Question: NEED HELP WITH JAVA CODE, MY CODE IS AT THE BOTTOM OF THIS PAGE HERE ARE THE INSTRUCTIONS HERE IS MY CODE SO FAR: public
NEED HELP WITH JAVA CODE, MY CODE IS AT THE BOTTOM OF THIS PAGE
HERE ARE THE INSTRUCTIONS






HERE IS MY CODE SO FAR:
public class Watch extends Object { private static int hours; private static int minutes; private static int seconds; public Watch(int hh, int mm, int ss) { this.hours = hh; this.minutes = mm; this.seconds = ss; } public Watch(int hh, int mm) { this.hours = hh; this.minutes = mm; this.seconds = 0; } public Watch(int hh) { this.hours = hh; this.minutes = 0; this.seconds = 0; } public Watch() { this.hours = 0; this.minutes = 0; this.seconds = 0; } public int getHours() { return this.hours; } public int getMinutes() { return this.minutes; } public int getSeconds() { return this.seconds; } public void setHours(int hh) { if ((hh 24)) hh = 0; this.hours = hh; } public void setMinutes(int mm) { if ((mm 60)) { mm = 0; this.minutes = mm; } } public void setSeconds(int ss) { if ((ss 60)) { ss = 0; } this.seconds = ss; } public String toString() { String result = getHours() + ":" + getMinutes() + ":" + getSeconds(); return result; } public static boolean equals(Watch otherWatch) { if (!Watch.equals(otherWatch)) { return false; } return true; } public void advance(int ss) { int tempSec = this.getHours() * 60 * 60 + this.getMinutes() * 60 + this.getSeconds(); tempSec += ss; seconds = tempSec % 60; } public void advance(int mm , int ss){ int tempSec = this.getHours() * 60 * 60 + this.getMinutes() * 60 + this.getSeconds(); tempSec += ss; seconds = tempSec % 60; int tempMin = this.getHours() * 60 + this.getMinutes(); tempMin += mm; minutes = tempMin / 60; } public void advance(int hh ,int mm , int ss){ int tempSec = this.getHours() * 60 * 60 + this.getMinutes() * 60 + this.getSeconds(); tempSec += ss; seconds = tempSec % 60; int tempMin = this.getHours() * 60 + this.getMinutes(); tempMin += mm; minutes = tempMin / 60; int tempHour = this.getHours(); tempHour += hh; hours = tempHour; } public static void main(String[] args) { Watch w1 = new Watch(); System.out.println(w1); Watch w2 = new Watch(19); System.out.println(w2); Watch w3 = new Watch(3,37); System.out.println(w3); Watch w4 = new Watch(16,29,45); System.out.println(w4); } } 4 Modeling a Digital Watch Implement the following UML class diagram, which specifies a Watch class that main- tains the time in 24-hour format, such as 2:43:44 (hours:minutes seconds). Note that the description column to the right of the box is not related to the UML; it is provided here to describe the role of each class member. The class Watch Watch stores the hours hours int stores the minutes minutes int stores the seconds seconds int Creates a Watch object initialized to the supplied values Watch (hh int mm int SS int hh, mm, and ss. Delegates the initialization of the in- stance fields hours, minutes, and seconds to the setter methods, which are in charge of validation of the sup- plied values. Note: this is the most general constructor to which the other constructors delegate their tion tasks. Watch (hh int, mm int) Delegates the task of initializing hours to hh, minutes to mm, and seconds to 0, to the most general constructor. Watch (hh int) Delegates the task of initializing hours to hh, minutes to 0, and seconds to 0 to the most general constructor. Delegates the task of initializing hours to 0, minutes to Watch 0, and seconds to 0, to the most general constructor. Returns hours get Hours int
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
