Food Delivery Service System
A food delivery company wants to automate their system.
• DeliveryPerson (Base Class)
o id
o name
o salary
o area
o virtual method ShowInfo()
• Two types:
o BikeRider
▪ customerRating (0–100%)
▪ deliveryCharge (fixed 60 BDT per delivery)
▪ totalDeliveries
o Supervisor
▪ yearsOfExperience
• Method EmployeeStatus() in base class:
o BikeRider eligible for bonus if:
▪ customerRating > 80%
▪ totalDeliveries ≥ 100
o Supervisor eligible if:
▪ yearsOfExperience ≥ 3
• Method TotalEarn() in BikeRider:
o totalDeliveries × deliveryCharge
When ShowInfo() is called:
• Show all details
• Bonus eligibility
• Total earnings (if applicable)
Ride Sharing Service (Uber/Pathao Type)
A ride sharing company wants a software system.
• Driver (Base Class)
o driverId
o name
o baseSalary
o location
o virtual method ShowInfo()
• Two types:
o CarDriver
▪ rating (0–5)
▪ farePerRide (fixed 200 BDT)
▪ totalRides
o BikeDriver
▪ rating
▪ farePerRide (fixed 100 BDT)
▪ totalRides
• Method DriverStatus():
o Eligible for bonus if:
▪ rating ≥ 4.5
▪ totalRides ≥ 50
• Method TotalIncome():
o totalRides × farePerRide
ShowInfo() displays:
• All info
• Bonus eligibility
• Total income
Hospital Management System
A hospital wants to digitize their employee system.
• Staff (Base Class)
o id
o name
o salary
o department
o virtual method ShowInfo()
• Two types:
o Doctor
▪ consultationFee
▪ totalPatients
▪ experienceYears
o Nurse
▪ overtimeHours
▪ hourlyOvertimeRate
• Method StaffStatus():
o Doctor eligible for bonus if:
▪ experienceYears ≥ 5
▪ totalPatients ≥ 200
o Nurse eligible if:
▪ overtimeHours ≥ 50
• Method TotalEarn():
o Doctor: consultationFee × totalPatients
o Nurse: overtimeHours × hourlyOvertimeRate
Online Learning Platform
An e-learning platform wants to automate instructor management.
• Instructor (Base Class)
o id
o name
o baseSalary
o email
o virtual method ShowInfo()
• Two types:
o FullTimeInstructor
▪ yearsOfExperience
o PartTimeInstructor
▪ paymentPerCourse
▪ totalCourses
• Method InstructorStatus():
o FullTime eligible if:
▪ experience ≥ 3 years
o PartTime eligible if:
▪ totalCourses ≥ 5
• Method TotalEarn() (for PartTime):
o totalCourses × paymentPerCourse
Bank Employee System
A bank wants to manage different employee types.
• BankEmployee (Base Class)
o id
o name
o salary
o branch
o virtual ShowInfo()
• Two types:
o Cashier
▪ transactionsHandled
o LoanOfficer
▪ loansApproved
▪ yearsOfExperience
• Method EmployeeStatus():
o Cashier eligible if:
▪ transactionsHandled ≥ 1000
o LoanOfficer eligible if:
▪ loansApproved ≥ 50
▪ experience ≥ 2 years
5️⃣ Gym Management System
A gym wants to manage their trainers.
• Trainer (Base Class)
o id
o name
o salary
o specialization
o virtual method ShowInfo()
• Two types:
o PersonalTrainer
▪ sessionFee
▪ totalSessions
▪ clientRating
o GeneralTrainer
▪ yearsOfExperience
• Method TrainerStatus():
o PersonalTrainer eligible if:
▪ clientRating ≥ 85%
▪ totalSessions ≥ 30
o GeneralTrainer eligible if:
▪ experience ≥ 4 years
• Method TotalIncome():
o sessionFee × totalSessions
Simple solution(Normal)
namespace GymManagementSystem
{
// Personal Trainer Class
class PersonalTrainer
{
public int Id;
public string Name;
public double Salary;
public string Specialization;
public double SessionFee;
public int TotalSessions;
public double ClientRating;
public PersonalTrainer(int id, string name, double salary, string specialization,
double sessionFee, int totalSessions, double clientRating)
{
Id = id;
Name = name;
Salary = salary;
Specialization = specialization;
SessionFee = sessionFee;
TotalSessions = totalSessions;
ClientRating = clientRating;
}
public bool IsEligibleForBonus()
{
return ClientRating >= 85 && TotalSessions >= 30;
}
public double TotalIncome()
{
return SessionFee * TotalSessions;
}
public void ShowInfo()
{
[Link]("---- Personal Trainer ----");
[Link]("ID: " + Id);
[Link]("Name: " + Name);
[Link]("Salary: " + Salary);
[Link]("Specialization: " + Specialization);
[Link]("Session Fee: " + SessionFee);
[Link]("Total Sessions: " + TotalSessions);
[Link]("Client Rating: " + ClientRating + "%");
[Link]("Total Income: " + TotalIncome());
[Link]("Eligible for Bonus: " + (IsEligibleForBonus() ? "Yes" : "No"));
[Link]("--------------------------------");
}
}
// General Trainer Class
class GeneralTrainer
{
public int Id;
public string Name;
public double Salary;
public string Specialization;
public int YearsOfExperience;
public GeneralTrainer(int id, string name, double salary, string specialization,
int yearsOfExperience)
{
Id = id;
Name = name;
Salary = salary;
Specialization = specialization;
YearsOfExperience = yearsOfExperience;
}
public bool IsEligibleForBonus()
{
return YearsOfExperience >= 4;
}
public void ShowInfo()
{
[Link]("---- General Trainer ----");
[Link]("ID: " + Id);
[Link]("Name: " + Name);
[Link]("Salary: " + Salary);
[Link]("Specialization: " + Specialization);
[Link]("Years of Experience: " + YearsOfExperience);
[Link]("Eligible for Bonus: " + (IsEligibleForBonus() ? "Yes" : "No"));
[Link]("--------------------------------");
}
}
class Program
{
static void Main(string[] args)
{
List<PersonalTrainer> personalTrainers = new List<PersonalTrainer>()
{
new PersonalTrainer(1, "Rahim", 20000, "Weight Training", 500, 35, 90),
new PersonalTrainer(2, "Sadia", 22000, "Yoga", 400, 20, 80)
};
List<GeneralTrainer> generalTrainers = new List<GeneralTrainer>()
{
new GeneralTrainer(3, "Karim", 18000, "Cardio", 5),
new GeneralTrainer(4, "Nabil", 17000, "Strength", 2)
};
// foreach for Personal Trainers
foreach (PersonalTrainer pt in personalTrainers)
{
[Link]();
}
// foreach for General Trainers
foreach (GeneralTrainer gt in generalTrainers)
{
[Link]();
}
[Link]();
}
}
}
More OOP2 advance solution
Here is a complete C# console example for the Gym Management System:
namespace GymManagementSystem
{
// Base Class
class Trainer
{
public int Id { get; set; }
public string Name { get; set; }
public double Salary { get; set; }
public string Specialization { get; set; }
public Trainer(int id, string name, double salary, string specialization)
{
Id = id;
Name = name;
Salary = salary;
Specialization = specialization;
}
// Virtual Method
public virtual bool TrainerStatus()
{
return false; // default
}
public virtual void ShowInfo()
{
[Link]("Trainer ID: " + Id);
[Link]("Name: " + Name);
[Link]("Salary: " + Salary);
[Link]("Specialization: " + Specialization);
[Link]("Eligible for Bonus: " + (TrainerStatus() ? "Yes" : "No"));
}
}
// Derived Class 1
class PersonalTrainer : Trainer
{
public double SessionFee { get; set; }
public int TotalSessions { get; set; }
public double ClientRating { get; set; }
public PersonalTrainer(int id, string name, double salary, string specialization,
double sessionFee, int totalSessions, double clientRating)
: base(id, name, salary, specialization)
{
SessionFee = sessionFee;
TotalSessions = totalSessions;
ClientRating = clientRating;
}
public double TotalIncome()
{
return SessionFee * TotalSessions;
}
public override bool TrainerStatus()
{
return (ClientRating >= 85 && TotalSessions >= 30);
}
public override void ShowInfo()
{
[Link]();
[Link]("Session Fee: " + SessionFee);
[Link]("Total Sessions: " + TotalSessions);
[Link]("Client Rating: " + ClientRating + "%");
[Link]("Total Income: " + TotalIncome());
[Link]("---------------------------");
}
}
// Derived Class 2
class GeneralTrainer : Trainer
{
public int YearsOfExperience { get; set; }
public GeneralTrainer(int id, string name, double salary, string specialization,
int yearsOfExperience)
: base(id, name, salary, specialization)
{
YearsOfExperience = yearsOfExperience;
}
public override bool TrainerStatus()
{
return YearsOfExperience >= 4;
}
public override void ShowInfo()
{
[Link]();
[Link]("Years of Experience: " + YearsOfExperience);
[Link]("---------------------------");
}
}
class Program
{
static void Main(string[] args)
{
// Create a list of Trainer (Polymorphism)
List<Trainer> trainers = new List<Trainer>()
{
new PersonalTrainer(1, "Rahim", 20000, "Weight Training", 500, 35, 90),
new PersonalTrainer(2, "Sadia", 22000, "Yoga", 400, 20, 80),
new GeneralTrainer(3, "Karim", 18000, "Cardio", 5),
new GeneralTrainer(4, "Nabil", 17000, "Strength", 2)
};
// Using foreach
foreach (Trainer trainer in trainers)
{
[Link](); // Runtime Polymorphism happens here
}
[Link]();
}
}
}
What This Demonstrates
• ✔ Inheritance
• ✔ Method overriding
• ✔ Virtual method
• ✔ Constructor chaining (: base(...))
• ✔ Polymorphism (Trainer t1 = new PersonalTrainer(...))
• ✔ Business rule logic