Further Programming Concepts in C++TP016028 UC2F1007CSE Contents Introduction......................................................... 2 Class Diagram........................................................ 3 Use Case Diagram..................................................... 4 Activity Diagram..................................................... 5 Sequence Diagram..................................................... 6 Object-Oriented Concepts............................................. 7 Classes.............................................................7 Employee Parent Class.............................................7 Admin Child Class of Employee.....................................8 HR Child Class of Employee........................................8 Objects.............................................................9 In Login() function...............................................9 In displaySearch() function.......................................9 Encapsulation......................................................10 Constructors.......................................................11 Employee Class Constructor.......................................11 Admin Class Constructor..........................................11 HR Class Constructor.............................................11 Inheritance........................................................12 Polymorphism.......................................................12 Overriding.......................................................12 Overloading......................................................14 Validation.......................................................... 15 Gender field validation............................................15 Simple choices validation..........................................15 Validate Designation Entry.........................................15 Validate Department Entry..........................................16 1
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
Further Programming Concepts in C++ TP016028 UC2F1007CSE
Class Diagram..............................................................................................................................................3
Use Case Diagram........................................................................................................................................4
Validate Department Entry....................................................................................................................16
Validate IC field......................................................................................................................................16
Validate Date fields................................................................................................................................17
1
Further Programming Concepts in C++ TP016028 UC2F1007CSE
Test Plan....................................................................................................................................................18
System Reliability...................................................................................................................................21
Program sample outputs...........................................................................................................................22
The parent class where its fields can be inherited and the methods are publicly available for use
9
Further Programming Concepts in C++ TP016028 UC2F1007CSE
Admin Child Class of Employeeclass Admin:public Employee{public :
Admin(void);bool guiMenu();bool searchEmp();
};
The HR class which inherits all the fields and method from the Parent Employee class but overwrites the method called guiMenu() and has an extra new method called searchEmp()
HR Child Class of Employeeclass HR:public Employee{public:
HR(void);bool guiMenu();bool searchEmp();
};
The HR class which inherits all the fields and method from the Parent Employee class but overwrites the method called guiMenu() and has an extra new method called searchEmp()
10
Further Programming Concepts in C++ TP016028 UC2F1007CSE
Objects
In Login() function-Retriving An Admin object from file
This method encapsulates data as the functions using this method does not need to bother or handle the infromation being displayed or the format in which it will display, all the function need to know is that the method returns a string value.
12
Further Programming Concepts in C++ TP016028 UC2F1007CSE
Constructors
Employee Class ConstructorEmployee::Employee(void){
The constructor for the parent class Employee that takes in no values.
Admin Class ConstructorAdmin::Admin(void):Employee(){}
Since the Admin has no new fields all the fields that it has is from the parent Employee class which already has its own constuctor, therefor the Admin class constructor just needs to call one of the parent class constructor, where in this example its the Employee() constructor.
HR Class ConstructorHR::HR(void):Employee(){}
Since the HR has no new fields all the fields that it has is from the parent Employee class which already has its own constuctor, therefor the HR class constructor just needs to call one of the parent class constructor, where in this example its the Employee() constructor.
13
Further Programming Concepts in C++ TP016028 UC2F1007CSE
Inheritance
class Employee
class Admin:public Employee
class HR:public Employee
From the example above we can see that the class Admin and HR inherits the Employee class and since the the fields are set under the access modifier of protected and the method are under the the access modifier of public the two child classes has every field and method in them.
Polymorphism
Overriding-in guiMenu() of Employee Class and Admin Class
cout<<"'1' - My Account"<<endl;cout<<"'2' - Register New Employee"<<endl;cout<<"'3' - Search"<<endl;cout<<"'4' - Settings"<<endl;cin>>choice;cin.clear();cin.sync();
14
Further Programming Concepts in C++ TP016028 UC2F1007CSE
if (choice == '1') {
guiDetailA();}else if (choice == '2'){
Employee input;input.guiInput();
}else if (choice == '3'){
searchEmp();}else if (choice == '4');else if (choice == 'x' || choice == 'X') loopmenu = false;else{
printf("\a");cout<<"please choose either 1 , 2 , 3 , 4 or 'X'"<<endl;getche();
}}while (loopmenu);return true;
}
The since the Employee class methods are inherited into Admin class the guiMenu() method of Employee class is overridden with the guiMenu() method in the Admin class.
15
Further Programming Concepts in C++ TP016028 UC2F1007CSE
From the example above we can see the constructors are for the same Employee class but there are two of them, this is made possible by to overloading the constructors with different parameters and different amounts of parameters to take in.
16
Further Programming Concepts in C++ TP016028 UC2F1007CSE
Validation
Gender field validation//VALIDATE GENDER FIELDbool validateF_M(char check){