Top Banner
Sudantha Sulochana Gunawardena (CB003198) MODULE CODE : CE00314-2 FPC INTAKE CODE : HF09B1COM ASSIGNMENT TITLE : Further Programming Concepts in C++ SUBMITTED TO : Mr.Udesh Amarasinghe HAND IN DATE : 27 th August 2010 HAND OUT DATE : 2 nd November 2010
21
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Further Programming Concepts in C++

Sudantha Sulochana Gunawardena

(CB003198)

MODULE CODE : CE00314-2 FPC

INTAKE CODE : HF09B1COM

ASSIGNMENT TITLE : Further Programming Concepts in C++

SUBMITTED TO : Mr.Udesh Amarasinghe

HAND IN DATE : 27th August 2010

HAND OUT DATE : 2nd November 2010

Page 2: Further Programming Concepts in C++

Further Programming Concepts in C++

2

Acknowledgments

This was a great opportunity for me to put into practice which I learned in few lecturers

and my own research knowledge on object oriented programming and C++.

First and foremost I would like my sincere graduate to Mr.Udesh Amarasinghe for his

great guidance in this project.

Finally, I would like to thank each and every person who helped me in numerous ways

to make this project a success.

Page 3: Further Programming Concepts in C++

Further Programming Concepts in C++

3

Table of Contents

Assumptions .................................................................................................................... 4

Implementation ................................................................................................................ 5

Class Diagram ................................................................................................................. 6

Object Oriented Concepts ............................................................................................... 7

Classes ........................................................................................................................ 7

Objects ........................................................................................................................ 8

Abstraction ................................................................................................................... 8

Inheritance ................................................................................................................... 9

Polymorphism ............................................................................................................ 10

Static Polymorphism .............................................................................................. 10

Dynamic Polymorphism ......................................................................................... 11

Programming Concepts ................................................................................................. 12

User defined data types ............................................................................................. 12

Modularity .................................................................................................................. 12

Decomposition ........................................................................................................... 12

Extendibility ............................................................................................................... 12

Screens ......................................................................................................................... 13

Validations ..................................................................................................................... 16

Test Plans ..................................................................................................................... 17

Limitations ..................................................................................................................... 20

References .................................................................................................................... 21

Page 4: Further Programming Concepts in C++

Further Programming Concepts in C++

4

Assumptions

Users of the system are already provided with the usernames and passwords

which are required for authentication.

Doctors are supposed to edit or add medical records about any patients.

Only administrators are having authorization to edit or add patient’s payment

details.

All the users of this system have a basic knowledge of using computers and

experienced in working with console applications.

As this application depends on windows libraries the program will be used in

windows platform only.

Page 5: Further Programming Concepts in C++

Further Programming Concepts in C++

5

1.0 Implementation

The implementation of this program should be complete using C++ language and the

object oriented concepts. By using object oriented concepts the application can easily

extendable, implement new features and have many other benefits. As the first step of

the implementation it is required to identity the logical design of the application.

Unified modeling language (UML) can be used to model the design of the proposed

application. Foremost it is required to identify the user categories that interact with the

system. These ‘entities’ can be identified as Administration staff, doctors, nurses and

patients. Next it is required to identity the relationships between the system and the

entities for the next stage of implementation.

Following to next the attributes of each entity can be identified. Some of the entities may

have common attributes, for instance every person who interact with the system may

name a name, age and a gender so in this situation these common attributes can be

abstracted and create a common entity which can be inherited for the specializations of

the entities .

Also it is required to keep the data which will be stored in these attributes should be

secured. By using proper access modifiers this situation can be overcome.

The following diagram shows the class diagram which is a type of a UML diagram,

reflects the structure and the relationships of the system.

Page 6: Further Programming Concepts in C++

Further Programming Concepts in C++

6

2.0 Class Diagram

Page 7: Further Programming Concepts in C++

Further Programming Concepts in C++

7

3.0 Object Oriented Concepts

3.1 Classes

According to Hekmat (n.d) a class is a collection of a sharing a common attribute. The

following table shows the identified classes of the given scenario, its purpose and the

type of class.

Class Name Class Type Purpose

Person Base class Keep the generic information about

persons.

Administration Base class Keep generic and special information

about administration staff.

Patient Derived class Stencil for keep patient information.

Doctor Derived class Pattern for keep doctors information.

Nurse Derived class Structure to keep Nurses information.

Admin Derived class Keeps administration information.

SpecialFIO Template class Provide file input/output operations.

Support Classes

Login Class Authentication and authorization of users

to the system.

Menu Class Navigate the users in the system.

GUI Class Provide graphics and messages in the

console.

Error Handling Class Keep methods for user input validations.

Table 1 – Class Information.

Page 8: Further Programming Concepts in C++

Further Programming Concepts in C++

8

As the above figure the except the major classes the supportive classes provide various

functionalities to the system. As an example all the command line interface (CLI)

interactions are managed by the menu class and the authenticating and authorizations

of the users are done by the login class.

3.2 Objects

All the classes are used in this program as instances of the classes. In the system there

may me numerous number of patients, nurses or administrators. In the run time

instances on these classes will be used.

3.3 Abstraction

As Cain (2010), real world objects like doctors, Patients may have endless

characteristics but as the requirement of the system its need to select the required

characteristics likes medical details, allergies and required personal details, selecting

the required characteristics as the requirement can be considered as abstraction.

Abstraction helps to create a generalize emerge of an entity which can be specialized

by inheriting it. In the designed system person is identified as an abstract class which all

the users doctors, patients will be inherited from.

3.4 Encapsulation

Encapsulation is a way of protecting data by restricting access to them using access

modifiers. According to Balaguruswamy (2008) C++ supports three kinds of

encapsulation methods which are private, public and protected. In the deliberate system

most of the attributes are defined as private or protected to prevent the unauthorized

access. To provide access getter methods and setter methods can be used.

Page 9: Further Programming Concepts in C++

Further Programming Concepts in C++

9

3.5 Inheritance

As Schmidt (n.d) inheritance allows to create classes with specialization classes with

extendibility. The advantage of using inheritance is that to reusability of code, save the

time and effort of redoing the same work. In this project all the users who use the

system are inherits from the person class. Person class contains the basic attributes of

a person which are common to all users. The following class shows the inheritance of

the classes.

Figure – Inheritance

As the above diagram doctor who is an administrative user is inherited from two base

classes with multiple inheritances. Multiple inheritances is used because the

administrative users may have special features which are only required for

administrative personals. As C++ supports multiple inheritances these classes can be

easily extended with new features without altering the current code.

Page 10: Further Programming Concepts in C++

Further Programming Concepts in C++

10

3.6 Polymorphism

3.6.1 Static Polymorphism

In static polymorphism same methods which are implemented can be use in different

forms as its arguments and data types. In this project overriding and overloading which

are types of static polymorphism is used.

3.6.1.1 Overloading

According to Deitel & Deitel (2009) overloading is using multiple methods with same but

different arguments. In this project all the classes which are inherit from the person

class have overloaded constructor.

3.6.1.2 Overriding

As Deitel & Deitel (2009) describes overriding helps to replicate the similar process in

various object types in different ways. The printallInfo() method which inherits from

person class to its derived classes provide different operations as the type of the object.

In C++ concepts pure virtual functions have been used in the base person class to print

all person information.

Page 11: Further Programming Concepts in C++

Further Programming Concepts in C++

11

3.6.2 Dynamic Polymorphism

According to Vandervoodrde (2002) in dynamic polymorphism it is able to handle

heterogeneous collections of objects which will be determined in the program run time

with the same classes and methods.

In this project dynamic polymorphism is implemented using template classes and

methods. A special template class for file input and output operations have been used.

This template class and its methods can accept heterogeneous object types and

perform file writing, reading and searching operations. Using template classes it helps to

generalize the file IO operations to all files available in the program.

Primarily to keep records as several files are used to store and retrieve data also as the

system expands the number of files which will be used also increase. Using separate

methods for each file can be impossible and variables of these methods may use

unwanted memory. With template classes same method can be used for all file

operation by using polymorphism concepts.

Page 12: Further Programming Concepts in C++

Further Programming Concepts in C++

12

4.0 Programming Concepts

4.1 User defined data types

According to Stroustrup (2000) user defined data types will help to refer the stored data

efficiently. In this program design most of the data are categorized inside structures. For

Example the all the information about medical records is kept inside the Medical details

structure.

4.2 Modularity

Attached to the classes the functionalities of the system are made by modules. These

modules are divided logically as can be reused. All the modules which are commonly

used are placed in a common class.

4.3 Decomposition

As the problem statement this scenario is logically decomposed in to smaller solutions.

This approach will help to solve the main dilemma by solving the smaller problem, in

example searching is a solution for a miniature problem but it’s a part of the main

scenario problem.

4.4 Extendibility

As the implementation is based on object oriented concepts so this solution can be

easily extendable for new features. Also as the requirement in prospect more attributes

can be added to the classes and extend the solution.

Page 13: Further Programming Concepts in C++

Further Programming Concepts in C++

13

5.0 Screens

Login Screen

Figure - Login Screen

Select login type Screen

Figure - Login type

Page 14: Further Programming Concepts in C++

Further Programming Concepts in C++

14

Administrator Main menu

Figure - Administrator main menu

Doctor Main menu

Figure - Doctor Main menu

Page 15: Further Programming Concepts in C++

Further Programming Concepts in C++

15

Patient Medical Details

Figure - Patient Medical details

Patient Payment details

Figure - Patient Payment information

Page 16: Further Programming Concepts in C++

Further Programming Concepts in C++

16

6.0 Validations

Login Validations

Without a correct username or password users cannot access the system. Users

have to use their authorized usernames and passwords to login into the system.

Record Validations

When searching or viewing records the person ID’s are validated. If user inputs

an invalid ID which not available in the file it will not be accepted.

Gender Validations

In registration forms except M for male and F for female any other user input will

not be accepted.

Number Validations

In payment and other locations where takes user input for numeric values are

validated. If user entries a non numeric number it will not be accepted.

Doctor Availability

When assigning a doctor to a patient, if doctor is not available in doctor records a

warning message will be generated.

Error Messages

When error occurs a colorful error message will be promoted to users with the

error details and echo notification. Also when an action completed a message will

be shown.

Page 17: Further Programming Concepts in C++

Further Programming Concepts in C++

17

7.0 Test Plans

7.1 Unit Testing

ID Initial State Test Excepted Outcome

1 Login Screen Enter valid

username/password Show the user main menu

2 Login Screen Enter invalid

username password Login failed error message

3 Login Screen Kept Blank Login failed error message

4 Administrator Main menu Add a new Patient

with valid details

Patient added successful

message

5 Patient registration

Enter a invalid

character to gender

except M/F

Doesn’t accept the user

input and a beep message

6 View all patient details View patients Show the registered patient

details

7 Add patient payment

information

Input a valid

numeric value Accept the user input

8 Add patient payment

information

Input a invalid

numeric value

(character or

symbol)

Error message and doesn’t

accept the user input

9 View patient payment

information

Input a valid patient

number

Show the correct patient

information

Page 18: Further Programming Concepts in C++

Further Programming Concepts in C++

18

10 View patient payment

information

Input a invalid

patient number

Error message and redirect

back to main menu

11 Add staff Menu Create a new doctor Load the create new doctor

details

12 Create Doctor Enter doctor details

Save the doctor details and

redirect to the manage staff

menu

13 Create Nurse Enter nurse details

Save the nurse details and

redirect to the manage staff

menu

14 Search Staff Enter a valid staff ID Show the staff members

details

15 Search Staff Enter a invalid staff

ID Error message

16 Search Patients Enter a valid patient

ID Show patients information

17 Doctors main menu Add medical details Show the medical details

add form

18 Add medical details Enter valid medical

details Successful message

19 Add medical details Enter a valid date Successful message

20 Add medical details Enter a valid date Error message

21 Show medical details Enter a valid patient

ID

Show the patient medical

details

22 Show medical details Enter a invalid

patient ID Error message

Page 19: Further Programming Concepts in C++

Further Programming Concepts in C++

19

23 Patients Login menu -

Show the patients

payment/and medical

details

24 Nurse Menu - Ability to view patient

medical information

25 Password Validation

Enter first password

and second

password matching

Accept the password

26 Password Validation Enter non matching

passwords Reject the password

Table 2 – Unit Test Plan

Page 20: Further Programming Concepts in C++

Further Programming Concepts in C++

20

Limitations

Only can keep limited number of medical records.

Not be able to customize the payment details with payment types.

No multi user support and concurrency.

Extending the application may affect the current stored data in files in file input-

output operations.

The maximum number of data can be stored in a file is limited to 2GB.

Searching is limited, and searching with keywords is not applicable.

Page 21: Further Programming Concepts in C++

Further Programming Concepts in C++

21

References

Balagurusamy (2008), Object Oriented Programming With C++, India: TATA Mcgraw-

Hill.

Cain, J. (2010), Programming Abstractions - CS106B: California: Stanford University.

Deitel, H. & Deitel, P. (2009), C++ How to Program, USA: Prentice Hall.

Hekmat, S. (n.d), C++ Essentials, PragSoft Corporation.

Schmidt (n.d), C++ Programming Language, [Online]. Available from:

http://www.cs.wustl.edu/~schmidt/C++/ [Accessed on 31st October 2010 ].

Stroustrup, B. (2000). The C++ Programming Language, UK: Addison-Wesley.

Vandervoodrde, D. (2002), C++ Templates: The Complete Guide. Addison-Wesley

Professional: Canada.