Programming lesson
Building a Console-Based Education Management System in C#: A Step-by-Step OOP Tutorial
Learn how to design and implement a console-based education management system in C# using object-oriented programming. This tutorial covers encapsulation, inheritance, polymorphism, UML diagrams, and data structures—perfect for COMP1551 coursework.
Introduction: Why Build an Education Management System?
In May 2026, schools and training centers are rapidly digitizing their operations. Whether it's a local tuition center or a large university, managing teachers, administrators, and students efficiently is critical. In this tutorial, you'll learn how to design a desktop information system using C# and object-oriented programming (OOP) principles. This project mirrors the COMP1551 Application Development coursework, where you create a console-based system for an education center. By following this guide, you'll master encapsulation, inheritance, polymorphism, and data structures—all while building a practical application that could be used in real-world scenarios.
Understanding the System Requirements
Before writing code, you must understand what the system should do. The education center needs to manage three user roles: Teaching Staff, Administration, and Students. Each role shares common data (like name, ID, email) but also has role-specific fields. For example, teachers have a department and subjects taught, administrators have an office number and access level, and students have a grade level and enrollment date. The system must allow adding, viewing (by role or all), editing, and deleting records. All data should be stored in appropriate data structures that can handle an unknown number of objects.
Designing with UML Diagrams
Before coding, it's wise to create UML diagrams to visualize the system. A Class Diagram shows the classes, their attributes, methods, and relationships. For this system, you'll have a base class Person with derived classes Teacher, Admin, and Student. A Use Case Diagram illustrates the interactions between users and the system—like adding a new student or viewing all teachers. These diagrams are often required in coursework (Task 2) and help you plan your code structure.
Setting Up the C# Console Application
Open Visual Studio or your preferred IDE and create a new Console Application project. Name it something like EducationManagementSystem. You'll write all code in a single .cs file (as per coursework requirements). Start by defining the Person base class with common properties and methods.
public class Person
{
// Encapsulated fields
private string name;
private string id;
private string email;
// Public properties
public string Name { get => name; set => name = value; }
public string ID { get => id; set => id = value; }
public string Email { get => email; set => email = value; }
// Constructor
public Person(string name, string id, string email)
{
Name = name;
ID = id;
Email = email;
}
// Virtual method for polymorphism
public virtual void DisplayInfo()
{
Console.WriteLine($"Name: {Name}, ID: {ID}, Email: {Email}");
}
}Notice the use of encapsulation: fields are private, and public properties control access. The virtual keyword allows derived classes to override DisplayInfo.
Implementing Derived Classes
Now create the Teacher, Admin, and Student classes. Each inherits from Person and adds its own fields. This is inheritance in action.
public class Teacher : Person
{
public string Department { get; set; }
public string Subjects { get; set; }
public Teacher(string name, string id, string email, string department, string subjects)
: base(name, id, email)
{
Department = department;
Subjects = subjects;
}
public override void DisplayInfo()
{
base.DisplayInfo();
Console.WriteLine($"Department: {Department}, Subjects: {Subjects}");
}
}
public class Admin : Person
{
public string OfficeNumber { get; set; }
public string AccessLevel { get; set; }
public Admin(string name, string id, string email, string officeNumber, string accessLevel)
: base(name, id, email)
{
OfficeNumber = officeNumber;
AccessLevel = accessLevel;
}
public override void DisplayInfo()
{
base.DisplayInfo();
Console.WriteLine($"Office: {OfficeNumber}, Access Level: {AccessLevel}");
}
}
public class Student : Person
{
public string GradeLevel { get; set; }
public DateTime EnrollmentDate { get; set; }
public Student(string name, string id, string email, string gradeLevel, DateTime enrollmentDate)
: base(name, id, email)
{
GradeLevel = gradeLevel;
EnrollmentDate = enrollmentDate;
}
public override void DisplayInfo()
{
base.DisplayInfo();
Console.WriteLine($"Grade: {GradeLevel}, Enrolled: {EnrollmentDate.ToShortDateString()}");
}
}Each derived class calls the base constructor using : base(...) and overrides DisplayInfo to show role-specific details. This is polymorphism: you can treat all Person objects the same way, yet each displays its own info.
Choosing the Right Data Structures
To store an unknown number of objects, use collections like List<T> or Dictionary. A List<Person> can hold objects of any derived type because of polymorphism. For example:
List<Person> people = new List<Person>();You can then add teachers, admins, and students to this list. When you need to view by role, you can filter using OfType<T>() or check with is keyword.
Building the Text-Based Menu
The system must present a menu with options to add, view, edit, and delete records. Use a while loop and switch statement. Here's a simplified version:
bool running = true;
while (running)
{
Console.WriteLine("\n=== Education Management System ===");
Console.WriteLine("1. Add Record");
Console.WriteLine("2. View All Records");
Console.WriteLine("3. View by Role");
Console.WriteLine("4. Edit Record");
Console.WriteLine("5. Delete Record");
Console.WriteLine("6. Exit");
Console.Write("Select option: ");
string choice = Console.ReadLine();
switch (choice)
{
case "1":
AddRecord(people);
break;
case "2":
ViewAll(people);
break;
// ... other cases
case "6":
running = false;
break;
default:
Console.WriteLine("Invalid option.");
break;
}
}Each method (e.g., AddRecord) handles the specific logic. For adding, you prompt for the role and then collect the appropriate data. For editing, you search by ID and update properties. For deletion, you remove the object from the list.
Adding Comments: 30% of Code
Coursework requires comments to be about 30% of the source code. Use XML comments for methods and inline comments for complex logic. For example:
/// <summary>
/// Adds a new person record based on user input.
/// </summary>
/// <param name="people">The list of persons.</param>
static void AddRecord(List<Person> people)
{
// Prompt for role
Console.Write("Enter role (Teacher/Admin/Student): ");
string role = Console.ReadLine().ToLower();
// ... rest of method
}Remember to comment your class definitions, properties, and any non-obvious code.
Polymorphism in Action: Viewing All Records
When viewing all records, you can iterate through the List<Person> and call DisplayInfo() on each object. Because of polymorphism, the correct overridden method is called automatically.
static void ViewAll(List<Person> people)
{
foreach (Person p in people)
{
p.DisplayInfo();
Console.WriteLine("---");
}
}This works for any derived type. If you want to view only teachers, you can filter:
static void ViewTeachers(List<Person> people)
{
var teachers = people.OfType<Teacher>();
foreach (Teacher t in teachers)
{
t.DisplayInfo();
Console.WriteLine("---");
}
}Real-World Analogy: Like a School's Digital Dashboard
Think of this system as a simplified version of a school's digital dashboard, similar to systems used by many educational institutions in 2026. Just as a dashboard shows different views for teachers, admins, and students, your console app provides role-specific functionality. The OOP design ensures that adding a new role (like a 'Guest' or 'Parent') is easy—just create a new derived class. This flexibility is why OOP is so powerful in application development.
Testing and Debugging Tips
Test each menu option thoroughly. Try adding multiple records of different roles, then view all and by role. Edit a record and verify changes. Delete a record and ensure it's removed. Watch out for index out-of-range errors when editing or deleting—always confirm the record exists. Use try-catch for input validation (e.g., parsing dates).
Conclusion
You've now built a console-based education management system in C# that demonstrates encapsulation, inheritance, polymorphism, and data structures. This project meets the core requirements of the COMP1551 coursework: a base class Person with derived classes, a text-based menu, and data stored in a List. Remember to add comments (30% of code) and submit your .cs file along with the PDF of your system description and UML diagrams. Good luck with your coursework!
Note: This tutorial is for educational purposes. Always follow your university's guidelines on AI usage and plagiarism.