Treasure Doc

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Student Record Management System

The following C++ program is a Student Record Management system. The program allows
users to perform the following operations:
• Enter student data (Name, roll number, Section, Program and Contact number)
• Display the student data that was entered.
• Search for a specific student's data by their roll number.
• Update a specific student's data by their roll number.
• Delete a specific student's data by their roll number or delete the entire data.
The program utilizes object-oriented programming concepts and provides a command-line
interface for interacting with the system.

Concepts Used in Program:


The program consists of the following concepts:
 Classes and object
 Inheritance (Single Inheritance)
 Constructor
 Data Encapsulation
 Array
 Loops

Classes:
The program consists of the following classes:
 Person
 Student
 StudentRecordManager

Person:
The Person class represents a person and has the following attributes and methods:

Attributes
 Name
 ContactNumber

Functions
 Person()
 Person(string Name, string ContactNumber)

1
 string getName()
 string getContactNumber()

Overview

This code defines a class called "Person" with two private member variables: "Name" and
"ContactNumber", both of type string.
The class has two constructors. The default constructor (Person()) does not take any
parameters and does not perform any specific actions. The second constructor (Person(string
Name, string ContactNumber)) takes two string parameters: "Name" and "ContactNumber".
Inside this constructor, the values of the parameters are assigned to the corresponding
member variables using the "this" keyword.
The class also provides two getter methods: "getName()" and "getContactNumber()". These
methods return the values of the private member variables "Name" and "ContactNumber",
respectively.

2
Student:
The Student class inherits from the Person class and represents a student. It adds the
following attributes and methods:

Attributes
 rollNo
 section
 program

Methods
 Student()
 Student(string Name, int rollNo, string section, string program, string ContactNumber)
 int getrollNo()
 string getSection()
 string getProgram()

Overview
This code defines a derived class called "Student" that inherits from the base class "Person".
The derived class adds new member variables specific to a student: "rollNo" of type int,
"section" and "program" of type string.
The class provides two constructors. The default constructor (Student()) does not take any
parameters and does not perform any specific actions. The second constructor (Student(string
Name, int rollNo, string section, string program, string ContactNumber)) takes several
parameters including the name, roll number, section, program, and contact number. It
initializes the base class "Person" using the constructor of the base class, passing the name
and contact number as parameters. It also initializes the derived class member variables with
the provided values.

3
The class also provides getter methods for the roll number, section, and program. It has setter
methods for the section and program, allowing these values to be updated.

4
StudentRecordManager
The StudentRecordManager class manages the collection of student records and provides
methods for adding, displaying, searching, updating, and deleting records. It has the
following attributes and methods:

Attributes
 students[MAX_STUDENTS]
 total

Methods
 StudentRecordManager()
 void addStudent(string name, int rollNo, string section, string program, string
contactNumber)
 void displayAllStudents()
 void searchStudent(int rollNo)
 void updateStudent(int rollNo)
 void deleteStudent(int rollNo)

Overview
This code defines a class called "StudentRecordManager" that inherits from the base class
"Person". The class manages student records and includes an array of 20 "Student" objects
called "students" to store the records. It also has a variable "total" to keep track of the number
of students in the record.
The class provides a default constructor that initializes the "total" variable to 0.

Functions:
 addStudent: This function takes parameters for student information (name, roll number,
section, program, and contact number) and creates a new "Student" object. If there is
space in the "students" array (total < 20), the new student is added to the array, and the
"total" variable is incremented. Otherwise, it displays a message indicating that the
maximum number of students has been reached.

5
Output for addStudent()

6
 displayAllStudents: This function displays the details of all the students in the
"students" array by iterating through the array and calling the appropriate getter methods
for each student.

Output for displayAllStudents()

7
 searchStudent: This function takes a roll number as a parameter and searches for a
matching student in the "students" array. If a match is found, it displays the student's
details. Otherwise, it displays a message indicating that the student was not found.

Output for searchStudent()

8
 updateStudent: This function takes a roll number as a parameter and searches for a
matching student in the "students" array. If a match is found, it prompts the user to enter
new information for the student's name, section, program, and contact number. It updates
the corresponding student object with the new information. If no matching student is
found, it displays a message indicating that the student was not found.

9
Output for updateStudent ()

 deleteStudent: This function takes a roll number as a parameter and searches for a
matching student in the "students" array. If a match is found, it shifts the remaining
elements in the array to fill the gap created by deleting the student. The "total"
variable is decremented, and a message is displayed to indicate the successful
deletion. If no matching student is found, it displays a message indicating that the
student was not found.

10
Output for deleteStudent():

Int main()
The main() function in this code creates a StudentRecordManager object called
recordManager and implements a menu-driven loop to interact with the student record
management system.
Within the loop, the user can choose different options:
 Enter data: Allows the user to input student details and add them to the record using the
addStudent() method.

 Display data: Shows the details of all students in the record using the
displayAllStudents() method.

 Search data: Prompts the user to enter a roll number and searches for a student with that
roll number using the searchStudent() method.

 Update data: Asks the user for a roll number and allows them to update the student's
information (name, section, program, and contact number) using the updateStudent()
method.

 Delete data: Requests a roll number and deletes the student record with that roll number
using the deleteStudent() method.

11
Exit the program: Terminates the program by returning 0 from the main() function.

The user's input is captured in the value variable, and a switch statement is used to perform
the corresponding action based on the selected option.

12
13
Class Diagram:

Explanation:
The class diagram includes the following relationships:
Inheritance: The Student class inherits from the Person class. This is represented by an
arrow with an open triangle pointing from Student to Person.
Composition: The StudentRecordManager class has a composition relationship with the
Student class. It is shown by a solid diamond shape on the StudentRecordManager side,
pointing towards the Student class.
Association: The StudentRecordManager class is associated with the Person class through
its association with the Student class. This association is represented by a line connecting the
StudentRecordManager and Student classes, indicating a general relationship.

14

You might also like