C# Programming: Create a program with the following OO structure. You do not hav
ID: 3915838 • Letter: C
Question
C# Programming:
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
import java.io.*;
public class Test {
public static void main(String[] args) throws IOException {
Dean dean = new Dean("Dean",new Double("10000"));
Professor professor1 = new Professor("professor1",new Double("8000"),"class1");
Professor professor2 = new Professor("professor2",new Double("8000"),"class2");
Professor professor3 = new Professor("professor3",new Double("8000"),"class3");
Administrator administrator1 = new Administrator("administrator1",new Double("9000"));
Administrator administrator2 = new Administrator("administrator2",new Double("9000"));
Administrator administrator3 = new Administrator("administrator3",new Double("9000"));
Researcher researcher1 = new Researcher("researcher1",new Double("8500"),ResearchSpeciality.COMPUTER);
Researcher researcher2 = new Researcher("researcher2",new Double("8500"),ResearchSpeciality.MATHS);
Researcher researcher3 = new Researcher("researcher3",new Double("8500"),ResearchSpeciality.PHSCYCOLOGY);
Staff staffs[] = {dean,professor1,professor2,professor3,administrator1,administrator2,administrator3,researcher1,researcher2,researcher3};
Math math = new Math(staffs);
ComputerScience computerScience = new ComputerScience(staffs);
English english = new English(staffs);
Geography geography = new Geography(staffs);
Departments departments[] = {math,computerScience,english,geography};
University university = new University(departments);
System.out.println(university.departments[2].staffs[3].name);
}
}
class University {
Departments departments[] = new Departments[4];
public University(Departments[] departments) {
this.departments = departments;
}
}
class Departments {
Staff staffs[] = new Staff[10];
public Departments(Staff[] staffs) {
this.staffs = staffs;
}
}
class Math extends Departments{
public Math(Staff[] staffs) {
super(staffs);
}
}
class English extends Departments{
public English(Staff[] staffs) {
super(staffs);
}
}
class Geography extends Departments{
public Geography(Staff[] staffs) {
super(staffs);
}
}
class ComputerScience extends Departments{
public ComputerScience(Staff[] staffs) {
super(staffs);
}
}
class Staff {
String name;
Double salary;
public Staff(String name, Double salary) {
this.name = name;
this.salary = salary;
}
}
interface ITeachable{
public void Teach();
}
interface IAdmin{
public void Administrate();
}
class Dean extends Staff implements IAdmin,ITeachable{
public Dean(String name, Double salary) {
super(name, salary);
}
@Override
public void Administrate() {
System.out.println("Dean.Administrate");
}
@Override
public void Teach() {
System.out.println("Dean.Teach");
}
}
class Professor extends Staff implements ITeachable{
String Class;
public Professor(String name, Double salary, String aClass) {
super(name, salary);
Class = aClass;
}
@Override
public void Teach() {
System.out.println("Professor.Teach");
}
}
class Administrator extends Staff implements IAdmin {
public Administrator(String name, Double salary) {
super(name, salary);
}
@Override
public void Administrate() {
System.out.println("Administrator.Administrate");
}
}
class Researcher extends Staff{
ResearchSpeciality speciality;
public Researcher(String name, Double salary, ResearchSpeciality speciality) {
super(name, salary);
this.speciality = speciality;
}
}
enum ResearchSpeciality{
MATHS,
COMPUTER,
PHSCYCOLOGY;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.