Question: Need full code. Use object Oriented Java. Implement a classClockwithgetHoursandgetMinutesmethods to return the current time. (Usenew java.util.Date.toString()and extract the time from that string.) Also provide

Need full code. Use object Oriented Java.

Implement a classClockwithgetHoursandgetMinutesmethods to return the current time. (Usenew java.util.Date.toString()and extract the time from that string.) Also provide agetTimemethod that returns a string with the hours and minutes by calling yourgetHoursandgetMinutesmethods. Provide a subclassWorldClockwhose constructor accepts a time offset. For example, from California, anew WorldClock(3)will show the time in New York, three time zones ahead.YourWorldClocksubclass should override some methods fromClock, but should not overridegetTime.

Hint: How to extract integer hour and minute fromDate()object:

public class Clock { private int hour,minute; public Clock(){ String s=new java.util.Date().toString(); hour=Integer.parseInt(s.substring(11,13)); minute=Integer.parseInt(s.substring(14,16)); } public int getMinute(){ return minute; } public int getHour(){ return hour; } public static void main(String[] args){ Clock c=new Clock(); System.out.printf("%02d:%02d ",c.getHour(),c.getMinute()); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!