Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer the the question thank you!! 1. Create a program with the followin

ID: 3844637 • Letter: P

Question

Please answer the the question thank you!!

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

2. Create a class for an inventory system for an RPG.

Your solution should contain the following classes

An Interface called IContainer - items that implement IContainer can have other things put inside them

Add method - adds an item to the container. You may NOT calculate or store the totals for the container here

TotalCount property - returns how many items are in the container including any containers inside. You MUST calculate the totalCount recursively when this method is called

TotalWeight property - returns the total weight of the container including any containers inside. You MUST calculate the totalWeight recursively when this method is called

A class called Inventory that implements IContainer

The constructor should pass in the number of items in the inventory

An abstract base class called Item

Each item should have a cost and a weight property

Several inherited objects from a typical RPG. Each item should have a different cost and weight

A BagOfHolding class which inherits from Item and implements IContainer

You should write some test code to test all of your classes. For example it might look something like this. Make sure that you test the recursive TotalCount and TotalWeight methods

@@@@

Explanation / Answer

//Include the needed files
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

//Create namespace
namespace myNamespace1
{

//Enumeration ResearchSpeciality
public enum ResearchSpeciality{MATHS, ZOOLOGY, BIOLOGY};

//ITeachable interface
public interface ITeachable
{
   //Teach()
   void Teach();
}

//IAdmin interface
public interface IAdmin
{
   void Administrate();
}

//Staff class
public class Staff
{
   public string Name{get;set;}
   public double salary{get;set;}

   //Default constructor
   public Staff()
   {
       Name="";
       salary=0;
   }

   //parameterized constructor
   public Staff(string nm1)
   {
       Name=nm1;
       salary =0;
   }

   //Overloaded constructor
   public Staff(string nm1, double nm2)
   {
       Name=nm1;
       salary=nm2;
   }
}

//Professor class
public class Professor: Staff,ITeachable
{
   public string cls{get;set;}
  
   //Default constructor
   public Professor():base()
   {
       cls="";
   }

   //parameterized constructor
   public Professor(string nm1):base(nm1)
   {
       cls="";
   }

   //Overloaded constructor
   public Professor(string nm1, double nm2, string nm3):base(nm1,nm2)
   {
       cls = nm3;
   }

   //implementing Teach() method
   public void Teach()
   {
       Console.WriteLine("I am Teaching the class:{0}",cls);
   }
}

//Researcher class
public class Researcher:Staff,ITeachable
{

   public ResearchSpeciality special{get;set;}

   //Default constructor
   public Researcher():base()
   {
       special=ResearchSpeciality.MATHS;
   }

   //parameterized constructor
   public Researcher(string nm1):base(nm1)
   {
   }
  
   //Overloaded constructor
   public Researcher(string nm1, double nm2, ResearchSpeciality nm3):base(nm1,nm2)
   {
       special = nm3;
   }  

   //implementing Teach() method
   public void Teach()
   {
       Console.WriteLine("I am Researching in the subject:{0}",special);
   }
}


//Dean class
public class Dean:Staff,ITeachable, IAdmin
{
  
   //Default constructor
   public Dean():base()
   {

   }

   //parameterized constructor
   public Dean(string nm1):base(nm1)
   {
   }

   //Overloaded constructor
   public Dean(string nm1, double nm2):base(nm1,nm2)
   {

   }

   //implementing Teach() method
   public void Teach()
   {
       Console.WriteLine("I am Dean");
   }

   //implementing Administrate() method
   public void Administrate()
   {
       Console.WriteLine("I am Administrating the department.");
   }
}


//Administrator class
public class Administrator: Staff, IAdmin
{
  
   //Default constructor
   public Administrator():base()
   {

   }

   //parameterized constructor
   public Administrator(string nm1):base(nm1)
   {
   }

   //Overloaded constructor
   public Administrator(string nm1, double nm2):base(nm1,nm2)
   {

   }

   //implementing Administrate() method
   public void Administrate()
   {
       Console.WriteLine("I am an Administrator.");
   }
}

//Department class
public class Department
{

   public Staff[] Staff{get;set;}
   public string depatName{get; set;}

   //Default constructor
   public Department()
   {
       depatName="";
       Staff=new Staff[10];
       for(int kk=0;kk<10;kk++)
       {
           Staff[kk]=new Staff();
       }
   }

   //Parameterized constructor
   public Department(string nm1)
   {
       depatName=nm1;
       Staff=new Staff[10];
       for(int kk=0;kk<10;kk++)
       {
           Staff[kk]=new Staff();
       }
   }

   //Method displays all the staff details
   public void displayStaffDetails()
   {
       for(int kk=0;kk<10;kk++)
       {
           Console.WriteLine("Name : {0} Salary: {1}", Staff[kk].Name, Staff[kk].salary);
       }
   }

}

//University class
public class University
{
   public Department[] Department{get;set;}
   public string univName{get;set;}

   public University()
   {
       univName="";
       Department=new Department[4];
       Department[0]=new Department("MATHS");
       Department[1]=new Department("ENGLISH");
       Department[2]=new Department("GEOGRAPHY");
       Department[3]=new Department("COMPUTERSCIENCE");

   }  

   //Parameterized constructor
   public University(string uname)
   {
       univName=uname;
       Department=new Department[4];
       Department[0]=new Department("MATHS");
       Department[1]=new Department("ENGLISH");
       Department[2]=new Department("GEOGRAPHY");
       Department[3]=new Department("COMPUTERSCIENCE");
   }

   //Method displays all the department names
   public void displayDepartmentNames()
   {
       int kk;
       for(kk=0;kk<4;kk++)
       {
           Console.WriteLine("Department : {0}", Department[kk].depatName);
       }
   }

}

//Tester class
public class Tester
{

   //Main
   static void Main(string[] args)
   {
       var u=new University();
       u.univName="MY UNIVERSITY";
       Console.WriteLine("{0}", u.univName);
       Console.WriteLine("===============================");
       Console.WriteLine("Departments in the university:");
       u.displayDepartmentNames();
       Console.WriteLine("===============================");
       Console.WriteLine(u.Department[2].Staff[3].Name);
       u.Department[1].Staff[0]=new Researcher("Andy");
       Console.WriteLine("Staffs info in department ENGLISH");
       u.Department[1].displayStaffDetails();
   }
}
}