Question

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

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 milestone’s 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 <code>reset()</code> will reset the object such
* that it will return the first goal on the next invocation of
* <code>getNextGoal()</code> after the <code>reset()</code>.
*
* 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 <code>reset()</code> will reset
* the object such that it will return the first constraint on the next
* invocation of <code>getNextConstraint()</code> after the
* <code>reset()</code>.
*
* @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 <code>reset()</code>
* will reset the object such that it will return the first risk on the next
* invocation of <code>getNextRisk()</code> after the <code>reset()</code>.
*
* @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() {

}


}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You have to made only one change ... save the event information in variable in if else statement the return it .......

/**************************Milestone.java*************************************/

import java.util.Date;

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;
   }

   /**
   *s
   * @return MilestoneAchieved
   */
   public String milestoneAchieved() {
       if (this.actualCompletionDate != null) {
           eventdescription = "Milestone Achieved";
       }
       return eventdescription;
   }

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

       }
       return eventdescription;
   }
}

Thanks a lot, Please let me know if you have any problem........

Add a comment
Know the answer?
Add Answer to:
please help with program,these are he requirements: I am also getting a "missing return statement" in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE HELP! The assignment details are in the *noted part of the code. I REALLY need...

    PLEASE HELP! The assignment details are in the *noted part of the code. I REALLY need help. import java.util.LinkedList; public class TwoDTree { private TwoDTreeNode root; private int size; public TwoDTree() {    clear(); } /** * Returns true if a point is already in the tree. * Returns false otherwise. * * The traversal remains the same. Start at the root, if the tree * is not empty, and compare the x-coordinates of the point passed * in and...

  • Im writing a method to evaluate a postfix expression. Using my own stack class. Here is my code but I keep getting a classcastexception where it says java.lang.Character cannot be cast to java.lang,In...

    Im writing a method to evaluate a postfix expression. Using my own stack class. Here is my code but I keep getting a classcastexception where it says java.lang.Character cannot be cast to java.lang,Integer. Im not sure how to fix this. public class Evaluator { public static void evaluatePost(String postFix)    {        LinkedStack stack2 = new LinkedStack();        int val1;        int val2;        int result;        for(int i = 0; i < postFix.length(); i++)        {            char m = postFix.charAt(i);            if(Character.isDigit(m))            {                stack2.push(m);            }            else            {               ...

  • Hey guys I am having trouble getting my table to work with a java GUI if...

    Hey guys I am having trouble getting my table to work with a java GUI if anything can take a look at my code and see where I am going wrong with lines 38-49 it would be greatly appreciated! Under the JTableSortingDemo class is where I am having erorrs in my code! Thanks! :) import java.awt.*; import java.awt.event.*; import java.util.*; import java.util.List; import javax.swing.*; public class JTableSortingDemo extends JFrame{ private JTable table; public JTableSortingDemo(){ super("This is basic sample for your...

  • Please help with the codes for the implementation of java.util.List, specifically for the 3 below overridden...

    Please help with the codes for the implementation of java.util.List, specifically for the 3 below overridden methods @Override        public int lastIndexOf(Object arg0) { required code }        @Override        public ListIterator<R> listIterator() { required code }        @Override        public ListIterator<R> listIterator(int arg0) { required code } PLEASE NOTE: Below are some of other overridden methods that are already implemented, they are meant to be examples of what the answers to the above questions for the 3 methods should...

  • Currently, I'm getting this as my output: "Exception in thread "main" java.lang.NullPointerException    at InfixExpression.execute(InfixExpression.java:98)   ...

    Currently, I'm getting this as my output: "Exception in thread "main" java.lang.NullPointerException    at InfixExpression.execute(InfixExpression.java:98)    at InfixExpression.Evaluate(InfixExpression.java:65)    at InfixExpression.setWholeExpr(InfixExpression.java:24)    at InfixExpression.<init>(InfixExpression.java:17)    at Main.testHW1(Main.java:17)    at Main.main(Main.java:6)" I need to get this as my output: "Testing InfixExpression: When passing null, the String and double = Infix String: , result: 0.0 When passing a valid String, the String and double = Infix String: ( 234.5 * ( 5.6 + 7.0 ) ) / 100.2, result: 29.488023952095805 ..." I...

  • Need Help finishing up MyCalendar Program: Here are the methods: Modifier and Type Method Desc...

    Need Help finishing up MyCalendar Program: Here are the methods: Modifier and Type Method Description boolean add​(Event evt) Add an event to the calendar Event get​(int i) Fetch the ith Event added to the calendar Event get​(java.lang.String name) Fetch the first Event in the calendar whose eventName is equal to the given name java.util.ArrayList<Event> list() The list of all Events in the order that they were inserted into the calendar int size() The number of events in the calendar java.util.ArrayList<Event>...

  • DataSetEmployee Can you please help me the JAVA program? Here is the requirement. Rewrite DataSetBook to...

    DataSetEmployee Can you please help me the JAVA program? Here is the requirement. Rewrite DataSetBook to be DataSetEmployee. DataSetEmployee should extend ArrayList<Employee> and have no instance variables. You'll have to decide what replaces the getPages concept for getMax/getMin. As a hint, what method of Employee returns a numeric value? Make a package com.acme.midmanager. This package should contain the Manager class. Make a package com.acme.personnel. This package should contain the DataSetEmployee class. Make a package com.acme.topmanagement. This package should contain the...

  • Can anyone helps to create a Test.java for the following classes please? Where the Test.java will...

    Can anyone helps to create a Test.java for the following classes please? Where the Test.java will have a Scanner roster = new Scanner(new FileReader(“roster.txt”); will be needed in this main method to read the roster.txt. public interface List {    public int size();    public boolean isEmpty();    public Object get(int i) throws OutOfRangeException;    public void set(int i, Object e) throws OutOfRangeException;    public void add(int i, Object e) throws OutOfRangeException; public Object remove(int i) throws OutOfRangeException;    } public class ArrayList implements List {   ...

  • c++, I am having trouble getting my program to compile, any help would be appreciated. #include...

    c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...

  • JAVA: Already completed: MyList.java, MyAbstractList.java, MyArrayList.java, MyLinkedLink.java, MyStack.java, MyQueue.java. Need to complete: ReversePoem.java. This program has...

    JAVA: Already completed: MyList.java, MyAbstractList.java, MyArrayList.java, MyLinkedLink.java, MyStack.java, MyQueue.java. Need to complete: ReversePoem.java. This program has you display a pessimistic poem from a list of phrases. Next, this program has you reverse the phrases to find another more optimistic poem. Use the following algorithm. 1.   You are given a list of phrases each ending with a pound sign: ‘#’. 2.   Create a single String object from this list. 3.   Then, split the String of phrases into an array of phrases...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT