Mini Project 1 — Student Management System (OOP + C# Project)

Introduction

This mini project will help you understand how OOP concepts work together in a real-world scenario.
You will build a simple Student Management System using:

  • Classes & Objects
  • Encapsulation
  • Inheritance
  • Properties
  • Constructors
  • Polymorphism (optional extension)

This project is beginner-friendly and perfect for practicing real C# programming.


🎯 Project Goal

Create a system that can:

✔ Store student details
✔ Manage multiple students
✔ Add, remove, and display students
✔ Use OOP concepts properly


🧱 Step 1 — Class Design (Blueprint)

We will create 3 classes:

  1. Student
  2. Course (optional but recommended)
  3. StudentManager

🧑‍🎓 1️⃣ Student Class (Core Entity)

✔ Responsibilities:

  • Hold student data
  • Validate inputs
  • Provide a formatted view of student details

🧑‍💻 Code:

public class Student
{
    // Private fields (Encapsulation)
    private int age;

    // Properties
    public int Id { get; }
    public string Name { get; set; }
    public int Age
    {
        get => age;
        set
        {
            if (value > 4 && value < 120)
                age = value;
            else
                throw new ArgumentException("Invalid age.");
        }
    }
    public string CourseName { get; set; }

    // Constructor
    public Student(int id, string name, int age, string course)
    {
        Id = id;
        Name = name;
        Age = age;
        CourseName = course;
    }

    // Method
    public void PrintDetails()
    {
        Console.WriteLine($"ID: {Id}, Name: {Name}, Age: {Age}, Course: {CourseName}");
    }
}


🎓 2️⃣ Course Class (Optional but Useful)

✔ Responsibilities:

  • Represent a course
  • Store course-related info

🧑‍💻 Code:

public class Course
{
    public string CourseName { get; set; }
    public int DurationInMonths { get; set; }

    public Course(string name, int duration)
    {
        CourseName = name;
        DurationInMonths = duration;
    }
}


📋 3️⃣ StudentManager Class (Controller Layer)

✔ Responsibilities:

  • Add students
  • Remove students
  • List all students
  • Search students

🧑‍💻 Code:

public class StudentManager
{
    private List<Student> students = new List<Student>();

    // Add student
    public void AddStudent(Student s)
    {
        students.Add(s);
        Console.WriteLine($"Student {s.Name} added successfully.");
    }

    // Remove student by ID
    public void RemoveStudent(int id)
    {
        var student = students.FirstOrDefault(x => x.Id == id);
        if (student != null)
        {
            students.Remove(student);
            Console.WriteLine($"Student with ID {id} removed.");
        }
        else
        {
            Console.WriteLine("Student not found.");
        }
    }

    // Display all students
    public void DisplayAllStudents()
    {
        Console.WriteLine("\n--- Student List ---");
        foreach (var s in students)
        {
            s.PrintDetails();
        }
    }

    // Search student
    public void SearchStudent(int id)
    {
        var student = students.FirstOrDefault(x => x.Id == id);
        if (student != null)
        {
            Console.WriteLine("\nStudent found:");
            student.PrintDetails();
        }
        else
        {
            Console.WriteLine("Student not found.");
        }
    }
}


🖥️ Step 2 — Bring It All Together in Main Program

🧑‍💻 Example Program:

class Program
{
    static void Main()
    {
        StudentManager manager = new StudentManager();

        // Add students
        manager.AddStudent(new Student(1, "Amit", 20, "Computer Science"));
        manager.AddStudent(new Student(2, "Riya", 19, "Mathematics"));

        // Display students
        manager.DisplayAllStudents();

        // Search
        manager.SearchStudent(1);

        // Remove
        manager.RemoveStudent(2);

        // Display again
        manager.DisplayAllStudents();

        Console.ReadLine();
    }
}


🧠 OOP Concepts Used in This Project

ConceptHow It’s Used
Class & ObjectsStudent, Course, Manager
EncapsulationPrivate fields + Properties
ConstructorInitializing students
Inheritance (optional)You can extend Student → GraduateStudent
Polymorphism (optional)Override PrintDetails()
CollectionsList<Student>

🌈 Optional Extensions (For Practice)

Add more features:

1️⃣ Inheritance

class GraduateStudent : Student
{
    public string ThesisTopic { get; set; }
}

2️⃣ Polymorphism
Override PrintDetails().

3️⃣ Sorting Students
By name, age, course, etc.

4️⃣ Saving Data to File
Use text/JSON file.

5️⃣ Menu-based Console App
User can choose options.


🔍 FAQs

Q1: Is this a beginner-friendly project?

Yes, perfect for learning OOP basics.

Q2: Which OOP concepts are covered?

Classes, objects, properties, encapsulation, constructors, collections.

Q3: How to extend this project?

Use inheritance, interfaces, file handling, or LINQ.


🎉 Conclusion

This mini project teaches you how to apply OOP concepts to a real-world scenario.
It is a solid foundation for moving into larger applications like:

✔ Library Management System
✔ Employee Management System
✔ Banking System
✔ Inventory System