This is C#, not JAVA and not C++ 1. Create a program with the following OO struc
ID: 3809673 • Letter: T
Question
This is C#, not JAVA and not C++
1. 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 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 IS-A relationships and the HAS-A relationships and implement things correctly.
You should determine reasonable types for all properties not otherwise specified and initialise 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Univ
{
public class University
{
Department[] department = new Department[4];
static void Main(string[] args)
{
University u = new University();
for (int i=0;i<4;i++)
{
u.department[i] = new Department();
}
u.department[0].staff[0] = new Dean("Deanie");
Researcher r = new Researcher("andy");
r.research = ResearchSpeciality.machinelearning;
Console.WriteLine(u.department[0].staff[0].name);
Console.WriteLine(r.research);
}
}
public class Department
{
public Staff[] staff = new Staff[10];
}
public class Math : Department
{
}
public class English : Department
{
}
public class Geography : Department
{
}
public class ComputerScience : Department
{
}
public class Staff
{
public string name;
public double salary;
public Staff(string name)
{
this.name = name;
}
}
public enum ResearchSpeciality { machinelearning, calculus, trignometry, computervisison, litearture, topology }
public interface ITeachable
{
void teach();
}
public interface IAdmin
{
void administrate();
}
public class Professsor : Staff, ITeachable
{
public Professsor(string name) : base(name)
{
}
public string classname;
public void teach()
{
Console.WriteLine("I am a teaching professor ");
}
}
public class Researcher :Staff, ITeachable
{
public Researcher(string name):base (name)
{
}
public ResearchSpeciality research;
public void teach()
{
Console.WriteLine("I am a teaching Researcher");
}
}
public class Dean : Staff,ITeachable, IAdmin
{
public Dean(string name):base (name)
{
}
public void teach()
{
Console.WriteLine("I am a teaching dean");
}
public void administrate()
{
Console.WriteLine("I am an admin dean");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.