Você está na página 1de 32

Further Programming Concepts in C++ (CE00314-2-FPCOP)

Contents
1. Introduction...............................................................................................................................3
1.1 Project Overview.........................................................................................................................3
1.2 Objective of the project................................................................................................................3
1.3 List of presumed assumptions......................................................................................................4
1.4 Scope of the project.....................................................................................................................4
2. Description and justification of the design of the implementation codes...................................5
2.1 System Features...........................................................................................................................5
2.2 User Privileges.............................................................................................................................5
2.3 Design (Logical Design) and Justifications.................................................................................7
2.3.1 Use Case diagram.....................................................................................................................7
2.3.2 Hierarchical chart for proposed system.....................................................................................8
2.3.3 Class Diagram.........................................................................................................................11
3. Description and Justification of Implementation codes in terms of the OOP Concept.............13
3.1 Class and Objects.......................................................................................................................13
3.2 Data Abstraction and Encapsulation..........................................................................................15
3.3 Inheritance.................................................................................................................................17
3.4 Polymorphism............................................................................................................................19
3.4.1 Operator overloading and method overloading.......................................................................19
3.4.2 Method Overloading...............................................................................................................19
3.4.3 Parametric overloading and generacity...................................................................................21
4. Description and justification of the validation codes applied into the implementation codes. .22
4.1 Validations for the menu selections...........................................................................................22
4.2 Validation for file operations.....................................................................................................23
5. Testing and Test Plans.............................................................................................................24
5.1 Features to be tested...................................................................................................................24
5.2 Test plan for Login Module.......................................................................................................24
5.3 Test plan for Main Menu Selection............................................................................................25
5.4 Test plan for Academic Staff Management................................................................................26
5.5 Test plan for Module Management – Assign Lecturer..............................................................27
5.6 Test plan for Marks Management – View Marks.......................................................................27
5.7 Test plan for File Handling........................................................................................................28
6. Critical Evaluation...................................................................................................................29
7. Reference.................................................................................................................................30
Reference
1
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

1.

2
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

List of Tables
Table 2.1 User Privileges ……………………………………………………………………..6
Table 2.2 File Structure ……………………………………………………………………….9
Table 5.1 Test plan for Login Module ………………………………………………………24
Table 5.2 Test plan for Menu Module ……………………………………………………….24
Table 5.3 Test plan for Academic Staff Menu ………………………………………………25
Table 5.4 Test plan for Academic Staff Module …………………………………………….26
Table 5.5 Test plan for Module Management ……………………………………………….26
Table 5.6 Test plan for Marks management …………………………………………………26
Table 5.7 Test plan for File Handling ……………………………………………………….28

3
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

List of Figures
Figure 2.1 Case diagram
……………………………………………………………………………………………………………
………7
Figure 2.2 Privileges diagram
……………………………………………………………………………………………………………
.8
Figure 2.3 Class Diagram
……………………………………………………………………………………………………………
……10
Figure 3.1 Inheritance
……………………………………………………………………………………………………………
………..16

4
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

List of Abbreviations

C++ C plus plus

SDLC System Development Life Cycle

OO Object Oriented

OOP Object Oriented Programming

UML Unified Modeling Language

5
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

1. Introduction

1.1 Project Overview

Manage and keep data of an organisation is one of the most important task. Different
organisations or individuals use different approaches to fulfil that. Security of the data,
efficiency of the system and reliability of the system are the most essential and important
factors of an information management system. Because of it, it is possible to expand,
processing and handling capacity of organisation.

Handling data of an organisation using manual system can be risk sensitive data of the
organisation because that there can be a leak of the information and it is very difficult to
identify where is the system compromise .Also reliability and efficacy of the system depend
on it is human resources. Apart form that backup or clone data and keep them safely can be
difficult because of its manual format.

To prevent and minimize above risks and gain advantage of technology it is suggest to use
computerized information management system. SMS (Student Management system) is
windows based console application which allows manage, store and edit complete personal
records and examinations results of each student in a university.

As required by assignment, Object Oriented Concept and OO designing pattern have applied
with this solution. Apart form that, files use as data storing media and following features have
included with the final application
• Advanced login with authenticate system for selected user
categories
• User management
• Module management
• Advanced search facility
• Marks management

Microsoft Visual Studio Team System 2008 and Dot net framework 3.5 have used as main
developing and testing platform of this application. Microsoft Visual C++ 6.0 has used as a
secondary developing and testing tools. UML has used as modelling method of this
application.

1.2 Objective of the project

The main objective of the project is providing a complete solution for handle records of
students in a university by using OOP concept and OOP patterns. Main objective can be
dividing into further as shown in below.

• Provide essential security and privileges to data of the system and its
users
• Provide capability to handle records of the system
• Provide reporting capability up to some extends

6
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

• By providing above facilities, increase efficiency , security and


reliability of the system

1.3 List of presumed assumptions

To make more meaningful, feasible and easy of design and develop, following assumptions
have made and narrow the scope of the application.

1. The system will only use four type of users


2. No of records to be saved in the system is limited
3. Lecturer is assigned to only one module and it is not necessary to trackback previous
assignment details
4. Student only allows to take 3 modules per semester and it is not necessary to
trackback previous assignment details
5. Batch code of a student will change in every semester
6. The system admin will change module assignment of lecturers and enrolments of
students when it required
7. The organisation has enough capability to run and process huge no of files and size of
the application and its component does not matter

1.4 Scope of the project

The scope of the project is developing win32 console application which provides record
handling capability of a university. System will enable to system administrators,
Administrative staff, academic staff and students to view, enter, modify and delete records
based on given privileges.

7
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

1. Description and justification of the design of the


implementation codes

2.1 System Features

The following modules can be identify as key features of a computer system,

1. User login
2. User management
• User registration
• User modification
• User deletion
1. Module Management
• Module registration
• Module modifications
• Module deletions
• Assign lecturers
• Assign student for modules
1. Marks
• Entering marks
• Modifying marks
1. Search

Privileges on above features can be varying based on the user type .The following diagram
shows users and their privileges

2.2 User Privileges

Privileges Admin Administrative Academic Student


Staff Staff
User Management
Student Management 
Add 
View   
Modify 
Delete 
Academic Staff Management 
Add 
View 
Modify 
Delete 
8
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

Administrative Staff Management 


Add 
View 
Modify 
Delete 
Module Management
Add 
View    
Modify 
Delete 
Assign lecturers 

Assign student for modules 

Marks

Add  (Related
)
View   (Related) 
Modify  (Related
)
Search  (Related) (Related (Related)
)

Table 2.1 User Privileges

9
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

2.3 Design (Logical Design) and Justifications

UML (Unified Modelling Language) has been used as analysing and design tool of this
project. This artefact has developed based on object oriented concept.

2.3.1 Use Case diagram


Following use case diagram shows interaction between users (students, system admin,
academic staff and administrative staff) and functions of the current system which is
mentioned in case study.
This system include 4 actors who inherited from one common actor “User”

System

Add New User


«inherits»
User «inherits»

«inherits»

«inherits»

Add New Module


Acadamic Staff Member

AdminstrativeStaff Member
Login
Student AcadamicStaff Member Admin

Modify Module
System Admin

Modify Users

Student

Add New Mark

Modify Marks
Adminstrative Staff Member

View User

Acadamic Staff Member


Search

View Marks

System Admin

View Module
Student

Figure 2.1 Case diagram


10
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

The reason for having four user type inherited form one user is, it is possible to identify some
common characteristics between 4 actors. So it is make more sense to generalize user actor in
to other 4 user types.

The following diagram shows common privileges of four user type.


Figure 2.2 Privileges diagram

2.3.2 Hierarchical chart for proposed system

As mentioned before system admin has full privileges and other users have limited privileges.
In the proposed system different privileges have implemented by restricting menu access for
different user levels.

The following table shows attributes of the user types, modules, enrolments and marks

User Marks Module Enrolments


Admin Academ Administra St
ic Staff tive Staff ud
Member Member en
t

userid : String Markid : String id: String Id:String


Statues : String studentid:String code: String Moduleid :
String
Userpassword : String moduleid: String name: String Studentid:Strin
g
Fname : String Lecid : String duration: BatchCode:Stri
String ng

mname: String Batchcode : cordinator:


String String
lname: String Marktype : validility:
String String
nidno: String Attempt :
Integer
gender: String Mark : Float
dateofbirth: String
datejoined: String
nationality: String
addressLine1: String
addressLine2: String
city: String
postalno: String
11
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

country: String
telephone: String
mob: String
email: String
Admin Ac A Student
ad d
em m
ic in
St ist
aff ra
M ti
em ve
be St
r af
f
M
e
m
be
r
Dateretired String Batch String

Table 2.2 File Structure

12
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

2.3.3 Class Diagram

User
#userid : string
#statues : string
#userpassword : string
#fname : string
#mname : string
#lname : string
#nidno : string
#gender : string
#dateofbirth : string
#datejoined : string
#nationality : string
#addressLine 1 : string
#addressLine 2 : string
#city : string
#postalno : string
#country : string
#telephone : string
#telephone : string
#mob : string
#email : string
+login() : void
+logout () : void
+search () : void
*
Student +genarateID() : string AdministrativeStaff
-batch : string +view() : void -dateHired : string
-imodule : Module +loadMainMenu () : void -file : FileHandler
+ShowCommandConsole () : void -controller : UserHandler
+viewMarks (in Parameter 1) : void
+viewModule (in Parameter 1 : string) : void +viewMarks (in studentid : string , in moduleid : string , in attemp : int) : void
+enroll (in id : int, in imodule : Module ) : void +viewModule (in moduleid : string ) : void
*
*

* * -End3
Admin
-controller : UserHandler
-file : FileHandler
-dsteRetired : string
+RegisterNew (in Parameter 1 : Student ) : void
+RegisterNew (in Parameter 1 : AdministrativeStaff ) : void
*
+RegisterNew (in Parameter 1 : AcadamicStaff ) : void
+viewUser (in Parameter 1 : Student, in Id : int) : void
Enrolment +viewUser (in Parameter 1 : AcadamicStaff , in Id : int ) : void
+viewUser (in Parameter 1 : AdministrativeStaff , in Id : int) : void
-ID : string +deleteUser (in Parameter 1 : Student , in Id : int) : void
-ModuleID : string +deleteUser (in Parameter 1 : AcadamicStaff , in Id : int) : void
-StudentID : string +deleteUser (in Parameter 1 : AdministrativeStaff , in Id : int ) : void
-BatchCode : string +editUser (in Parameter 1 : Student, in Id : int ) : void
+GenarateID () : string +editUser (in Parameter 1 : AcadamicStaff , in Id : int ) : void
+editUser (in Parameter 1 : AdministrativeStaff , in Id : int ) : void
* +viewModule (in id : int, in imodule : Module ) : void
+viewMarks (in id : int) : void
+editMarks (in id : int) : void
+editModule (in id : int, in iModule : Module ) : void
+deleteMarks (in id : int) : void
+deleteModule (in id : int , in iModule : Module ) : void
+addMarks () : void
+addModule () : void

* * *

Module
-modID : string
-code : string
-cordinator : string
-duration : int
-name : string
-validility : string
+view () : void
+genarateID () : string

*
*
* * -End4

*
UserHandler
*
*
+registerNew (in iobject : AdministrativeStaff ) : void
* * +registerNew (in iobject : Student) : void FileHandler
* +registerNew (in iobject : AcadamicStaff ) : void
* +delete (in id : int , in istudent : Student ) : void +view (in id : int, in istudent : Student ) : void
MarkModuleHandler +delete (in id : int , in iobject : AdministrativeStaff ) : void +view (in id : int, in iobject : AdministrativeStaff ) : void
+delete (in id : int , in iobject : AcadamicStaff ) : void +view (in id : int, in iobject : AcadamicStaff ) : void
+studentSearch (in searchCatogory : char ) +view (in id : int, in iobject : Module ) : void
+view (in id : string , in iobject : Module ) : void +AcadamicSearch (in searchCatogory : char ) +view (in id : int, in iobject : Marks) : void
+enterNew (in iobject : Module ) : void +AdminSeach () +write(in id : int, in iobject : Marks) : void
+edit(in id : int , in iobject : Module ) : void +ModuleSearch () +write(in id : int, in iobject : Module ) : void
+delete (in id : string, in iobject : Module ) : void +MarkSearch () +write(in id : int, in iobject : AcadamicStaff ) : void
+enterNew (in iobject : Marks) : void +write(in id : int, in iobject : AdministrativeStaff ) : void
+view (in id : string , in modid : string, in userid : string, in atemp : int) : void * +write(in id : int, in istudent : Student) : void
+edit(in id : string , in modid : string, in userid : string, in atemp : int) : void +rewrite(in id : int, in istudent : Student ) : void
+delete (in id : string, in *modid : string , in userid : string , in atemp : int) : void * * +rewrite(in id : int, in iobject : AdministrativeStaff ) : void
*
+rewrite(in id : int, in iobject : AcadamicStaff ) : void
+rewrite(in id : int, in iobject : Module ) : void
* AcadamicStaff
* +rewrite(in id : int, in iobject : Marks ) : void
-dateHired : string +delete (in id : int, in istudent : Student ) : void
-file : FileHandler +delete (in id : int, in iobject : AdministrativeStaff ) : void
Marks -ui : Grapix +delete (in id : int, in iobject : AcadamicStaff ) : void
-userid : string -controller : UserHandler +delete (in id : int, in iobject : Module ) : void
-moduleid : string +viewMarks (in studentid : string, in moduleid : string , in attemp : int) : void +delete (in id : int, in iobject : Marks) : void
-atempt : int +viewModule (in moduleid : string ) : void +getFileSize (in id : int , in istudent : Student ) : double
-mark : double +AddMarks (in studentid : string , in moduleid : string , in attemp : int) : void +getFileSize (in id : int , in iobject : AdministrativeStaff ) : double
+setMark (in imoduleid : string, in iattempt : int, in imark : double ) : void +EditMarks (in studentid : string , in moduleid : string , in attemp : int) : void +getFileSize (in id : int , in iobject : AcadamicStaff ) : double
+getMarks () : double +getFileSize (in id : int , in iobject : Module ) : double
+getFileSize (in id : int , in iobject : Marks) : double

Figure 2.3 Class Diagram

13
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

User, Student, “AcademicStaff”, “AdministrativeStaff”, Admin, Module, Marks, Enrolment


have identified as main classes of the case study, User handler, File handler, “MarkModule”
handler are the support classes which are facilitate to main classes to communicate with each
other and reduce the complexity of the relationships.

Student, academic staff, administrative staff and admin inherited form the user class which
have common characteristics of all 4 other users. “Userhandler” class manages above
mentioned four class’s interconnectivity with each others and “MarkModuleHandler” class
which has connected with module and marks classes performs same duty of “Userhandler”
class. The Student, “AcademicStaff”, “AdministrativeStaff” and admin classes access marks
and module via “MarkModuleHandler” .

Allowing direct access between Student,”AcadamicStaff” , “AdministrativeStaff” , Module ,


Marks and Enrolment classes without using “MarkModuleHanler” , “FileHandler” and
“UserHandler” classes cause to duplication of functions and attributes and reduce the
efficiency of the application by unnecessary usage of resources. By centralizing important
functions and call them when they required, is increase efficacy of the application and
makes more reliable solution.

Enrolment class keeps track on connections between module and student classes. By using
Enrolment class it allows to manage and keep track on students’ modules. Also because of
using enrolment class it allows to keep details of all existing modules which have followed
by a student in a given time duration and reduce unnecessary communications between
classes

Although there are lot of drawback of using file as a store media because of project
requirements, the data of the system is store in files which handle by “FileHandler” class. It
uses binary format to store. Above mentioned table 2.2 demonstrate attributes and type of the
data which store in the files. The reason for using binary format to encrypt the data because
of that it is possible to protect data from unauthorized access.

14
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

1. Description and Justification of Implementation codes in


terms of the OOP Concept

As mentioned by Balagurusamy(2008,p7) Object Oriented Programming is an approach that


“provides a way to modularizing programs by creating portioned memory area for both data
and functions” which mean OOP concept basically based on reusability of components He
also mentioned it by” that can be used as template for creating copies on demand” .
Modularising real word entitles to software components are also main part of the OOP.
Which mean all approaches of OOP based on real world cases.

Because of that it make easy to designer to map logical design with the real world objects and
understand the issues and correct them. Class is the basic atomic unit of the OOP.

3.1 Class and Objects

Class can be identified as most imported entity of OOP. In simple way class is the blueprint
of an object which mean it has all characteristics and properties which should have on
particular object. As mentioned by Microsoft Developer Network (2009) class describe the
structure of an object

As mentioned by Sun Developer Network Site (2009) object is an “instance” of a class.

This solution contains 11 different classes which have allocated for different purposes.

Students, Admin, “AdministrativeStaff”, “AcadamicStaff”, Module, Marks, “FileHandler”,


“UserHandler” , “MarkModuleHanler” can be identified classes of implemented solution.
The following sample codes shows implementation of a class taken in the solution.

class User{ // Start of the class definition


protected: // Member access specifiers only for derived classes
string userid,statues,userpassword,fname; // data member of the
class
public: // Member access specifiers
User();//Constructor
// define the methods user functions
void login();// login to the system
void logout(); // log out to the system
void search(); // search
string genarateID();
void veiwUser();
};//End of the class definition

This classes’ method can be implement separately before the initialization / creating an
object.

User::void login(){
// Implementation of codes}
15
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

Like this all class have declared except interface and abstract classes of the solution. When it
required to access method or data member of a class it creates an object and access them
using member access operator.

The following code shows how to create an object and access the data member or methods of
it

//Access members using dot operator

Student istudent;// create a object it takes default constructor


Istudent.setUserid(“std001”);//passing string as a argument and set student id

//Access members using -> operator

User *iuser; // create user pointer, Assumed that user is a base class and admin in
// derived class of user
Admin iadmin;
iuser=&iadmin;//Point iuser to iadmin object
iuser->login();//call login method of iadmin (Assumend login() is a virtual function)

Ideally using classes allow programmer to reuse classes as a blueprint and make objects in
different location of the application. And also it makes easy to programmer to manage code
and use them effectively. Because of using classes and objects it takes less time to trouble
shooting the application.

16
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

3.2 Data Abstraction and Encapsulation

Encapsulation and Abstraction are going together words in Object Oriented programming.
Abstraction is a one of the most important concept in OOP.

As mentioned by Baldwin (2008) “Abstraction is the definition of an abstract data type,


which includes the data type's representation and behaviour.” Which mean represent essential
and important details of a class without including the other unnecessary related information.
Abstract classes can not be initializing because it is a prototype. Inherited classes should be
use to access abstract classes’ method and data members. In C++, Classes which have at least
one pure virtual function can be identify as an abstract class. The classes which have only
pure virtual function can be identified as interfaces which called another form of an
abstraction.

In this solution there is one abstract class which can identified as an interface class. The
reason for making “User” class interface is, Student,”AcadamicStaff”,”AdministrativeStaff”
and Admin classes have very common characteristics which can be identified as essential
and important details of the four classes because of that it allows to share common features
between four classes.

The following codes which have extracted form the project shows the how abstract classes
have implemented

class User{ // Start of the class definition


protected: // Member access specifiers only for derived classes
string userid, statues, userpassword, fname, mname, lname, nidno,
gender,
dateofbirth,datejoined,nationality,addressLine1,addressLine2,city,posta
lno,country,tpres,mob,email;// data member of the class
public: // Member access specifiers
User();//Constructor
// define the methods user functions
virtual void login()=0;// No return object and no arguments
virtual void logout()=0;// No return object and no arguments
virtual void search()=0;// No return object and no arguments
virtual string genarateID()=0;// No return object and no arguments
virtual void veiwUser()=0;// No return object and no arguments
};//End of the class definition

Class “User” is a pure virtual class which mean it is an “interface” class, which have only
declarations of the methods but not implemented. Because of that it is not possible to create
an object from “User” class.

By creating inherited classes form the “User class” it is possible to access data members and
implement functions of the “User” and since it is using virtual functions it is possible to
access inherited classes method via a pointer of “User” Which can make code more dynamic
Following codes demonstrate how to access inherited classes’ methods via base class
methods. Class “Admin” has inherited form class “User”.
17
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

User *iuser; // create user pointer, Assumed that user is a base class and admin in
// derived class of user
Admin iadmin;
iuser=&iadmin;//Point iuser to iadmin object
iuser->login();//call login method of iadmin (Assumend login() is a virtual function)

Encapsulation can simply explain as “hiding data” According to Balagurusamy E (2008)


“Wrapping up data and related functions in to a single class” is the encapsulation he also
mentioned that make data members not accessible to outer world but accessible for functions
of the same class can be identified as “encapsulation”.

In this solution all data members of the classes access through functions which make data
members more secure by limiting access to outer world. Because of that the data of the class
can not change by using any other class for the reason that all data members are protected
and only accessible for method of the own classes, inherited classes and friend class and
functions.

class Marks// Start of the class definition


{
private : // Member access specifiers
string markid,studentid,moduleid,lecid,batchcode;
int attemp;
double mark;
public: // Member access specifiers
Marks(void);//Constructor
virtual ~Marks(void);//Destructors
string genarateID();
void view();
// Setter for set data
void setMarkid(string);// Set mark id
void setStudentid(string);// Set student ID
void setModuleid(string);// Set ModuleID
void setLecid(string);// Set LecturerID
void setbatchcode(string);//Set Batch Code
void setattemp(int);//Set Attempt
void setmark(double);// Set Marks
// Getters for fields
string getMarkid();// get mark id
string getStudentid();// get student ID
string getModuleid();// get ModuleID
string getLecid();// get LecturerID
string getbatchcode();//get Batch Code
int getAttemp();//get Attempt
double getmark();// get marks
bool operator ==(Marks);// Operator Overloading for comparison
};
All “getters” get methods take data fields which are only accessible for methods of the class
and return it to out. Set methods takes argument from out side of class and assign them to
data members of the class. Without using getters and setters of the class out world can not
access the data fields of the class.
18
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

3.3 Inheritance

As mentioned by Morin (2002) “Inheritance is the concept that when a class of object is
defined, any subclass that is defined can inherit the definitions of one or more general
classes.” Which mean derived class has same characteristics of base class. The idea of
inheritance is “Reusability” because derived class can access all data members (which
allowed to inherit by putting access specifiers, protected or public) and functions of the base
class. If it required, they can override it without changing base class attributes. Inheritance
can be categorized as multiple inheritance, single inheritance, hierarchical inheritance and
multilevel inheritance

This solution contains only one hierarchical inheritance. “Student”,”Admin”,”


AdministrativeStaff” and ” AcadamicStaff” classes inherit form the “User” class as shown
bellow.

User

Student Admin
AcadamicStaff AdministrativeStaff

Figure 3.1 Inheritance

“Student”,”Admin”,” AdministrativeStaff” and ” AcadamicStaff” classes have all data


methods and functions ( Characteristics) of user class because all classes have inherited in
publicly. Because of that it is possible to use methods and data members of the “User”
interface in derived classes after overriding them. Like this other classes can reuse members
of “User” without duplication of the code.

The following code shows the application of inheritance in solution.

Base Class

class User{ // Start of the class definition


protected: // Member access specifiers only for derived classes
string userid, statues, userpassword, fname, mname, lname, nidno,
gender,
dateofbirth,datejoined,nationality,addressLine1,addressLine2,city,posta
lno,country,tpres,mob,email;// data member of the class
public: // Member access specifiers
User();//Constructor
// define the methods user functions
19
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

virtual void login()=0;// No return object and no arguments


virtual void logout()=0;// No return object and no arguments
virtual void search()=0;// No return object and no arguments
virtual string genarateID()=0;// No return object and no arguments
virtual void veiwUser()=0;// No return object and no arguments
};//End of the class definition

Derived Class

class Student : public User //Start of the Student Class


{
private :
string batch;
public :
Student():User();//Constructor and invoking base class
// constructor
~Student();//Destructor
//set functions for attributes
void setUserid(string);//set user id
void setStatues(string);//set statues of the student
// Set Function Continue...........
// Get Varibles
string getUserid();//get user id
string getStatues();//get statues of the student
// Get fntion continue ...............
void login();//connect login module
void logout();//connect logout module
void loadMainMenu();//Load main menu
void enroll();//Set user enrolment
void search();//search
string genarateID();//Generate student id
void veiwUser();
void viewmodule();
void viewmarks();
bool operator ==(Student);// Operator Overloading
void showCommandConsole(string);
};//End of the student Class

By using inheritance it is possible to implement different type of users which inherited from
“User” class by doing minor modification to main class. It is added advantage of using OOP
concept in this project.

20
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

3.4 Polymorphism

Polymorphism (from the Greek, meaning "many forms") is the quality that allows one name
to be used for two or more related but technically different purposes.(Schildt,1998).There are
3 main categories of polymorphism

3.4.1 Operator overloading and method overloading

Operator Overloading

Known as overloading. Operator overloading is provide new meaning to existing operator


and provide ability to work with user defined types.

By using operator overloading it is allows to code more meaningful function and apply them
in effectively. Also it improves “reusability” of the code. Type casting can also take as a
operator overloading.

There are few operators overloading in this solution to improve application coders experience
more easily and manage the codes in efficient way. The following codes show applications of
an operator overloading in this application.

Overload “==” Operator


bool operator ==(Student istudent)// Operator Overloading for comparison
{
//Compare user input
if(fname.compare(istudent.getFname())==0 ||
getMname().compare(istudent.getMname())==0 ||
getLname().compare(istudent.getLname())==0)
return true;//If user inputs are matching return true
else
return false; //else user inputs are not matching false

}//End of the operator overloading function

3.4.2 Method Overloading

Method Overloading provides new meaning or change behaviour and characteristics of


functions which have same name. A method which defined in base class inherited to all
derived class and it works as defined in base class. Based on requirements the method in base
class can be override to give different functionality.

The following codes show Method overloading in the solution.

21
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

Method declaration of string genarateID() in User Class

class User{ // Start of the class definition

public: // Member access specifiers


User();//Constructor
// define the methods user functions
virtual string genarateID()=0;// No return object and no arguments
};//End of the class definition

Method Implementation of Student Class


string genarateID()//Start of the genrate ID method
{
string str;//Declare str string
fstream file; //stream for input AND output
//Open the file
file.open("Student.dat",ios::in|ios::out|ios::ate|ios::binary);
int last=file.tellg();//move to end of the file and get size
int loc=last/sizeof(Student);
//To Convert Int to string
stringstream out;
out <<"std"<<loc;
str = out.str();
return string(str);
}

Method Implementation of “AcadamicStaff” Class

string genarateID()//Start of the genrate ID method


{
string str;//Declare str string
fstream file; //stream for input AND output
//Open the file
file.open("AcadamicStaff.dat",ios::in|ios::out|ios::ate|ios::binary);
int last=file.tellg();//move to end of the file and get size
int loc=last/sizeof(AcadamicStaff);
//To Convert Int to string
stringstream out;
out <<"std"<<loc;
str = out.str();
return string(str);
}

It is appears to be both method are same but they access different files and use different
classes and different type of objects.

3.4.3 Parametric overloading and generacity

22
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

There are two way of applying polymorphism via parameters. Parametric overloading gives
ability to define number of methods in same class by changing there parameters and return
type of it.

The following codes shows use of parametric overloading in the solution.

//Taken form markModuleHandler.h


void edit(int id,Module &iobject)// To edit Module record of a file
{
//Continue …………………….

// To edit marks record form a file


void edit(int attempt,string modid,string stdid,Marks &iobject)
{

//Continue …………………….

Genetacity or parametric overloading allows to creates generic methods which are applicable
to range of objects using “Template” concept this can be achieve.

During the development of the solution different class used this concept to reduce
unnecessary codes and make more effective application.
// Taken in Admin.h

template<class Tclass>
void registerNew(Tclass &iobject)
{
controller.registerNew(iobject);// This is the methods
for create new user)
}

Using template functions reduce unnessory duplication of the coding.To register all four user
of the system takes four function but using templates it can be done only using one single
function.

23
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

2. Description and justification of the validation codes


applied into the implementation codes

It required validations to reduce unnecessary logical errors of the application. Due to limited
time frame only few validations were implemented.

4.1 Validations for the menu selections

Each and every selection menu of the application only accepts the limited character input
including both upper and lower case. If user input invalid character it is prompt an error
message and allow user to navigate away based on the menu and location of the application.

// Taken from Admin.h


void showCommandConsole(string loc)
{
//continue..............
if(loc.compare("mainmenu")==0)
{
switch (selection)
{
//Continue……….
default:
{
system("cls");
// To show invalid selection message
ui.showInvalidSelectionErrorMessage();
cout<<"\t\tType m in crusor for go main menu"<<endl;
char ch;
cin>>ch;
if(ch=='b'|ch=='B'){system("cls");}
else if(ch=='e'|ch=='E'){logout();}
else if(ch=='m'|ch=='M') {system("cls");
loadMainMenu();
}
}
}
}
}

24
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

4.2 Validation for file operations


File read out operations are most important and an often perform action in the solution. And
failure of the file operation might cause to runtime errors. Therefore as special requirement it
use validation and failure safely steps in this feature

// Taken form FileHandler.h

void write(string filename,Student &iobject)


{
try{
fstream file; //stream for input AND output
file.open("Student.dat",ios::in|ios::out|ios::ate|ios::binary);//open the file
int last=file.tellg();//get last memory location of the file
int n=last/sizeof(iobject); //get no of the objects in the file
file.seekp(last); //go to last location
file.write((char*)&iobject,sizeof(Student))<<flush; //write into file
cout<<"Student Record has succsesfuly registred"<<endl;
file.close();//close the file
}catch(...){
cout<<"\t\tFile Handlling Error Please contact system Admin"<<endl;
}

3.

25
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

4. Testing and Test Plans

Since all system use same source to call function it was checked all functions logged as an
admin except login. The login module checked by logged as all users.

5.1 Features to be tested

• Login for different user type


• Loading of correct selection menu and forms for user selection
• Storing and retrieving of data
• Run time error if any
The testing has done based on the modules of the system. The following modules have
identified to be tested.

• Login
• Main selection
• Student Management
• Academic Staff Management
• Administrative Staff Management
• Mark Module
• Module Management
• Search

5.2 Test plan for Login Module

Test Case Expected Result Actual Result

Logging as a admin

Login – correct Display Admin main screen


parameter
Login – wrong Display error message
parameter
Logging as a student
Login – correct Display student main screen
parameter
Login – wrong Display error message
parameter
Logging as a Administrative Staff Member
Login – correct Display administrative staff member
parameter main screen
Login – wrong Display error message
parameter
Logging as a Academic Staff Member
Login – correct Display academic staff main screen
26
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

parameter
Login – wrong Display error message
parameter

Table 5.1 Test plan for Login Module

5.3 Test plan for Main Menu Selection

Test Case Expected Result Actual Result

Admin Menu

Enter – correct Navigate to relevant module


parameter in both upper
and lower case
Enter – wrong Display error message and prompt user
parameter to option to navigate
Student Menu
Enter – correct Navigate to relevant module
parameter in both upper
and lower case
Enter – wrong Display error message and prompt user
parameter to option to navigate
Administrative Staff Menu
Enter – correct Navigate to relevant module
parameter in both upper
and lower case
Enter – wrong Display error message and prompt user
parameter to option to navigate
Academic Staff Menu
Enter – correct Navigate to relevant module
parameter in both upper
and lower case
Enter – wrong Display error message and prompt user
parameter to option to navigate

Table 5.2 Test plan for Menu Module

Since all user menus and functionalities same and call in same source it is use “Academic
Staff Management “module to tested other modules. But additional features of the other
modules which are not relevant to academic staff management module tested separately.

5.4 Test plan for Academic Staff Management

Academic Staff Management Menu

27
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

Test Case Expected Result Actual Result

Academic Staff Menu

Enter – correct Navigate to relevant module


parameter in both upper
and lower case
Enter – wrong Display error message and prompt user
parameter to option to navigate
Table 5.3 Test plan for Academic Staff Menu
Academic Staff Forms

Test Case Expected Result Actual Result

Add Academic Staff

Enter – details is fields Navigate to relevant module


View Academic Staff
Enter correct search Prompt message that it is available and
parameters in the show record and show navigation options
prompt at the end
Enter incorrect search Prompt message that it is incorrect and
parameters in the allow user to navigate
prompt
Edit Academic Staff
Enter correct search Prompt message that it is available and
parameters in the prompt user to edit, after editing ask user
prompt confirmation
Enter incorrect search Prompt message that record is not
parameters in the available and allow user to navigate
prompt
Accept confirmation Update record and show navigation
message option
Cancel confirmation Show navigation
Delete Academic Staff
Enter correct search Prompt message that it is available and
parameters in the editing ask user confirmation
prompt
Enter incorrect search Prompt message that record is not
parameters in the available and allow user to navigate
prompt
Accept confirmation Update(Delete) record and show
message navigation option
Cancel confirmation Show navigation
Assign Lecturer
Enter correct search Prompt message that it is available ,
parameters in the prompt user to assign lecturer and ask
prompt user confirmation
Enter incorrect search Prompt message that record is not
parameters in the available and allow user to navigate
28
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

prompt
Accept confirmation Update record and show navigation
message option
Cancel confirmation Show navigation

Table 5.4 Test plan for Academic Staff Module

5.5 Test plan for Module Management – Assign Lecturer

Assign Lecturer
Enter correct search Prompt message that it is available ,
parameters in the prompt user to assign lecturer
prompt
Enter required details ask user confirmation
to the fields
Enter incorrect search Prompt message that record is not
parameters in the available and allow user to navigate
prompt
Accept confirmation Update record and show navigation
message option
Cancel confirmation Show navigation
Table 5.5 Test plan for Module Management

5.6 Test plan for Marks Management – View Marks

Assign Lecturer
Enter correct search Prompt message that it is available ,
parameters in the prompt user to assign lecturer
prompt
Enter required details ask user confirmation
to the fields
Enter incorrect search Prompt message that record is not
parameters in the available and allow user to navigate
prompt
Accept confirmation Update record and show navigation
message option
Cancel confirmation Show navigation
Table 5.6 Test plan for Marks management
All menus of the application accept both upper and lower case letters as selections. When
user required to access not implemented or not required feature of the application it shows
error message and prompt user to navigate away.

Although some of file read write operations covered in previous test plans and because of all
operations used same source file and call them in different locations of the application, file
read write operation checked manually in selected cases. To check that add, view and
modification features were used.

29
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

5.7 Test plan for File Handling

Test Case Expected Result Actual Result


Student File - Student.dat
Add New Record Show successfully modified message and
increase file size
View Record View record according to given
parameters
Modify Record Prompt to correct record and update file
Academic Staff File - AcadamicStaff.dat
Add New Record Show successfully modified message and
increase file size
View Record View record according to given
parameters
Modify Record Prompt to correct record and update file
Administrative Staff File - AdministrativeStaff.dat
Add New Record Show successfully modified message and
increase file size
View Record View record according to given
parameters
Modify Record Prompt to correct record and update file
Module File - Module.dat
Add New Record Show successfully modified message and
increase file size
View Record View record according to given
parameters
Modify Record Prompt to correct record and update file
Marks File - Marks.dat
Add New Record Show successfully modified message and
increase file size
View Record View record according to given
parameters
Modify Record Prompt to correct record and update file
Enrolment file - Enrolment.dat
Add New Record Show successfully modified message and
increase file size
View Record View record according to given
parameters
Modify Record Prompt to correct record and update file

Table 5.7 Test plan for File Handling

30
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

1. Critical Evaluation

OOP is the latest programming trend in the world. As a software developer, engineer it is
necessary to absorb correct techniques and technology to keep in field.”Further Programming
Concept in C++” module gives a golden opportunity to polish knowledge and experience of a
student.

During the project life cycle, object oriented concept, UML and application of OOP concept
have practised. Since this is an individual project a variation of SDLC used to keep track on
the project works but with less documentation.

The following facts has identified during the project development

1. Object oriented concept based on mapping real word objects to computer code
2. By using OOP concept , designers and developers find that code
management(maintain and modifying) is easy
3. OOP reduce unnecessary duplication of the code and improve reusability of the
application
4. Using OOP, it is possible to implement code library which is integrated all necessary
components, class and abstract classes where implementation details are not allowed
to access to other. Because of this feature it is possible to provide secure development
environment without giving direct access to base codes.
5. Required more time to initial design time and mapping with the real world entity can
be confusing, cause to serious logical errors and always not possible to perform.

By finding above facts, although there are some disadvantages it is determined that using
OOP concept cause to reduce lot of problems and increase effectiveness of the code.

31
Asia Pacific Institute of Information Technology
Sri Lanka
Further Programming Concepts in C++ (CE00314-2-FPCOP)

1. Reference

Balagurusamy, E.(2008) Object oriented program with c++. New Delhi: Tata McGraw-Hill.

Baldwin,R.G. (2008) Advanced OOP using C++ [online]. Available from:


http://www.dickbaldwin.com/AdvOOP/AdvCpp00110.htm#Abstraction.[Accessed 25 August
2009].

Schildt. (1998) Teach Your self C++ [online]. New Delhi: Tata McGraw-Hill. Available
from:http://books.google.com/books?
id=8uszuvNpFy0C&pg=PA5&dq=he+quality+that+allows+one+name+to+be+used+for+two
+or+more+related+but+technically+different+purposes.&ei=wJa0SpzAAqaSkQSaub37Dw#
v=onepage&q=&f=false.
[Accessed 5 May 2004].

Sun Developer Network Site. (2009) Understanding Instance and Class Members [online].
Available from: http://java.sun.com/docs/books/tutorial/java/javaOO/classvars.html.
[Accessed 25 August 2009].

Microsoft Developer Network. (2009) Classes: Blueprints for Objects [online]. Available
from: http://msdn.microsoft.com/en-us/library/ee5edha0.aspx.[Accessed 25 August 2009].

Morin,R.C. (2002) OOP Concepts by Example [online]. Available from:


http://docs.google.com/gview?
a=v&q=cache:wif9IvNXHIoJ:www.kbcafe.com/articles/OOP.Concepts.pdf+abstraction+
%2B+definition+%2BOOP&hl=en&gl=lk.[Accessed 25 August 2009].

32
Asia Pacific Institute of Information Technology
Sri Lanka

Você também pode gostar