Programming Concepts in C++ [Group Assignment]
Acknowledgement
We take this opportunity to express our gratitude to all the people who helped us to
accomplish this project. We owe our deepest gratitude and sincere thanks go to our
respected professor Ms Nazura and our head of the IT department Ms. Vishnupriya
Raghavan. This project would not have been completed without their valuable support and
guidance and motivation throughout the course.
In this opportunity we would also like to thank our institute, Bangalore Management
Academy (BMA), for providing us with all the required laboratory and library facilities for all
our references and for creating a very friendly atmosphere which as a whole helped us to
achieve our goal.
Asia Pacific University College of Technology and Innovation – Level 2 1
Programming Concepts in C++ [Group Assignment]
Table of contents
Acknowledgment_______________________________________________01
Introduction___________________________________________________03
Application C++________________________________________________04
Staff Personnel System__________________________________________06
Implementation________________________________________________08
OOPs concepts_________________________________________________08
Inheritance____________________________________________________09
Encapsulation__________________________________________________10
Class diagram__________________________________________________10
Test Strategies_________________________________________________13
Validations____________________________________________________15
Screens_______________________________________________________16
Conclusion____________________________________________________21
Bibliography___________________________________________________22
Asia Pacific University College of Technology and Innovation – Level 2 2
Programming Concepts in C++ [Group Assignment]
Introduction
C++ Language was developed by Bjarne Stroustrup at AT&T Bell Laboratories in early
1980’s. But C++ language is still used by software developers or programmers for
developing software applications, device drivers for electronic hardware. The reasons behind
this are the powerful features of C++ like the Object Oriented Features allows developers or
programmers to build bigger programs with extensibility, simplicity and ease of maintenance.
C++ is a superset of C Language where important features that add to C Language are
classes, inheritance, function overloading and operator overloading. These features help in
creation of abstract data types, inherit properties from existing data types and also by
supporting polymorphism makes C++ fully Object Oriented Language.
Asia Pacific University College of Technology and Innovation – Level 2 3
Programming Concepts in C++ [Group Assignment]
Applications of C++
C++ is a versatile language for handling very large programs. It is suitable for virtually any
programming task including development of editors, compilers, databases, communication
system and any complex real-life application systems.
Since C++ allows us to create hierarchy-related objects, we can build special object-
oriented libraries which can be used later by many programmers.
While C++ is able to map the real world problem properly, the C part of C++ gives
the language the ability to get close to the machine-level details.
C++ programs are easily maintainable and expandable. When a new features needs to
be implemented, it is very easy to add to the existing structure of an object.
It is expected that C++ will replace C as general purpose language in near future.
Asia Pacific University College of Technology and Innovation – Level 2 4
Programming Concepts in C++ [Group Assignment]
Benefits of OOPs
Object Oriented Programming offers several benefits to both the programmer and the user.
Object Orientation helps in the development and quality of software products. The new
technology promises greater programmer productivity, better quality of software and lesser
maintenance cost. The principle advantages are:
Inheritance helps to eliminate redundant code and extend the use of existing classes.
Less development time and higher productivity.
Data hiding principle helps the programmer to build secure programs.
It is possible to have multiple instances of an object to co-exist without any inference.
New Data and functions can be easily added whenever necessary.
It is easy to partition the work in a project based on objects.
Software complexity can be easily managed.
Asia Pacific University College of Technology and Innovation – Level 2 5
Programming Concepts in C++ [Group Assignment]
Staff Personnel System
We have developed a Win32 console application to store, search, edit and view personnel
information of the staff in the company based on different access priority as mentioned in the
project. This application will be used by the Administrator, Human Resource personnel, and
the staff. The main purpose of this application is to store and edit the complete personal
record of each staff in the company. In addition as evidence of our project we have included,
a document to reflect the design of the implementation codes and the implementation details
that utilises the OOP concepts.
Objective
The main objective is to develop the practical ability to describe, to justify and implement an
object oriented system. The main purpose of this application is to store and edit the complete
personal record of each staff in the company.
Description and Justification
The Staff personnel management system is used to manage staff in an organisation where
different staff has different user levels to use the system. The scope of this system is that
we have three major levels of staff that is the normal staff, human resource and
Administrator. Each staff has a different permission level and actions they can perform.
The Staff can perform the following activities, where the priority of access is low
View personal details
Login / logout
Exit System
The Human resource Staff can perform the ones listed below
Exit System
Login / logout
Add Staff
View staff
Asia Pacific University College of Technology and Innovation – Level 2 6
Programming Concepts in C++ [Group Assignment]
Edit Staff
Search Staff
The Administrator have the highest level of authority in the system, amongst the activities the
administrative can perform are listed below:
Exit System
Login /logout
Add Staff and Human Resource Staff
View Staff and Human Resource Staff
Edit Staff and Human Resource Staff
Search Staff and Human Resource Staff
Asia Pacific University College of Technology and Innovation – Level 2 7
Programming Concepts in C++ [Group Assignment]
IMPLEMENTATION
Object Oriented Programming Concepts used:
A Class binds the data and its associated functions together. It allows the data and function to
be hidden, if necessary, from external use. Class has two parts:
1.) Class declaration describes the type and scope of its members.
2.) Class function describes how the class functions are implemented.
class Menus
{
private :
char choice;
char name[30];
char icNum[3];
char sName[30];
char gender[10];
char maritalstatus[20];
char nationality[20];
char department[20];
char designation[20];
char joinDate[10];
char sPassword[10];
char key;
public :
void mainmenu();///////////////////////Main Menu
void managesdata();////////////////////Manage Module
void searchModule();///////////////////Search Module
void linModule();//////////////////////Log In Module
void loutModule();/////////////////////Log out Module
Asia Pacific University College of Technology and Innovation – Level 2 8
Programming Concepts in C++ [Group Assignment]
void exitModule();/////////////////////Exit Module
void addStaff();///////////////////////Add Staff Module
void updateStaff();////////////////////Update Module
void getStaff();
void putStaff();
};
Inheritance
Inheritance is the process by which objects of one class acquire the properties of objects of
another class. It supports the concept of hierarchical classification. The principle behind this
sort of division is that each derived class shares common characteristics with the class from
which it is derived. Here in OOP, the concept provides the idea of reusability of code, so the
programmer or the user doesn’t have to write the same code repeatedly.
Inheritance involves subclasses and super classes. Subclasses are more specialized
versions of a class, which inherit attributes and behaviors from their parent classes, and can
introduce their own. Each subclass can alter its inherited traits.
class HumanResource : public Menus
{
public :
void hrmain();
};
class OStaff : public Menus
{
public:
void stfmain();
};
Asia Pacific University College of Technology and Innovation – Level 2 9
Programming Concepts in C++ [Group Assignment]
Encapsulation
The wrapping up of data and functions into a single unit is known as encapsulation. Data
encapsulation is the most striking feature of the class. The data is not accessible to the outside
world, only the functions wrapped in the class can access it. These provide the interface
between the object’s data and the program. This insulation of the data from direct access by
the program is called data hiding or information hiding.
void Menus::getStaff()
{
system("cls");
char gSchoice,gDchoice;
Menus gStaff;
cout<<"Add Staff"<<"\n";
cout<<"========="<<"\n";
cout<<"Staff Name__________: "; cin>>name;
cout<<"IC_Number___________: "; cin>>icNum;
cout<<"Gender______________: "; cin>>gender;
cout<<"Marritial Status____: "; cin>>maritalstatus;
cout<<"Nationality_________: "; cin>>nationality;
cout<<"\nSelect Department"<<"\n";
cout<<"+++++++++++++++++"<<"\n";
cout<<"1. IT "<<"\n";
cout<<"2. HR "<<"\n";
cout<<"3. Finance "<<"\n";
cout<<"4. Other "<<"\n\n";
cout<<"Enter your choice :";
cin>>gSchoice;
if(gSchoice=='1')
Asia Pacific University College of Technology and Innovation – Level 2 10
Programming Concepts in C++ [Group Assignment]
{
strcpy_s(department,"IT");
}
else if(gSchoice=='2')
{
strcpy_s(department,"HR");
}
else if(gSchoice=='3')
{
strcpy_s(department,"Finance");
}
else if(gSchoice=='4')
{
strcpy_s(department,"Other");
}
else
{
cout<<"error";
gStaff.addStaff();
}
Asia Pacific University College of Technology and Innovation – Level 2 11
Programming Concepts in C++ [Group Assignment]
Class Diagram
Asia Pacific University College of Technology and Innovation – Level 2 12
Programming Concepts in C++ [Group Assignment]
Test Strategies
TEST OPTION DESCRIPTIONEXPECTED
RESULTS
ACTUAL
RESULT
Login
Invalid username
and password.Access denied. As expected
Valid username and
passwordEnters to the System As expected
Administrator
Invalid inputSystem stays in the
same pageAs expected
Enter 1 for Manage
Staff Data
Enters to a menu for
adding, searching
and updating of staff
data
As expected
Enter 2 to LogoutLogs out to the login
pageAs expected
Enter 3 to ExitExits the system
with a confirmationAs expected
Manage Staff Data
(HR and
Administrator)
Invalid inputSystem stays in the
same pageAs expected
Enter 1 add staff
Displays a menu
where staff data is
entered with
different details
As expected
Enter 2 to Search Enters another menu
where a particular
staff data is viewed
and can be edited or
all staff data can be
As expected
Asia Pacific University College of Technology and Innovation – Level 2 13
Programming Concepts in C++ [Group Assignment]
viewed
Enter 3 to Go backGo back to the
previous menuAs expected
Search and Update
Staff Data()
Invalid inputSystem stays in the
same pageAs expected
Enter 1 to search
staff by name,
IC_Number,
Gender,
Designation,
Department etc
Display Staff Files
according to the
search selected
As expected
Enter 2 to search
whole staff data and
update if needed
Display all staff files
which is storedAs expected
Enter 3 to go backGo back to the
previous menuAs expected
Validations
Asia Pacific University College of Technology and Innovation – Level 2 14
Programming Concepts in C++ [Group Assignment]
Validation of password
if(strcmp (sName,"admin") == 0){
if(password==sPassword /*&& strcmp (name,sName) == 0*/){
cout<<"admin inside now\n";Menus::mainmenu();
}else{
cout<<"Incorrect Password";Menus::linModule();
}}
Validation of Search
fstream Myfile;Myfile.open ("Staff_Dat.txt",ios::in|ios::out);
while(!Myfile.eof()){
getline(Myfile,line);
while((offset = line.find(search,offset)) != string::npos) {
int g=Myfile.tellp();Myfile.seekg(offset-1);//name
Myfile.read((char *)&SA_Data, sizeof SA_Data);
SA_Data.putStaff();
offset = offset++;}
}
Myfile.close();
SCREENS
Asia Pacific University College of Technology and Innovation – Level 2 15
Programming Concepts in C++ [Group Assignment]
Add Data
Confirm Exit
Main menu
Asia Pacific University College of Technology and Innovation – Level 2 16
Programming Concepts in C++ [Group Assignment]
Main Screen 1
Manage Staff
Asia Pacific University College of Technology and Innovation – Level 2 17
Programming Concepts in C++ [Group Assignment]
Search By Name
Search by Main
Asia Pacific University College of Technology and Innovation – Level 2 18
Programming Concepts in C++ [Group Assignment]
Update Data
Updated Data
Asia Pacific University College of Technology and Innovation – Level 2 19
Programming Concepts in C++ [Group Assignment]
User Name Password
Conclusion
Asia Pacific University College of Technology and Innovation – Level 2 20
Programming Concepts in C++ [Group Assignment]
Software technology has evolved through a series of phases during the last five decades. Object Oriented Programming was invented to overcome the drawbacks of Procedure Oriented Programming.
Staff Personnel System development has helped us to learn about various aspects of OOP concepts in C++. Throughout this project we have gained a broad horizon of knowledge about the process of developing, designing and implementing a system through C++. The project as a whole has helped us build our knowledge in all the stages, procedures and rules involved developing the system.
Asia Pacific University College of Technology and Innovation – Level 2 21
Programming Concepts in C++ [Group Assignment]
Bibliography
Book
Balagurusamy 4rd Edition, 2010, Object oriented programming with C++ Tata McGraw Hill
India .
Online
C++ - OOPs Concepts ,http://www.cplusplus.com/doc/tutorial/[accessed on 06th March 2011]
Asia Pacific University College of Technology and Innovation – Level 2 22