The program needs to be in C# Create a program with the following OO structure.
ID: 3915875 • Letter: T
Question
The program needs to be in C#
Create a program with the following OO structure. You do not have to implement any of the methods other than constructors to fill in some default data. You should implement the rest of the methods with a Console.WriteLine to indicate that it has been called. Within a UNIVERSITY there are 4 DEPARTMENTS: MATH, ENGLISH, GEOGRAPHY, COMPUTERSCIENCE Each DEPARTMENT has up to 10 STAFF There is/are a DEAN, PROFESSORs, ADMINISTRATORs and RESEARCHERs All Staff should have a name and salary Professors should have a Class Researchers should have a ResearchSpeciality which is a fixed set of research areas represented by an enumeration Deans, Professors and Researchers should implement an ITeachable interface which contains the Teach() method Deans and Administrators should implement an IAdmin interface which contains the Administrate() method Pay special attention to the ISA relationships and the HASA relationships and implement things correctly. You should determine reasonable types for all properties not otherwise specified and initialize things with sensible defaults. Your constructors should have reasonable parameters to set up the type where you cannot simply use constants. var u = new University()? Console.WriteLine(u.Department[2].Staff[3].Name)? u.Department[1].Staff[0] = new Researcher("Andy")? You should create additional test code to make sure that all of the properties and methods are available.
Explanation / Answer
Program code in C# :
Answer:
// includes header files
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace university
{
//Define a class
public class University
{
//create a array
Department[] DeptObj = newDepartment[4];
// Main program
static void Main(string[] args)
{
// Creating an object foran class
University uni = newUniversity();
for (int it = 0; it <4; it++)
{
//Assignsthe department
uni.DeptObj[it] = new Department();
}
// Includesentities
uni.DeptObj[0].Staff1[0]= new Dean("Victor");
Researcher Re = newResearcher("Andy");
Professsor P1 = newProfesssor("Praisy");
Re.research =Research_Speciality.Machinelearning;
// Display thevalues
Console.WriteLine(uni.DeptObj[0].Staff1[0].Name);
Console.WriteLine(Re.research);
Console.ReadLine();
}
}
//Define a Class as department
public class Department
{
//Create a array
public StaffS[] Staff1 = newStaffS[10];
}
//class maths department
public class MathS : Department
{ }
//class english department
public class English : Department
{ }
//class english Geography
public class Geography : Department
{ }
//class english ComputerScience
public class ComputerScience : Department
{ }
//Declare a Class for staffs
public class StaffS
{
// Declared required variables
public string Name;
public double Staffsalary;
// Implement a constructor forclass
public StaffS(string Names)
{
this.Name = Names;
}
}
// Creating enum
public enum Research_Speciality { Machinelearning,Calculus, Trignometry, Computervisison, Litearture, Topology}
// Define a Interface for iTeachable
public interface iTeachable
{
void Teach();
}
//Interface as iAdmin
public interface iAdmin
{
void Administrate();
}
//Define a Class Professors
public class Professsor : StaffS, iTeachable
{
//constructor
public Professsor(string Names)
: base(Names)
{
}
// Imlements the Name
public string NameOfClass;
public void Teach()
{
Console.WriteLine("I Am ATeaching Professor ");
}
}
// Implement a Class Researcher
public class Researcher : StaffS, iTeachable
{
//constructor
public Researcher(string Names)
: base(Names)
{ }
//class ResearchSpeciality
public Research_Specialityresearch;
//defines teach()
public void Teach()
{
Console.WriteLine("I Am ATeaching Researcher");
}
}
// Implement a class Dean
public class Dean : StaffS, iTeachable, iAdmin
{
//constructor
public Dean(string Names)
: base(Names)
{
}
public void Teach()
{
Console.WriteLine("I Am ATeaching Dean");
}
//Defines the Administrate()
public void Administrate()
{
Console.WriteLine("I AmAn Admin Dean");
}
}
}
Sample Output :
Andy
machinelearning
Editable Code :
// includes header files
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace university
{
//Define a class
public class University
{
//create a array
Department[] DeptObj = newDepartment[4];
// Main program
static void Main(string[] args)
{
// Creating an object foran class
University uni = newUniversity();
for (int it = 0; it <4; it++)
{
//Assignsthe department
uni.DeptObj[it] = new Department();
}
// Includesentities
uni.DeptObj[0].Staff1[0]= new Dean("Victor");
Researcher Re = newResearcher("Andy");
Professsor P1 = newProfesssor("Praisy");
Re.research =Research_Speciality.Machinelearning;
// Display thevalues
Console.WriteLine(uni.DeptObj[0].Staff1[0].Name);
Console.WriteLine(Re.research);
Console.ReadLine();
}
}
//Define a Class as department
public class Department
{
//Create a array
public StaffS[] Staff1 = newStaffS[10];
}
//class maths department
public class MathS : Department
{ }
//class english department
public class English : Department
{ }
//class english Geography
public class Geography : Department
{ }
//class english ComputerScience
public class ComputerScience : Department
{ }
//Declare a Class for staffs
public class StaffS
{
// Declared required variables
public string Name;
public double Staffsalary;
// Implement a constructor forclass
public StaffS(string Names)
{
this.Name = Names;
}
}
// Creating enum
public enum Research_Speciality { Machinelearning,Calculus, Trignometry, Computervisison, Litearture, Topology}
// Define a Interface for iTeachable
public interface iTeachable
{
void Teach();
}
//Interface as iAdmin
public interface iAdmin
{
void Administrate();
}
//Define a Class Professors
public class Professsor : StaffS, iTeachable
{
//constructor
public Professsor(string Names)
: base(Names)
{
}
// Imlements the Name
public string NameOfClass;
public void Teach()
{
Console.WriteLine("I Am ATeaching Professor ");
}
}
// Implement a Class Researcher
public class Researcher : StaffS, iTeachable
{
//constructor
public Researcher(string Names)
: base(Names)
{ }
//class ResearchSpeciality
public Research_Specialityresearch;
//defines teach()
public void Teach()
{
Console.WriteLine("I Am ATeaching Researcher");
}
}
// Implement a class Dean
public class Dean : StaffS, iTeachable, iAdmin
{
//constructor
public Dean(string Names)
: base(Names)
{
}
public void Teach()
{
Console.WriteLine("I Am ATeaching Dean");
}
//Defines the Administrate()
public void Administrate()
{
Console.WriteLine("I AmAn Admin Dean");
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.