You are required to write builds a record book for Projects being conducted at a department. A Project has an id, description, a list of members and start and end dates. In Project class make 2 abstract methods: getTeamSize(): that finds and returns the size of the team working on this project c and calculateCost(): that finds and returns the total cost of project. Provide the class MixedTeamProject which extends Project
a. This class represents a project that can have mixed types of members
b. Override the getTeamSize() appropriately so that it counts all members but makes sure that only active adhoc members are counted if there are any
c. Provide the implementation of calculateCost method so that the cost is calculated as under
i. Salaries are added for adhoc members
ii. Salaries of contract members are added but 11% tax is added for each contract member salary
iii. Salary of all hourly member is added and a flat amount of 1000 is added to cover additional cost.
import java.util.ArrayList;
import java.util.Date;
public abstract class Project {
private String id;
private String description;
private ArrayList<Member>members;
private Date start;
private Date end;
public abstract int getTeamSize();
public abstract double calculateCost();
}
public class MixedTeamProject extends Project {
@Override
public int getTeamSize() {
int size = 0;
for (Member member : getMembers()) {
if (member.isAdhoc()) {
size++;
}
}
return size;
}
@Override
public double calculateCost() {
double adhocSalaries = 0;
double contractSalaries = 0;
double hourlySalaries = 1000;
for (Member member : getMembers()) {
if (member.isAdhoc()) {
adhocSalaries += member.getSalary();
} else if (member.isContract()) {
contractSalaries += member.getSalary() * 1.11;
} else if (member.isHourly()) {
hourlySalaries += member.getSalary();
}
}
return adhocSalaries + contractSalaries + hourlySalaries;
}
}
Comments
Leave a comment