Contents
Contents
Introduc Introductiontion 22 C!ass "iagram C!ass "iagram ## UseUse Case Case "iagram"iagram $$ %cti&it'
%cti&it' "iagram"iagram (( Se)uence
Se)uence "iagram"iagram 66 *,ect-*riented Concepts
*,ect-*riented Concepts 77 C!asses
C!asses 77 Emp!o'ee
Emp!o'ee ParParent ent C!assC!ass 77 %dmin Chi!d C!ass o.
%dmin Chi!d C!ass o. Emp!o'eeEmp!o'ee 88 / Chi!d C!ass o. Emp!o'ee8 / Chi!d C!ass o. Emp!o'ee8 *,ects
*,ects In
In ogin34 .unctionogin34 .unction In
In disp!a'Seardisp!a'Search34 ch34 .unction.unction Encapsu!a
Encapsu!ationtion 1010 Constructor
Constructorss 1111 Emp!o'ee
Emp!o'ee C!ass C!ass ConstructorConstructor1111 %dmin C!ass
%dmin C!ass ConstructorConstructor 1111 /
/ C!ass C!ass ConstructorConstructor1111 Inheritance Inheritance 1212 Po!'morp Po!'morphismhism 1212 *&erriding *&erriding 1212 *&er!oading *&er!oading 1$1$ 5 5a!idationa!idation 1(1( ender e!d
ender e!d &a!idation&a!idation 1(1( Simp!e
Simp!e choices choices &a!idation&a!idation 1(1( 5
5a!idate a!idate "esignatio"esignation n Entr'Entr' 1(1( 5
5a!idate a!idate "epartment "epartment Entr'Entr' 1616 5
5a!idate IC a!idate IC e!de!d 1616 5
5a!idate "ate a!idate "ate e!dse!ds 1717 5
S'stem
S'stem e!ie!iai!it'ai!it' 2121 Progr
Program samp!e am samp!e outputsoutputs 2222 ogin
ogin screenscreen 2222 %dmin enu
%dmin enu 2222 /
/ enuenu 2#2# 9orma! sta:
9orma! sta: enuenu 2#2# 5ie;
5ie; "etai!s"etai!s2$2$ egi
egister ster ne; ne; accountaccount 2$2$ Edit account
Edit account 2626 Search
Search PrompPromptt 2626 Search esu!t
Search esu!t 2727 %dditiona
%dditiona! ! FFeatureseatures 2828 %dd "esigna
%dd "esignation and speci.' designtion and speci.' designation<s access outsation<s access outside programide program2828 %dd "epartments outside program
%dd "epartments outside program 2828 u!ti
u!ti FFie!d ie!d SearchSearch 2828 Conc!usion Conc!usion 22 e.er e.erencesences #0#0 2 2
5
5a!idationa!idation 1818 S'stem
S'stem e!ie!iai!it'ai!it' 2121 Progr
Program samp!e am samp!e outputsoutputs 2222 ogin
ogin screenscreen 2222 %dmin enu
%dmin enu 2222 /
/ enuenu 2#2# 9orma! sta:
9orma! sta: enuenu 2#2# 5ie;
5ie; "etai!s"etai!s2$2$ egi
egister ster ne; ne; accountaccount 2$2$ Edit account
Edit account 2626 Search
Search PrompPromptt 2626 Search esu!t
Search esu!t 2727 %dditiona
%dditiona! ! FFeatureseatures 2828 %dd "esigna
%dd "esignation and speci.' designtion and speci.' designation<s access outsation<s access outside programide program2828 %dd "epartments outside program
%dd "epartments outside program 2828 u!ti
u!ti FFie!d ie!d SearchSearch 2828 Conc!usion
Conc!usion 22 e.er
e.erencesences #0#0 first need to download it.
Introduction
Introduction
Throughout the project creation period it took me 4 phases of routine in order to complete 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
the assignment. The first phase that I dived into head first is the learning phase where I readfirst is the learning phase where I read books, learned the syntaxes and understood how object oriented programming concepts, this 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 phase took the longest period. The second phase is the project design phase, in this phase I
created the designs of the screen ou
created the designs of the screen outputs and the flow of the program. The third phatputs and the flow of the program. The third pha ses is theses is the programming phase this is where I put in the logics for the sol
programming phase this is where I put in the logics for the solutions, object orientedutions, object oriented programming concepts and validations to the project solution. The last phase is t
programming concepts and validations to the project solution. The last phase is the testing phase,he testing phase, in the testing phase I used the
in the testing phase I used the program, tested its inputs and output and also aprogram, tested its inputs and output and also add in some lastdd in some last minutes logic correction and design correction.
minutes logic correction and design correction.
This assignment was a success for one reason is due
This assignment was a success for one reason is due to the module’s combined lecturersto the module’s combined lecturers guidance their help in showing us how object oriented programming concepts can be used to guidance their help in showing us how object oriented programming concepts can be used to solve problems allowed us to apply the
solve problems allowed us to apply the ! concepts that made the programming task more! concepts that made the programming task more easier, other than that I was also able to learn and
easier, other than that I was also able to learn and understand the syntax and features of "##understand the syntax and features of "## faster because of the lectures and lab
faster because of the lectures and lab session conducted. The library was also a big help session conducted. The library was also a big help althoughalthough most of the time the book need
most of the time the book needed is not available and the ed is not available and the borrowing period of the book is tooborrowing period of the book is too short still it was able to provide me with some reasonable bo
short still it was able to provide me with some reasonable bo oks while waiting for the book that Ioks while waiting for the book that I needed.
needed.
# #
Class Diagram
first need to download it.
Use Case Diagram
(
first need to download it.
Activity Diagram
7
first need to download it.
Sequence Diagram
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, DO; string nationality; string religion; string maritial!tat"s; p"#lic : Employee($oid); Employee(int); Employee(string,string,string,string,string,string,string,string,string,string ,string);
$irt"al #ool g"iInp"t(); %%to inp"t all data, "sed d"ring registration of ne employee $irt"al #ool g"iInp"t'(); $irt"al #ool g"ien"(); $irt"al #ool g"iDetail(); $irt"al #ool g"iDetail*(); $irt"al #ool g"iDetail'(); $irt"al #ool g"iEdit(); $irt"al #ool g"iEdit*(); $irt"al #ool g"iEdit'();
#ool rite+ile(); %%rites t-e edited employee details #ool Delete(); %%deletes t-e employee from file
%%setter and getter string getEmpID(); string get.ame(); string getIC(); string get/ender(); string getDesignation(); string getDepartment(); string getDateJoined(); string getDO(); string get.ationality(); string geteligion(); string getaritial!tat"s(); 0;
The parent class where its fields can be inherited and the methods are publicly available for use first need to download it.
Admin Cild Class o! Employee class *dmin:p"#lic Employee { p"#lic : *dmin($oid); #ool g"ien"(); #ool searc-Emp(); 0;
The $% class which inherits all the fields and method from the !arent &mployee class but overwrites the method called gui'enu() and has an extra new method called search&mp()
"# Cild Class o! Employee
class ':p"#lic Employee { p"#lic: '($oid); #ool g"ien"(); #ool searc-Emp(); 0;
The $% class which inherits all the fields and method from the !arent &mployee class but overwrites the method called gui'enu() and has an extra new method called search&mp()
11
Objects
In $ogin%& !unction
*%etriving +n +dmin object from file
if(empID1s"#str(2,3)1compare( 4*4) 55 2){
*dmin loged 5 retri$e*dm(con$ertID(empID)); if(loged1getEmpID()1compare(empID) 65 2){
co"t<<47n8lease enter t-e correct 74Employee ID744<<endl;
getc-(); contin"e; 0
if(6c-ec98ass(con$ertID(empID),pass)){
co"t<<47n8lease enter t-e correct 748assord744 <<endl; getc-(); contin"e; 0 %%r"n *dmin o#ect loged1g"ien"(); 0
This function retrives an +dmin object from the binary file according to the employee I and then executes the +dmin object’s gui'enu() method.
In displaySearc%& !unction
*in displaying employee list from search results
int display!earc-(Employee a, int n) {
int i 5 2, 5 2;
co"t<<4C-oice EmpID IC .ame4<<endl; for(i 5 2; i < n ;i){
;
if(<32)co"t<<4=4<<<<4= > 4<<a?i@<<endl;
else if(<322)co"t<<4=4<<<<4= > 4<<a?i@<<endl; else if(<3222)co"t<<4=4<<<<4= > 4<<a?i@<<endl; else co"t<<4=4<<<<4=> 4<<a?i@<<endl;
0
ret"rn i; 0
This function get a list of search hits from the file as an array of &mployee objects then displays the employee object’s details.
first need to download it.
isplay of employee details
ostream& operator<< (ostream& o"t, Employee a){ o"t<<a1empID<<4 4<<a1IC<<4 4<<a1name; ret"rn o"t;
0
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.
1#
Constructors
Employee Class Constructor
Employee::Employee( $oid){ empID 5 4>4; name 5 4>4; IC 5 4>4; gender 5 4>4; designation 5 4>4; department 5 4>4; dateJoined 5 4>4; DO 5 4>4; nationality 5 4>4; religion 5 4>4; maritial!tat"s 5 4>4; 0
The constructor for the parent class &mployee that takes in no values.
Admin Class Constructor
*dmin::*dmin($oid):Employee() {0
-ince the +dmin has no new fields all the fields that it has is from the pa rent &mployee class which already has its own constuctor, therefor the +dmin class constructor just needs to call one of the parent class constructor, where in this example its the &mployee() constructor.
"# Class Constructor
'::'($oid):Employee() {0
-ince the $% has no new fields all the fields that it has is from the parent & mployee class which already has its own constuctor, therefor the $% class constructor just needs to call one of the parent class constructor, where in this example its the &mployee() constructor.
first need to download it.
class Employee
class *dmin:p"#lic Employee class ':p"#lic Employee
rom the example above we can see that the class +dmin and $% inherits the &mployee 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.
Polymorpism
Overriding
*in gui'enu() of &mployee "lass and +dmin "lass In &mployee class/ #ool Employee::g"ien"() { system(4cls4); ret"rn g"iDetail(); 0 In +dmin class/ #ool *dmin::g"ien"(){ c-ar c-oice; #ool loopmen" 5 tr"e; do{ system(4cls4); co"t<<endl; co"t<<set(AB)<< 4>>>>>>>>>>>>>>>>>4 <<endl; co"t<<set(AB)<< 4 *DI.I!*O 4<<endl; co"t<<set(AB)<< 4>>>>>>>>>>>>>>>>>4 <<endl; co"t<<endl;
co"t<<4=3= > y *cco"nt4<<endl;
co"t<<4=+= > egister .e Employee4 <<endl; co"t<<4=A= > !earc-4<<endl; co"t<<4== > !ettings4<<endl; cinFFc-oice; cin1clear(); cin1sync(); 1(
{ g"iDetail*(); 0 else if (c-oice 55 =+=) { Employee inp"t; inp"t1g"iInp"t(); 0
else if (c-oice 55 =A=) {
searc-Emp(); 0
else if (c-oice 55 ==);
else if (c-oice 55 =G= HH c-oice 55 ==) loopmen" 5 false; else
{
printf(47a4);
co"t<<4please c-oose eit-er 3 , + , A , or ==4 <<endl; getc-e();
0
0-ile (loopmen"); ret"rn tr"e;
0
The since the &mployee class methods are inherited into +dmin class the gui'enu() method of &mployee class is overridden with the gui'enu() method in the +dmin class.
first need to download it.
*for &mployee class constructors Employee::Employee( $oid){ empID 5 4>4; name 5 4>4; IC 5 4>4; gender 5 4>4; designation 5 4>4; department 5 4>4; dateJoined 5 4>4; DO 5 4>4; nationality 5 4>4; religion 5 4>4; maritial!tat"s 5 4>4; 0
Employee::Employee(string empID3, string name3, string IC3, string gender3, string designation3, string department3, string dateJoined3, string DO3, string nationality3, string religion3, string maritial!tat"s3){
empID 5 empID3; name 5 name3; IC 5 IC3; gender 5 gender3; designation 5 designation3; department 5 department3; dateJoined 5 dateJoined3; DO 5 DO3; nationality 5 nationality3; religion 5 religion3; maritial!tat"s 5 maritial!tat"s3; 0
rom the example above we can see the constructors are for the same &mployee 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
'alidation
(ender )eld validation
%%*KID*E /E.DE IEKD#ool $alidateL(c-ar c-ec9){ sitc- (c-ec9){ case == : case =f= : case =m= : case == :{ ret"rn tr"e; 0 defa"lt : {
co"t<<47nplease c-oose eit-er == or ==4 <<endl; ret"rn false;
0 0
0
Simple coices validation
%%*KID*E !I8KE C'OICE#ool $alidate!C(c-ar c-oice){ sitc- (c-oice){ case =3=: case =+=:{ ret"rn tr"e; 0 defa"lt :{
co"t<<4please c-oose eit-er =3= or =+=4 <<endl; ret"rn false;
0 0
0
'alidate Designation Entry
%%*KID*E DE!I/.*IO. E.M#ool $alidateDes(c-ar c-oice?@){ int i 5 2;
dy!tring a 5 .NKK;
-ile(c-oice?i@ 65 =72=){
if(c-oice?i@ F B HH c-oice?i@ < P){
co"t<<4please enter only n"m#ers4 <<endl; ret"rn false; 0 i; 0 i 5 2; a 5 readDes();
first need to download it.
if(atoi(c-oice)F i){
co"t<<4c-oose n"m#ers smaller t-en 4 <<i<<endl; ret"rn false;
0
ret"rn tr"e; 0
'alidate Department Entry
%%*KID*E DE8*E. E.M#ool $alidateDep(c-ar c-oice?@){ int i 5 2;
dy!tring a 5 .NKK;
-ile(c-oice?i@ 65 =72=){
if(c-oice?i@ F B HH c-oice?i@ < P){
co"t<<4please enter only n"m#ers4 <<endl; ret"rn false; 0 i; 0 i 5 2; a 5 readDep(); -ile(a 65 .NKK){ a 5 a>FneGt; i; 0 if(atoi(c-oice)F i){
co"t<<4c-oose n"m#ers smaller t-en 4 <<i<<endl; ret"rn false; 0 ret"rn tr"e; 0
'alidate IC )eld
%%*KID*E IC IEKD #ool $alidateIC(c-ar ic?@){ string c-ec9IC 5 ic; int i 5 2;#ool c-ec9 5 tr"e;
if(strlen(ic) F 3+ HH strlen(ic) < 3+){
co"t<<4yo"r IC n"m#er m"st #e eGactly 3+ c-aracters long it- no space or apl-a#ets4<<endl;
c-ec9 5 false; 0
-ile(ic?i@ 65 =72=){
if(ic?i@ F B HH ic?i@ < P){
co"t<<4please enter only n"m#ers4 <<endl; ret"rn false; 0 i; 0 ret"rn c-ec9; 1
'alidate Date )elds
%%*KID*E D*E IEKD!#ool $alidateDate(c-ar date?@){ #ool c-ec9 5 tr"e;
int i 5 2;
if(strlen(date) F 32 HH strlen(date) < 32){
co"t<<4please follo 74DD%%MMMM74 format4 <<endl; c-ec9 5 false;
0
-ile(date?i@ 65 =72=){
if(6(date?i@ <5 BP && date?i@ F5 )){
co"t<<4please enter only n"m#ers or =%=4 <<endl; ret"rn false; 0 i; 0 ret"rn c-ec9; 0
'alidate searc select
%%*KID*E !E*C' !EKEC#ool $alidateKast.ode(int leng-t, string c-oice) {
#ool c-ec9 5 false;
if(atoi(c-oice1cLstr()) <5 leng-t && atoi(c-oice1cLstr()) F 2)c-ec9 5 tr"e;
else c-ec9 5 false; ret"rn c-ec9;
0
first need to download it.
*est Plan
'alidation
"omponent "riteria &xpected result +ctual result
0alidate gender field 11 f 11 ' 11 m %eturn true %eturn true
&lse isplay error
2please choose either 3’ or 3'’. %eturn false isplay error 2please choose either 3’ or 3'’. %eturn false 0alidate esignation field
&nter numbers only and must be a valid
designation
%eturn true %eturn true
If not a number isplay error 2please enter only numbers.
%eturn false
isplay error 2please enter only numbers.
%eturn false If not a valid designation isplay error
2"hoose numbers smaller then 5last designation number6. %eturn false
isplay error 2"hoose numbers smaller then 5last designation number6. %eturn false
21
0alidate epartment field
&nter numbers only and must be a valid
department
%eturn true %eturn true
If not a number isplay error 2please enter only numbers.
%eturn false
isplay error 2please enter only numbers.
%eturn false If not a valid department isplay error
2"hoose numbers smaller then 5last department
number6. %eturn false
isplay error 2"hoose numbers smaller then 5last department
number6. %eturn false 0alidate I" field -tring length 7 89 and is
numbers only
%eturn true %eturn true
-tring length below 89 or above 89
isplay error 2your I" number must be exactly 89 characters long with no space or alphabets. %eturn false isplay error 2your I" number must be exactly 89 characters long with no space or alphabets. %eturn false :ot numbers only isplay error
2please enter only numbers.
%eturn false
isplay error 2please enter only numbers.
%eturn false 0alidate date fields -tring length 7 8; and is
number or 3<’
%eturn true %eturn true
-tring length is not 8; isplay error 2please follow 2<''<====
isplay error 2please follow 2<''<==== first need to download it.
If not number or 3<’ isplay error 2please enter only numbers or <
isplay error 2please enter only numbers or < 0alidate search select If choice is within search
list numbers
%eturn true %eturn true
If choice not within search list numbers
%eturn false %eturn false
2#
System #eliability
"omponent "riteria &xpected result +ctual result >ogin >ogin with admin
account.
isplays admin menu.
isplays admin menu.
>ogin with human resource staff account.
isplays human resource staff menu. isplays human resource staff menu.
>ogin with normal staff account.
isplays staff details.
isplays staff details.
0iew details ?ser select 2my account
isplay user’s details.
isplay user’s details.
?ser search for a staff and select staff from the search result.
isplay the staff’s details.
isplay the staff’s details.
&dit details ?ser select 2&dit to edit details
!rompt for field to edit, store changes and display edited field in user
details
!rompt for field to edit, store changes and display edited field in user
details. elete staff ?ser search for a staff
and select 2elete from search result choice menu.
%emoves the staff account and re* display the new search results
%emoves the staff account and re* display the new search results -earch staff ?ser select 2-earch !rompt for user
search string, then display search result, prompt for user search hit staff choice
!rompt for user search string, then display search result, prompt for user search hit staff choice %egister new account ?ser select 2%egister
:ew &mployee
!rompt for fields entry, validate entry, create new employee I and display, store new employee, display
!rompt for fields entry, validate entry, create new employee I and display, store new employee, display first need to download it.
2(
Program sample outputs
$ogin screen
Admin +enu
first need to download it.
,ormal sta +enu
27
'ie. Details
#egister ne. account
first need to download it.
Searc Prompt
2
Searc #esult
first need to download it.Additional /eatures
Add Designation and speci!y designation0s access outside
program
The designation can be specified in the designation.txt file and the designation’s access can be specify 8,9 or @ in front of the designation name without space and each 8, 9 and @ represents the +dmin account access, $% account access and :ormal staff account access.
Add Departments outside program
The department can be specified in the department.txt file each line in the file represents a department.
+ulti /ield Searc
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 optimiAed by proper separation between the fields and proper formatting of the fields.
#1
Conclusion
Through out the assignment I have realiAed that even though "## is not as modern as Bava but "## has the ability to create large and complex systems due to the fact that it is an object oriented programming language. "## also has certain features other programming languages don’t have like pointers and operator overloading, these features have proved to be very useful over course of the assignment’s program development. I believe "## could be better if its library functions are more well developed like Bava’s +!I. ue to current growth of internet technologies I believe that "## as the most demanded programming language is soon to change, even so the use of "## to create a system has made me more knowledgeable on the field of software development
first need to download it.