Trying to get MilitaryFitWatch.Java test code IDK why but it says after puttin in test code that goes with this that its
Posted: Mon May 02, 2022 11:43 am
Trying to get MilitaryFitWatch.Java
test code
IDK why but it says after puttin in test code that goes with
this that its to long, pls comment so I can comment back with
it
Part2: Once your Military Watch class is working, you should write a subclass of Military Watch called MilitaryFitWatch. This will be the same as a Military Watch, except that it will also store the steps that a person takes that day along with their goal. It that sense, it will act as a fitness watch. 20:21 You will have to be sure that the data in the Military Watch can be inherited. Be sure that MilitaryFitWatch is a subclass and that it does not unnecessarily duplicate data and methods. MilitaryFitWatch should have the following: Data: • (The data that are inherited from its parent class – do not declare them here) • An int that will hold the number of steps for that day • An int that will hold the daily goal (number of steps). Constructors: A default constructor which receives no arguments and sets the initial hour to 6 and the minutes to 0. Note - this is exactly what its parent (super) class would do if its default constructor were called so IF YOU WANT, it could just call the parent's default constructor to set them. But it should also set the initial number of steps to 0 and the initial goal to 5000. • A parameterized constructor which receives 2 integers (for the initial hour and minutes, in that order). It should first check to see if the initial hour that is received is legal; if it is less than 0 or greater than 23, then: throw new IllegalArgumentException(“your explanation here..."); Then check to see if the initial minutes that are received is legal; if it is less than 0 or greater than 59, then: throw new IllegalArgumentException(“your explanation here..."); If it gets past the checks and there are no illegal arguments, then set the real hour and minutes to what is received Note - this is exactly what its parent (super) class would do if it received the same values for
initial hour and initial minutes so IF YOU WANT, it could just call its parent's parameterized constructor, passing in the same values. But it should also set the initial number of steps to 0 and the initial goal to 5000. Methods: • (all of the methods that are inherited from its parent class – they don't have to be redefined in the MilitaryFitWatch class unless they are to be "overridden"). • addSteps - receives an int and returns nothing (void). It receives a number of steps and adds them to its current steps data. You do not have to check for illegal (negative) steps... • setGoal – receives an int and returns nothing (void). It receives a goal and sets its goal data to what is received. You do not have to check for an illegal (negative) goal... • goalReached() - receives nothing and returns a boolean. It will retur true if the goal is reached (the current number of steps is the goal), false otherwise. toStringo -receives nothing and returns a String which represents it. It will "override" its parent's toString() and return a String made up of the HH:MM followed by " steps: then the number of steps. For example, if the hours is 2 and the minutes is 30 and the number of steps is 675 and the goal is 6000, then it should return this String 02:30 Steps: 675 Goal: 6000" only 1 space between items Note- the "02:30" part of this result is done the same way as the parent's toString(). So IF YOU WANT, it could just call super.toString() to put together this part. • tick) - receives nothing and returns nothing (void). It will "override" the parent's tick() method and do the same thing (add 1 minute and do the carries), but also resets the steps to 0 if the carries make the hours reset to 0 (since it would change to the next day). Note - since it does the same thing as the parent's tick method, IF YOU WANT this one could call super.tick(); and then just check to see if the hours and minutes are both O now; if so, it has changed to the next day and the steps should be reset to 0.
RunTests: bash — Konsole File Edit View Bookmarks Settings Help ------ testing parameterized constructor ----- creating new MilitaryFitWatch(0, 7) ==> its toString() returned: 00:07 Steps: Ø Goal: 5000 creating new MilitaryFitWatch(0, 23) ==> its toString() returned: 00:23 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(5, 7) ==> its toString() returned: 05:07 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(5, 23) ==> its toString() returned: 05:23 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(12, 7) ==> its toString() returned: 12:07 Steps: Ø Goal: 5000 creating new MilitaryFitWatch(12, 23) ==> its toString() returned: 12:23 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(15, 7) ==> its toString() returned: 15:07 Steps: Ø Goal: 5000 creating new MilitaryFitWatch(15, 23) ==> its toString() returned: 15:23 Steps: 0 Goal: 5000 I testing illegal arguments creating new MilitaryFitWatch(0, ) ==> its toString() returned: 00:00 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(, 23) ==> its toString() returned: 00:23 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(O, 60) ==> java.lang. IllegalArgumentException creating new MilitaryFitWatch(12, 0) ==> its toString() returned: 12:00 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(12, 23) ==> its toString() returned: 12:23 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(12, 60) ==> java.lang. IllegalArgumentException creating new MilitaryFitWatch(24, 0) ==> java.lang. IllegalArgumentException RunTests: bash : 必 S % % % A 7:17 PM
test code
IDK why but it says after puttin in test code that goes with
this that its to long, pls comment so I can comment back with
it
Part2: Once your Military Watch class is working, you should write a subclass of Military Watch called MilitaryFitWatch. This will be the same as a Military Watch, except that it will also store the steps that a person takes that day along with their goal. It that sense, it will act as a fitness watch. 20:21 You will have to be sure that the data in the Military Watch can be inherited. Be sure that MilitaryFitWatch is a subclass and that it does not unnecessarily duplicate data and methods. MilitaryFitWatch should have the following: Data: • (The data that are inherited from its parent class – do not declare them here) • An int that will hold the number of steps for that day • An int that will hold the daily goal (number of steps). Constructors: A default constructor which receives no arguments and sets the initial hour to 6 and the minutes to 0. Note - this is exactly what its parent (super) class would do if its default constructor were called so IF YOU WANT, it could just call the parent's default constructor to set them. But it should also set the initial number of steps to 0 and the initial goal to 5000. • A parameterized constructor which receives 2 integers (for the initial hour and minutes, in that order). It should first check to see if the initial hour that is received is legal; if it is less than 0 or greater than 23, then: throw new IllegalArgumentException(“your explanation here..."); Then check to see if the initial minutes that are received is legal; if it is less than 0 or greater than 59, then: throw new IllegalArgumentException(“your explanation here..."); If it gets past the checks and there are no illegal arguments, then set the real hour and minutes to what is received Note - this is exactly what its parent (super) class would do if it received the same values for
initial hour and initial minutes so IF YOU WANT, it could just call its parent's parameterized constructor, passing in the same values. But it should also set the initial number of steps to 0 and the initial goal to 5000. Methods: • (all of the methods that are inherited from its parent class – they don't have to be redefined in the MilitaryFitWatch class unless they are to be "overridden"). • addSteps - receives an int and returns nothing (void). It receives a number of steps and adds them to its current steps data. You do not have to check for illegal (negative) steps... • setGoal – receives an int and returns nothing (void). It receives a goal and sets its goal data to what is received. You do not have to check for an illegal (negative) goal... • goalReached() - receives nothing and returns a boolean. It will retur true if the goal is reached (the current number of steps is the goal), false otherwise. toStringo -receives nothing and returns a String which represents it. It will "override" its parent's toString() and return a String made up of the HH:MM followed by " steps: then the number of steps. For example, if the hours is 2 and the minutes is 30 and the number of steps is 675 and the goal is 6000, then it should return this String 02:30 Steps: 675 Goal: 6000" only 1 space between items Note- the "02:30" part of this result is done the same way as the parent's toString(). So IF YOU WANT, it could just call super.toString() to put together this part. • tick) - receives nothing and returns nothing (void). It will "override" the parent's tick() method and do the same thing (add 1 minute and do the carries), but also resets the steps to 0 if the carries make the hours reset to 0 (since it would change to the next day). Note - since it does the same thing as the parent's tick method, IF YOU WANT this one could call super.tick(); and then just check to see if the hours and minutes are both O now; if so, it has changed to the next day and the steps should be reset to 0.
RunTests: bash — Konsole File Edit View Bookmarks Settings Help ------ testing parameterized constructor ----- creating new MilitaryFitWatch(0, 7) ==> its toString() returned: 00:07 Steps: Ø Goal: 5000 creating new MilitaryFitWatch(0, 23) ==> its toString() returned: 00:23 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(5, 7) ==> its toString() returned: 05:07 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(5, 23) ==> its toString() returned: 05:23 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(12, 7) ==> its toString() returned: 12:07 Steps: Ø Goal: 5000 creating new MilitaryFitWatch(12, 23) ==> its toString() returned: 12:23 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(15, 7) ==> its toString() returned: 15:07 Steps: Ø Goal: 5000 creating new MilitaryFitWatch(15, 23) ==> its toString() returned: 15:23 Steps: 0 Goal: 5000 I testing illegal arguments creating new MilitaryFitWatch(0, ) ==> its toString() returned: 00:00 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(, 23) ==> its toString() returned: 00:23 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(O, 60) ==> java.lang. IllegalArgumentException creating new MilitaryFitWatch(12, 0) ==> its toString() returned: 12:00 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(12, 23) ==> its toString() returned: 12:23 Steps: 0 Goal: 5000 creating new MilitaryFitWatch(12, 60) ==> java.lang. IllegalArgumentException creating new MilitaryFitWatch(24, 0) ==> java.lang. IllegalArgumentException RunTests: bash : 必 S % % % A 7:17 PM