Vous êtes sur la page 1sur 21

Sudantha Sulochana Gunawardena (CB003198)

MODULE CODE INTAKE CODE ASSIGNMENT TITLE SUBMITTED TO HAND IN DATE HAND OUT DATE

: CE00314-2 FPC : HF09B1COM : Further Programming Concepts in C++ : Mr.Udesh Amarasinghe : 27th August 2010 : 2nd November 2010

Further Programming Concepts in C++

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.

Further Programming Concepts in C++

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

Further Programming Concepts in C++

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 patients 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.

Further Programming Concepts in C++

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.

Further Programming Concepts in C++

2.0 Class Diagram

Further Programming Concepts in C++

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 Person Class Type Base class persons. Keep generic and special information Base class about administration staff. Stencil for keep patient information. Pattern for keep doctors information. Structure to keep Nurses information. Keeps administration information. Provide file input/output operations. Purpose Keep the generic information about

Administration

Patient Doctor Nurse Admin SpecialFIO

Derived class Derived class Derived class Derived class Template class

Support Classes Login Menu GUI Error Handling Authentication and authorization of users Class Class Class Class to the system. Navigate the users in the system. Provide graphics and messages in the console. Keep methods for user input validations.
Table 1 Class Information.

Further Programming Concepts in C++

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.

Further Programming Concepts in C++

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.

Further Programming Concepts in C++

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.

10

Further Programming Concepts in C++

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.

11

Further Programming Concepts in C++

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 its 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.

12

Further Programming Concepts in C++

5.0 Screens
Login Screen

Figure - Login Screen

Select login type Screen

Figure - Login type

13

Further Programming Concepts in C++

Administrator Main menu

Figure - Administrator main menu

Doctor Main menu

Figure - Doctor Main menu

14

Further Programming Concepts in C++

Patient Medical Details

Figure - Patient Medical details

Patient Payment details

Figure - Patient Payment information

15

Further Programming Concepts in C++

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 IDs 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.

16

Further Programming Concepts in C++

7.0 Test Plans


7.1 Unit Testing
ID Initial State Test Enter valid username/password Enter invalid username password Excepted Outcome

Login Screen

Show the user main menu

Login Screen

Login failed error message

Login Screen

Kept Blank

Login failed error message

Administrator Main menu

Add a new Patient with valid details Enter a invalid

Patient added successful message Doesnt accept the user input and a beep message Show the registered patient details

Patient registration

character to gender except M/F

View all patient details

View patients

Add patient payment information

Input a valid numeric value Input a invalid

Accept the user input

Add patient payment information

numeric value (character or symbol)

Error message and doesnt accept the user input

View patient payment information

Input a valid patient number

Show the correct patient information

17

Further Programming Concepts in C++

10

View patient payment information

Input a invalid patient number

Error message and redirect back to main menu Load the create new doctor details Save the doctor details and

11

Add staff Menu

Create a new doctor

12

Create Doctor

Enter doctor details

redirect to the manage staff menu Save the nurse details and

13

Create Nurse

Enter nurse details

redirect to the manage staff menu

14

Search Staff

Enter a valid staff ID Enter a invalid staff ID Enter a valid patient ID Add medical details Enter valid medical details Enter a valid date

Show the staff members details Error message

15

Search Staff

16

Search Patients

Show patients information Show the medical details add form Successful message

17

Doctors main menu

18

Add medical details

19

Add medical details

Successful message

20

Add medical details

Enter a valid date Enter a valid patient ID Enter a invalid patient ID

Error message Show the patient medical details Error message

21

Show medical details

22

Show medical details

18

Further Programming Concepts in C++

Show the patients 23 Patients Login menu payment/and medical details 24 Nurse Menu Enter first password 25 Password Validation and second password matching 26 Password Validation Enter non matching passwords
Table 2 Unit Test Plan

Ability to view patient medical information

Accept the password

Reject the password

19

Further Programming Concepts in C++

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 inputoutput 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.

20

Further Programming Concepts in C++

References

Balagurusamy (2008), Object Oriented Programming With C++, India: TATA McgrawHill. 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.

21

Vous aimerez peut-être aussi