Question: using System; using System.Collections.Generic; public interface ITeachable { void Teach ( ) ; } public interface IAdmin { void Administrate ( ) ; } public
using System;
using System.Collections.Generic;
public interface ITeachable
void Teach;
public interface IAdmin
void Administrate;
public enum ResearchSpeciality
AI
QuantumComputing,
DataScience,
CyberSecurity
public abstract class Staff
public string Name get; set;
public decimal Salary get; set;
public Staffstring name, decimal salary
Name name;
Salary salary;
public class Dean : Staff, ITeachable, IAdmin
public Deanstring name, decimal salary : basename salary
public void Teach
Console.WriteLineDean is teaching.";
public void Administrate
Console.WriteLineDean is administrating.";
public class Professor : Staff, ITeachable
public string Class get; set;
public Professorstring name, decimal salary, string className : basename salary
Class className;
public void Teach
Console.WriteLineProfessor is teaching.";
public class Administrator : Staff, IAdmin
public Administratorstring name, decimal salary : basename salary
public void Administrate
Console.WriteLineAdministrator is administrating.";
public class Researcher : Staff, ITeachable
public ResearchSpeciality Speciality get; set;
public Researcherstring name, decimal salary, ResearchSpeciality speciality : basename salary
Speciality speciality;
public void Teach
Console.WriteLineResearcher is teaching.";
public class Department
public string Name get; set;
public List Staff get; set;
public Departmentstring name
Name name;
Staff new List;
public class University
public List Departments get; set;
public University
Departments new List
new DepartmentMath
new DepartmentEnglish
new DepartmentGeography
new DepartmentComputer Science"
;
Adding some default staff to each department
DepartmentsStaff.Addnew DeanDr Smith", ;
DepartmentsStaff.Addnew ProfessorProf Johnson", "Calculus";
DepartmentsStaff.Addnew AdministratorMs Brown", ;
DepartmentsStaff.Addnew ResearcherDr White", ResearchSpeciality.AI;
Adding default staff to Geography department to avoid index out of range error
DepartmentsStaff.Addnew DeanDr Green", ;
DepartmentsStaff.Addnew ProfessorProf Blue", "Geography ;
DepartmentsStaff.Addnew AdministratorMr Yellow", ;
DepartmentsStaff.Addnew ResearcherDr Red", ResearchSpeciality.DataScience;
public class Program
public static void Main
var u new University;
Accessing a valid index in Geography department
Console.WriteLineuDepartmentsStaffName;
Adding a new staff member to English department
uDepartmentsStaff.Addnew ResearcherAndy ResearchSpeciality.DataScience;
Additional test code
foreach var department in uDepartments
Console.WriteLine$"Department: departmentName;
foreach var staff in department.Staff
Console.WriteLine$"Staff: staffName Salary: staffSalary;
if staff is ITeachable teachable
teachable.Teach;
if staff is IAdmin admin
admin.Administrate;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
