Build class Project with id(int), desc (String), duration (int) , budget (double) and members (ArrayList of Workers). Provide parameterized constructor Project (int id, String desc, double budget). The member array will be initialized as empty array and initial duration of project will be 0. Provide setters for description & budget & getters for all except members list. Provide method addMember(Worker m) that adds worker instance to members array list. Provide a method Worker getMember(int wId) that searches for worker with given id in members list and returns instance. Provide a method addMemberHours(int wId, int h) that find Worker with wID in members list and then adds worker hours to instance. These many hours should also be added to duration of this project.( Also add 5 to the duration of this project). Provide method getTotalCost() to calculate total cost of project by summing budget and salary of each member of project. Override toString method to get output.
import java.util.Scanner;
public class Main {
public Actor(String desc, double budget, int id, int duration)
{
budgett = budget;
ID = id;
Duration = duration;
descccc=desc;
}
static void getTotalCost(){
Scanner input=new Scanner(System.in);
System.out.println("Enter the number of employees: ");
int n=input.nextInt();
System.out.println("Enter the price of each employee: ");
int price=input.nextInt();
System.out.println("Total cost of project "+price*n);
}
public static void main(String s[]){
Department D = new Department("I-14");
D.addMember(1, "Faiza", 200);
D.addMember(2, "Suru", 300);
D.addMember(3, "Tahi", 250);
D.addMember(4,"Salimm",150);
D.addMember(5, "Ahmed", 125);
D.addMember(6, "Nosir", 130);
D.addProject(1,"Room Construction", 1500);
D.addMember(1, 4);
D.addMember(1, 1);
D.addProject(4,"Financial Audit", 6500);
D.addMember(4,3);
D.addMember(4,4);
D.addMember(4,5);
D.addProject(3, "Procurement", 10000);
D.addMember(3,4);
D.addMember(3, 6);
D.addMember(3, 3);
D.addProjectWork(1, 4, 10);
D.addProjectWork(1, 1, 5);
D.addProjectWork(4, 3, 7);
D.addProjectWork(4, 4, 8);
D.addProjectWork(4, 5,3);
D.addProjectWork(3, 4, 4);
D.addProjectWork(3, 3, 1);
D.addProjectWork(3, 6, 4);
System.out.println(D);
}
}
Comments
Leave a comment