C++ Assignment Document (APIIT)

Share Embed Donate


Short Description

This project is an individual assignment in the module Further Programming Concepts in C++ for the HF09B1SE. Main aim if...

Description

Further Programming Concepts in C++

Submitted by Tharanga Chandrasekara (CB002976)

Submitted to Mr. Udesh Amarasinghe

Module Code CE00314-2

Intake Code HF09B1COM

Assignment Title Individual Assignment

Due Date 2nd November 2010

Acknowledgements I would like to extend my gratitude to those who helped me in completing the individual assignment for the module further Programming Concepts in C++. I would like to express my appreciation and thankfulness to my Further Programming Concepts in C++ module Lecturer Mr. Udesh Amarasinghefor giving me the guidelines towards the successfulness of this project. His expertise on concepts of programming helped me to complete the assignment in the given timeframe. I’m very grateful for his guidance and the manner he helped me with the encountered problems. Finally, I would like to thank my institute, Asia Pacific Institute of Information Technology, for providing me the necessary laboratory and library facilities.

Abstract This project is an individual assignment in the module Further Programming Concepts in C++ for the HF09B1SE. Main aim if this project is to design a consol system to a clinic center by using C++ and object oriented concepts. There are four main types of users in this system. They are Administrator, Doctor, Nurse and Patient. Each user has its own access capabilities to the system.

Table of Contents

Acknowledgements ......................................................................................................... 1 Abstract ........................................................................................................................... 3 List of Figure ................................................................................................................... 6 List of Table..................................................................................................................... 6 1

Description and Justification on Design ................................................................... 7 1.1

Class Diagram.................................................................................................... 8

1.2

Class diagram Description ................................................................................. 9

1.3

Object arrays .................................................................................................... 10

1.4

Menus .............................................................................................................. 11

1.4.1

Dynamically changing menus .................................................................... 12

1.5

File handler Class ............................................................................................ 13

1.6

Settings Class .................................................................................................. 14

1.7

Validation Class ............................................................................................... 14

2 Description and justification on implementation code in terms of object oriented programming concepts. ................................................................................................. 15 2.1

Object Oriented Concepts used in the program ............................................... 15

2.1.1

Inheritance ................................................................................................. 16

2.1.2

Encapsulation ............................................................................................ 17

2.1.3

Polymorphism ............................................................................................ 19

2.1.4

Constructors .............................................................................................. 20

2.1.5

Static and const variable............................................................................ 21

2.2

C++ Concepts Used ......................................................................................... 22

2.2.1

Templates .................................................................................................. 22

2.2.2

Pass by Reference .................................................................................... 23

2.2.3

Argument Passing ..................................................................................... 24

2.2.4

Const Argument Passing ........................................................................... 25

2.2.5

Inline Functions ......................................................................................... 25

3 Description and Justification of the Validation codes applied into the implementation of the code. ................................................................................................................... 26

3.1

Validate Integer (only take integer as a user input) .......................................... 26

3.2

Date Validation ................................................................................................. 27

3.3

NIC validation ................................................................................................... 28

3.4

Cost Validation ................................................................................................. 29

3.5

File Open Validation ......................................................................................... 30

4

Description and justification on Test Plans and results. ......................................... 31

5

Assumptions and Limitations ................................................................................. 36 5.1

Limitations ........................................................................................................ 36

5.2

Assumptions..................................................................................................... 36

6

Conclusion ............................................................................................................. 37

7

Reference .............................................................................................................. 38

List of Figure Figure 1: Class Diagram.................................................................................................. 8 Figure 2: Illustration of the Object Array ........................................................................ 10 Figure 3: Code Sample for dynamically changing menus ............................................. 12 Figure 4: Inheritance in the Program (Part of the Class Diagram) ................................. 16 Figure 5 : Illustration of Login Access............................................................................ 17 Figure 6: Illustration of Doctor and DoctorControl Classes Access Contro ................... 18 Figure 7: View Single Data from File - Method 1 ........................................................... 19 Figure 8: View Single Data from File - Method 2 ........................................................... 19 Figure 9: Method signature of viewSingleDataFromFile ................................................ 20 Figure 10: Method signature of viewSingleDataFromFile .............................................. 20 Figure 11: Constructor 1 – MedicalBill........................................................................... 20 Figure 12: Constructor 2 – MedicalBill........................................................................... 20 Figure 13: Example to Static and const variable ........................................................... 21 Figure 14: getLoginDetails method Template ................................................................ 22 Figure 15: Calling the mainMenuHandler method ......................................................... 23 Figure 16: mainMenuHandler Declaration ..................................................................... 23 Figure 17: MedicalBill Method in MedicalBill Class ....................................................... 24 Figure 18: Parameters of MedicalBill Method................................................................ 24 Figure 19: Const Argument Passing.............................................................................. 25 Figure 20: Inline Function .............................................................................................. 25 Figure 21: validateInteger function ................................................................................ 26 Figure 22: Error message in validateIneger function ..................................................... 26 Figure 23: isValidDate Function .................................................................................... 27 Figure 24: setNIC function............................................................................................. 28 Figure 25: File Open Validation Function ...................................................................... 30 Figure 26 : Error message of File Open validation ........................................................ 30

List of Table Table 1: Test Plan ......................................................................................................... 31

1 Description and Justification on Design

To design the proposed system there are several classes been used, there are 

Login



Diagnosis



User



DiagnosisControl



Administrator



MedicalBill



Doctor



MedicalBill Control



Nurse



MedicalExpences



Patient



Menu



AdministratorControl



Validation



DoctorControl



Settings



NurseControl



FileHandler



PatientControl

1.1 Class Diagram

Login #UserName : char #Password : char -changePassword() : int -setPassword(in psw : char = "123") +login() +getPassword() : char

User -val : Validation -log : Login -name : char -NIC : char -gender : char -DOB : char -joinedDate : char -nationality : char -status : char +getName() : char +getNIC() : char +getGender() : char +gedDOB() : char +getJoineddate() : char +getNationality() : char +getStatus() : char +setName() : void +setNIC() : void +setGender() : void +setDOB() : void +setJoinedDate() : void +setNationality() : void +setStatus() : void «inherits»

«inherits» «inherits»

«inherits»

Doctor

Administrator

Patient

-dc : DoctorControl -digc : DiagnosisControl -pc : PatientControl -mbc : MedicalBillControl -IDGenerator : int -ID : int -currentDiagnosis : char -SpecialArea : char +displaySingleData() : void +displayAllData(in : bool) : void +setData(in : bool) : void +getSpecialArea() : char +setSpecialArea() : void

+ac : AdministratorControl +dc : DoctorControl +nsc : NurseControl +pc : PatientControl +mbc : MedicalBillControl +digc : DiagnosisControl +IDGenerator : int +ID : int +displaySingleData() : void +displayAllData(in : bool) : void +setData() : void

-val : Validation -menuClass : Menu -fh : FileHandler -Alergy : char -IDGenerator : int -ID : int +displayAllData(in : bool) : void +displaySingleData() : void +setData(in : bool) : void +getID() : int +setID(in : bool) : void +editOneByOne() : void +Patient() +~Patient()

1

-docc

1

-doc

-End14

* 1

-adminc

1

-psc

1

-ps

1

-End40 *

1

-admin *

DoctorControl

*

-friend class Administrator -menuClass : Menu -val : Validation +mainMenuHandler(in : int, in

: Administrator) : int -End12

-End22 1

-dig

*-End38

1

-nsc

1

-ns

-ps

-End42

AdministratorControl

-friend class Doctor -menuClass : Menu -val : Validation +mainMenuHandler(in : Doctor) : int +addDoctor() : void +searchDoctor(in : Doctor) : int +viewAllDoctor(in : Doctor) : void

-End26

Nurse -digc : DiagnosisControl -pc : PatientControl -mbc : MedicalBillControl -nsc : NurseControl -IDGenerator : int -ID : int +displaySingleData() : void +displayAllData(in : bool) : void +setData(in : bool) : void +getID() : int +setID() : void +editOneByOne() +Nurse() +~Nurse()

*

-End36

*

*

*

PatientControl

NurseControl

-menuClass : Menu -fh : FileHandler +addPatient() : void +viewSinglePatient(in : Patient) : void +viewAllPatient(in : Patient) : void +editPatient(in : Patient) : void +searchPatient(in : Patient) : int +deletePatient(in : Patient) : void +viewMedicalBill(in : Patient) : void

-friend class Nurse -menuClass : Menu -val : Validation +addNurse() +searchNurse(in : Nurse) : int +viewAllNurse(in : Nurse) : void

* -End34 -End30

-End41 -End35 1 *

-End20

-docc

0..1

*

-End28

-mb

-End33

*

1

1

MedicalExpences Diagnosis

-End24

*

-name : char +ID : int +IDGenerator : int +status : char -menuClass : Menu -fp : FileHandler +Diagnosis() +~Diagnosis() +displayAllData(in : bool) : void +displaySingleData() : void +setData(in : bool) : void +getID() : int +setID(in : int) : void +getName() : char +setName(in * : char) : void +getStatus() : char +setStatus(in : char) : void +editOneByOne() : void -End2

1

-checkUpCost : int -medicineCost : int -totalCost : int -diagnosisName : char -friend class Doctor +setCost() : void +modifyCost() : void +getCost() : void +resetCost() : void +MedicalExpences()

1..*

-me

-dig -End6 DiagnosisControl

1

1

-digc

-dg

*

-menuClass : Menu -fh : FileHandler +addDiagnosis() : void +displayDiagnosis() : void +viewAllDiagnosiss(in : Diagnosis) : void +deleteDiagnosis() : void +editDiagnosis() : void -End4

* -End18

MedicalBill

MedicalBillControl

-End8

-End16

*

-me

-mb

1

-menuClass : Menu -fp : FileHandler +addAllExpencesToAPatient() : void

*

1

1..*

-mb

1

-mbc

-ID : int -mm : MedicalExpences -total : float -status : char -val : Validation -fh : FileHandler +MedicalBill() +MedicalBill(in : int, in : int, in : int) : void +displayAllData() : void +displaySingleData(in : bool) : void +setData() : void +calculateFinalTotal() : float +setStatus(in : char) : void +setID() : void +getStatus() : char +setStatus(in : int) : void +editOneByOne() : void

*

* -End10 -End11

-End1

1

-End13

1 -End3

1

1

FileHandler -val -friend class AdministratorControl +viewAllDataFromFile(in myDataType) : void +searchANDEditDataFromFile(in myDataType) : void +viewSingleDataFromFile(in myDataType) : void +viewSingleDataFromFile(in myDataType) : void +addNewRecordToFile(in myDataType) : void +IDGenerator(in myDataType) : void +deleteRecordFromFile(in myDataType) : void +modifyRecordsInFile(in myDataType) : void +getLoginDetails(in myDataType) : void

-End5

1 -End7

1 -End9

1 -End17

-End19 1

1 -End15

1

Menu 1

-End21 1

-End23 1

-End25

-End27

-setting +title(in * : char) +userLevelMenu() : int +mainMenu(in : int) : int +patientMainMenu() : int +firstCommomSubMenu(in * : char) : int +diagnosisHandlingFirstMenu(in * : char) : int +costHandlingFirstMenu(in * : char) : int +medicalBillMenu(in * : char) : int +SearchOptionMenu(in * : char) : int +doctorMainMenu() : int +nurseMainMenu() : int +exit() : char

1 -End29

1

Figure 1: Class Diagram

PDF file and a JPEG image is been provided separately for class diagram.

*

Validation 1 1

* -End37 -End32

-End31

+readInteger() : int +isDateValid(in : char) : bool +invalidInputError() : void

1

-End39

1.2 Class diagram Description

Administrator, Doctor, Nurse, Patient classes are inherits from the User class so that these classes share same attributes such as name, NIC, date of birth, gender, joined date, nationality due to the inheritance from a User class. Classes like Administrator, Doctor, Nurse, Patient classes have their own add, edit, search, view and delete methods in separate classes. This has been implemented to achieve the user levels in the application and to give the necessary privilege to the relevant users. MedicalBill class also has its own control class to give the necessary privilege to the relevant users.

1.3 Object arrays

Object arrays been used in the Medical Bill Report. MedicalExpences object array of 3 been used to store the medical expenses of the each patient. This each object will hold diagnosis name, check up cost, medicine cost and total cost for each diagnosis. As a result of using this simple object array system can hold 9 different variable values so it makes the program more efficient and easy to program. Following is the illustration of the used object array.

Patient ID

Medical Bill

Diagnosis 1

Checkup Cost

Medicine cost

Final Total

Diagnosis 2

Checkup Cost

Medicine cost

Final Total

Diagnosis 3

Checkup Cost

Medicine cost

Final Total

Final Total:

Figure 2: Illustration of the Object Array

Object Array

1.4 Menus

Menu class will handle main functions regarding the menus in the program. By using a separate class to handle the menus, will give a major advantage to the programmer and to the program. As an example many objects in the program will use the same menu class functions to fulfill the functions of their classes so it will reduce the number of code lines and increase the speed of the program due to that. And also it is easy for a new programmer to understand the program and to make the modifications if it’s necessary in the future, since all the functions are implemented in a one place so it is easy to acquire a wider picture of menu functions rather than looked into several places of the program to find the menu handling in the program. Each user will have their own separate special menus; this has been done to restrict the functionalities of the restricted users, who are not permitted to execute some special functions in the system such as, 

Add a Doctor



Delete Doctor



Add Diagnosis

In some situations common sub menus will be used to every user so it will reduce the programming conflicts when it comes to implementation of the design.

1.4.1 Dynamically changing menus

Dynamically changing menus will also be used in common menus. These menus will change their functions and user interface according to the parameters which is passed to the menu function. These menu functions will be a good implementation method because it reduces the time to program the separate menus and also helps the programmer to reduce the lines of codes and it will speed up the performance and the speed of the program. As an example following menu will change its user interface according to the parameters which is passed to the menu function. int Menu::firstCommomSubMenu(char * type){ int option; title(type); cout cout cout cout

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF