Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help with program,these are he requirements: I am also getting a missing return statement in my milestone class Create a new class Milestone which

please help with program,these are he requirements: I am also getting a "missing return statement" in my milestone class

Create a new class Milestone which contains at least an event description, a planned completion date, and an actual completion date (which will be unset when the milestone is created). There should be a method to changed the planned completion date as well as a method to designate the Milestone as achieved. Add a method that returns whether the milestone has been missed, completed early, completed on time, completed late, or still due.

Create a unit test to exercise the Milestone class.

Add the ability for the project to have numbered milestones that can be retrieved in date order with notation concerning the milestones status as well as the description.

Update the unit test for the Project.

My Code:Milestone.java

public class Milestone {

private String eventdescription; private Date expectedCompletionDate; private Date actualCompletionDate; public void milestoneTitle(String eventdescription){ this.eventdescription = eventdescription; } public void changeExpectedDate(Date date){ this.expectedCompletionDate = date; } /** * * @return MilestoneAchieved */ public String milestoneAchieved() { if (this.actualCompletionDate != null) { return "Milestone Achieved"; } } /** * * @return */ public String milestoneStatus() { Date d = new Date(); if (this.actualCompletionDate.before(this.expectedCompletionDate)) { return "Milestone Completed Early"; }else if (this.actualCompletionDate.after(this.expectedCompletionDate)) { return "Milestone Completed Late"; }else if (this.actualCompletionDate.equals(this.expectedCompletionDate)) { return "Milestone Completed on Time"; }else if ((this.actualCompletionDate == null)&&(d.after(this.expectedCompletionDate))) { return "Milestone Missed"; }else if ((this.actualCompletionDate == null)&&(d.before(this.expectedCompletionDate))) { return "Milestone Still Due"; } } }

Project.java

public class Project { private static final int SIZE = 10; private String title; private Goal[] goals = new Goal[SIZE]; private Constraint[] constraints = new Constraint[SIZE]; private Risk[] risks = new Risk[SIZE]; private Milestone[] milestones = new Milestone[SIZE];

private int numberGoals = 0; private int numberConstraints = 0; private int numberRisks = 0; private int numberMilestones = 0; private int nextGoalIndex = 0; private int nextConstraintIndex = 0; private int nextRiskIndex = 0; private int numMilestones = 1; /** * Models an effort to do something (build a product, write a paper, * marketing campaign, etc.) * * @param title text titling the project. If null, the project name will be * set to "Unnamed project" */ public Project(String title) { if (title == null) { this.title = "Unnamed project"; } else { this.title = title; } }

// Queries /** * Get the title of the project * * @return the title of the project name */ public String getTitle() { return title; }

/** * Represent a text description of the project like * {title} with {#constraints} constraints, {#goals} goals, and {#risks} risks. * @return string as described */ @Override public String toString() { return title + " with " + numberConstraints + " constraints, " + numberGoals + " goals, " + "and " + numberRisks + " risks."; }

// Commands /** * Add goal to the project * * @param goal the goal to add to the project */ public void addGoal(Goal goal) { if (numberGoals < SIZE) { goals[numberGoals++] = goal; } updateNumbering(goals, numberGoals); }

/** * Add constraint to the project * * @param constraint the constraint to add to project */ public void addConstraint(Constraint constraint) { if (numberConstraints < SIZE) { constraints[numberConstraints++] = constraint; } updateNumbering(constraints, numberConstraints); }

/** * Add risk to the project * * @param risk the risk to add to the project */ public void addRisk(Risk risk) { if (numberRisks < SIZE) { risks[numberRisks++] = risk; } // let Arrays sort risks array in descending using // r.priorty() as the sort index if ( numberRisks > 1) { Arrays.sort(risks, 0, numberRisks, Comparator.comparingInt( r -> -r.priority() ) ); } updateNumbering(risks, numberRisks); } // set component numbering to be sequential in array starting at 1 (index+1) private void updateNumbering(ProjectComponent[] components, int numberComponents) { for (int i = 0; i < numberComponents; i++) { components[i].setComponentID(i+1); } }

/** * Reset the getNextGoal, getNextConstraint, getNextRisk behaviors to start * again at the "first" item again to allow sequencing through the list * again. */ public void reset() { nextGoalIndex = 0; nextConstraintIndex = 0; nextRiskIndex = 0; }

// Other behavior /** * Get the next goal if it exists. The first time called, it will return the * first goal. The method reset() will reset the object such * that it will return the first goal on the next invocation of * getNextGoal() after the reset(). * * The order of the goals will be the ordered they were added to the object. * * @return goal object if one exists or null otherwise */ public Goal getNextGoal() { if (nextGoalIndex < numberGoals) { return goals[nextGoalIndex++]; } else { return null; } }

/** * Get the next constraint if it exists. The first time called, it will * return the first constraint. The method reset() will reset * the object such that it will return the first constraint on the next * invocation of getNextConstraint() after the * reset(). * * @return constraint object if one exists or null otherwise */ public Constraint getNextConstraint() { if (nextConstraintIndex < numberConstraints) { return constraints[nextConstraintIndex++]; } else { return null; } }

/** * Get the next risk if it exists in priority order. The first time called, * it will return the highest priority risk. The method reset() * will reset the object such that it will return the first risk on the next * invocation of getNextRisk() after the reset(). * * @return risk object if one exists or null otherwise */ public Risk getNextRisk() { if (nextRiskIndex < numberRisks) { return risks[nextRiskIndex++]; } else { return null; } } public void addLogger(Logger logger){ logger.log(10,"Project has been altered"); } // Milestone status information public Milestone getMilestones() {

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions