Professional Documents
Culture Documents
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
Validate IC field..................................................................................................... 16
Validate Date fields............................................................................................... 17
Validate search select........................................................................................... 17
Test Plan................................................................................................................... 18
1
UC2F1007CSE
Validation.............................................................................................................. 18
System Reliability.................................................................................................. 21
Program sample outputs.......................................................................................... 22
Login screen.......................................................................................................... 22
Admin Menu.......................................................................................................... 22
HR Menu................................................................................................................ 23
Normal staff Menu................................................................................................. 23
View Details........................................................................................................... 24
Register new account............................................................................................ 24
Edit account.......................................................................................................... 26
Search Prompt....................................................................................................... 26
Search Result........................................................................................................ 27
Additional Features................................................................................................... 28
Add Designation and specify designations access outside program....................28
Add Departments outside program.......................................................................28
Multi Field Search.................................................................................................. 28
Conclusion................................................................................................................ 29
References................................................................................................................ 30
UC2F1007CSE
Introduction
Throughout the project creation period it took me 4 phases of routine in order to complete
the assignment. The first phase that I dived into head first is the learning phase where I read
books, learned the syntaxes and understood how object oriented programming concepts, this
phase took the longest period. The second phase is the project design phase, in this phase I
created the designs of the screen outputs and the flow of the program. The third phases is the
programming phase this is where I put in the logics for the solutions, object oriented
programming concepts and validations to the project solution. The last phase is the testing phase,
in the testing phase I used the program, tested its inputs and output and also add in some last
minutes logic correction and design correction.
This assignment was a success for one reason is due to the modules combined lecturers
guidance their help in showing us how object oriented programming concepts can be used to
solve problems allowed us to apply the OOP concepts that made the programming task more
easier, other than that I was also able to learn and understand the syntax and features of C++
faster because of the lectures and lab session conducted. The library was also a big help although
most of the time the book needed is not available and the borrowing period of the book is too
short still it was able to provide me with some reasonable books while waiting for the book that I
needed.
UC2F1007CSE
Class Diagram
UC2F1007CSE
UC2F1007CSE
UC2F1007CSE
Activity Diagram
UC2F1007CSE
UC2F1007CSE
Sequence Diagram
UC2F1007CSE
Object-Oriented Concepts
Classes
Employee Parent Class
class Employee{
friend ostream& operator<< (ostream&,Employee);
protected :
string empID;
string name;
string IC;
string gender;
string designation;
string department;
string dateJoined, DOB;
string nationality;
string religion;
string maritialStatus;
public :
Employee(void);
Employee(int);
Employee(string,string,string,string,string,string,string,string,string,string
,string);
virtual bool guiInput(); //to input all data, used during registration
of new employee
virtual bool guiInputHR();
virtual bool guiMenu();
virtual bool guiDetail();
virtual bool guiDetailA();
virtual bool guiDetailHR();
virtual bool guiEdit();
virtual bool guiEditA();
virtual bool guiEditHR();
bool write2File(); //writes the edited employee details
bool Delete(); //deletes the employee from file
//setter and getter
string getEmpID();
string getName();
string getIC();
string getGender();
string getDesignation();
string getDepartment();
string getDateJoined();
string getDOB();
string getNationality();
string getReligion();
string getMaritialStatus();
};
The parent class where its fields can be inherited and the methods are publicly available for use
10
UC2F1007CSE
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()
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()
11
UC2F1007CSE
Objects
In Login() function
This function retrives an Admin object from the binary file according to the employee ID and
then executes the Admin objects guiMenu() method.
In displaySearch() function
This function get a list of search hits from the file as an array of Employee objects then displays
the employee objects details.
12
UC2F1007CSE
Encapsulation
Display of employee details
ostream& operator<< (ostream& out, Employee a){
out<<a.empID<<" "<<a.IC<<" "<<a.name;
return out;
}
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.
13
UC2F1007CSE
Constructors
Employee Class Constructor
Employee::Employee(void){
empID = "-";
name = "-";
IC = "-";
gender = "-";
designation = "-";
department = "-";
dateJoined = "-";
DOB = "-";
nationality = "-";
religion = "-";
maritialStatus = "-";
The constructor for the parent class Employee that takes in no values.
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 Constructor
HR::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.
14
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 Admin class:
bool Admin::guiMenu(){
char choice;
bool loopmenu = true;
do{
system("cls");
cout<<endl;
cout<<setw(35)<<"-----------------"<<endl;
cout<<setw(35)<<"# ADMINISTRATOR #"<<endl;
cout<<setw(35)<<"-----------------"<<endl;
cout<<endl;
cout<<"'1' cout<<"'2' cout<<"'3' cout<<"'4' cin>>choice;
cin.clear();
cin.sync();
My Account"<<endl;
Register New Employee"<<endl;
Search"<<endl;
Settings"<<endl;
15
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.
16
UC2F1007CSE
Overloading
empID = empID1;
name = name1;
IC = IC1;
gender = gender1;
designation = designation1;
department = department1;
dateJoined = dateJoined1;
DOB = DOB1;
nationality = nationality1;
religion = religion1;
maritialStatus = maritialStatus1;
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.
17
UC2F1007CSE
Validation
Gender field validation
//VALIDATE GENDER FIELD
bool validateF_M(char check){
switch (check){
case 'F' :
case 'f' :
case 'm' :
case 'M' :{
return true;
}
default : {
cout<<"\nplease choose either 'F' or 'M'"<<endl;
return false;
}
}
18
UC2F1007CSE
i++;
}
if(atoi(choice)> i){
cout<<"choose numbers smaller then "<<++i<<endl;
return false;
}
return true;
while(choice[i] != '\0'){
if(choice[i] > 57 || choice[i] < 48){
cout<<"please enter only numbers"<<endl;
return false;
}
i++;
}
i = 0;
a = readDep();
while(a != NULL){
a = a->next;
i++;
}
if(atoi(choice)> i){
cout<<"choose numbers smaller then "<<++i<<endl;
return false;
}
return true;
Validate IC field
//VALIDATE IC FIELD
bool validateIC(char ic[]){
string checkIC = ic;
int i = 0;
bool check = true;
if(strlen(ic) > 12 || strlen(ic) < 12){
cout<<"your IC number must be exactly 12 characters long with no
space or aplhabets"<<endl;
check = false;
}
while(ic[i] != '\0'){
if(ic[i] > 57 || ic[i] < 48){
cout<<"please enter only numbers"<<endl;
return false;
}
i++;
}
return check;
19
UC2F1007CSE
20
UC2F1007CSE
Test Plan
Validation
Component
Criteria
Expected result
Actual result
F || f || M || m
Return true
Return true
Else
Display error
please choose
either F or M.
Return false
Display error
please choose
either F or M.
Return false
Return true
Return true
If not a number
Display error
please enter only
numbers.
Return false
Display error
please enter only
numbers.
Return false
Display error
Choose numbers
smaller then [last
designation
number].
Return false
Validate Designation
field
21
Validate Department
field
Validate IC field
Return true
Return true
If not a number
Display error
please enter only
numbers.
Return false
Display error
please enter only
numbers.
Return false
Display error
Choose numbers
smaller then [last
department
number].
Return false
Return true
Display error
Choose numbers
smaller then [last
department
number].
Return false
Return true
Display error
your IC number
must be exactly 12
characters long
with no space or
alphabets.
Return false
Display error
please enter only
numbers.
Return false
Display error
your IC number
must be exactly 12
characters long
with no space or
alphabets.
Return false
Display error
please enter only
numbers.
Return false
Return true
Return true
Display error
please follow
DD/MM/YYYY
format.
Display error
please follow
DD/MM/YYYY
format.
UC2F1007CSE
22
Return false
If not number or /
UC2F1007CSE
Return false
Display error
please enter only
numbers or /
If choice is within search Return true
list numbers
Display error
please enter only
numbers or /
Return true
Return false
Return false
23
UC2F1007CSE
System Reliability
Component
Criteria
Expected result
Actual result
Login
Displays admin
menu.
Displays admin
menu.
Displays human
resource staff
menu.
Displays staff
details.
Displays human
resource staff
menu.
Displays staff
details.
User select my
account
Display users
details.
Display users
details.
View details
Edit details
Delete staff
Search staff
24
success
UC2F1007CSE
success
25
UC2F1007CSE
Admin Menu
26
UC2F1007CSE
HR Menu
27
UC2F1007CSE
View Details
28
UC2F1007CSE
Edit account
Search Prompt
29
UC2F1007CSE
Search Result
30
UC2F1007CSE
Additional Features
The designation can be specified in the designation.txt file and the designations access
can be specify 1,2 or 3 in front of the designation name without space and each 1, 2 and 3
represents the Admin account access, HR account access and Normal staff account access.
The department can be specified in the department.txt file each line in the file represents
a department.
The search just takes in one string but it has the ability to search all the fields for
matching results, this way the search menu is simplified and the search results are optimized by
proper separation between the fields and proper formatting of the fields.
31
UC2F1007CSE
Conclusion
Through out the assignment I have realized that even though C++ is not as modern as
Java but C++ has the ability to create large and complex systems due to the fact that it is an
object oriented programming language. C++ also has certain features other programming
languages dont have like pointers and operator overloading, these features have proved to be
very useful over course of the assignments program development. I believe C++ could be better
if its library functions are more well developed like Javas API. Due to current growth of internet
technologies I believe that C++ as the most demanded programming language is soon to change,
even so the use of C++ to create a system has made me more knowledgeable on the field of
software development
32
UC2F1007CSE
References
1.
DEITEL, H. M., 2002, C++ How to Program.5th edition, London, Prentice Hall.
2.
JOYCE FARRELL, 2009, Object-Oriented Programming USING C++, 4th edition, USA,
COURCE TECHNOLOGY CENGAGE Learning
3.
2010,
ASCII
Table
and
Description,[online],
ASCIITable,
Available
from
http://www.asciitable.com/, [12/11/2010]
4.
2010,
string,
[online],
cplusplus,
Available
from
http://www.cplusplus.com/reference/string/string/, [11/11/2010]
33