Project, with two attributes; projectNo (int) & location (string). Add the following: a parameterized constructor that initializes both fields getters toString() Supervisor, with two attributes; jobID (int) & name (string). A supervisor also has a list of projects. Add the following: a parameterized constructor that initializes jobId and name fields addProject(Project) method that adds the project object to the list of projects (if not null) terminateAllProjectsIn(String) method that searches for projects located in the passed location from the projects list, and if found, the method should remove these objects from the list and print a message “XX Project(s) terminated”. If the supervisor does not have projects in this location, your method should print the message “No current projects in ----------------” (----- means the passed location) ** toString method that returns the doctor details and the details of his/her patients.   ** NOTE: you cannot iterate the list and remove its elements at the same time. To do so, you will need to create a temporary list; that is a copy of the original: ArrayList tmp = (ArrayList) projects.clone(); Iterate the temporary list and perform the changes on the original.       Copy the class ProjectTest to the same package and make sure it runs and gives this output. App.java: public class ProjectTest {        public static void main(String[] args) {              Supervisor sup1 = new Supervisor(1, "Ali");              sup1.addProject(new Project(11, "Doha"));              sup1.addProject(new Project(22, "Khor"));              sup1.addProject(new Project(33, "Wakra"));              sup1.addProject(new Project(44, "doha"));              sup1.addProject(new Project(55, "DOHA"));                System.out.println(sup1);              System.out.println("_______________________\n");                sup1.terminateAllProjectsIn("Doha");              System.out.println("_______________________\n");                System.out.println(sup1);              System.out.println("_______________________\n");                sup1.terminateAllProjectsIn("thumama");              System.out.println("_______________________\n");                System.out.println(sup1);

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question
100%

Given the class App below, write the following classes such that the main class (App) runs with no errors, and gives the output indicated by the screenshot below.

You will need to create the classes:

  1. Project, with two attributes; projectNo (int) & location (string). Add the following:
    1. a parameterized constructor that initializes both fields
    2. getters
    3. toString()
  2. Supervisor, with two attributes; jobID (int) & name (string). A supervisor also has a list of projects. Add the following:
    1. a parameterized constructor that initializes jobId and name fields
    2. addProject(Project) method that adds the project object to the list of projects (if not null)
    3. terminateAllProjectsIn(String) method that searches for projects located in the passed location from the projects list, and if found, the method should remove these objects from the list and print a message “XX Project(s) terminated”. If the supervisor does not have projects in this location, your method should print the message “No current projects in ----------------” (----- means the passed location) **
    4. toString method that returns the doctor details and the details of his/her patients.

 

** NOTE: you cannot iterate the list and remove its elements at the same time. To do so, you will need to create a temporary list; that is a copy of the original:

ArrayList<Project> tmp = (ArrayList<Project>) projects.clone();

Iterate the temporary list and perform the changes on the original.

 

 

 

Copy the class ProjectTest to the same package and make sure it runs and gives this output.

App.java:

public class ProjectTest {

       public static void main(String[] args) {

             Supervisor sup1 = new Supervisor(1, "Ali");

             sup1.addProject(new Project(11, "Doha"));

             sup1.addProject(new Project(22, "Khor"));

             sup1.addProject(new Project(33, "Wakra"));

             sup1.addProject(new Project(44, "doha"));

             sup1.addProject(new Project(55, "DOHA"));

 

             System.out.println(sup1);

             System.out.println("_______________________\n");

 

             sup1.terminateAllProjectsIn("Doha");

             System.out.println("_______________________\n");

 

             System.out.println(sup1);

             System.out.println("_______________________\n");

 

             sup1.terminateAllProjectsIn("thumama");

             System.out.println("_______________________\n");

 

             System.out.println(sup1);

       }

}

 

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Development strategies
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage