Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Clock
- {
- private static final int HOUR_TO_SECONDS = 3600;
- private static final int MINUTE_TO_SECONDS = 60;
- private static final int DAY_TO_HOUR = 24;
- private int hours;
- private int minutes;
- private int seconds;
- //initializing clock to 0
- public Clock()
- {
- hours = 0;
- minutes = 0;
- seconds = 0;
- }
- public Clock(int hours, int minutes, int seconds)
- {
- this.hours = hours;
- this.minutes = minutes;
- this.seconds = seconds;
- }
- //setting parameters for clock(not going over 60)
- public Clock(int totalSeconds)
- {
- hours = (totalSeconds / HOUR_TO_SECONDS % DAY_TO_HOUR);
- minutes = (totalSeconds % HOUR_TO_SECONDS / MINUTE_TO_SECONDS);
- seconds = (totalSeconds % MINUTE_TO_SECONDS);
- }
- //adding a tick to seconds
- public void tick()
- {
- int totalSeconds;
- totalSeconds = hours * 3600 + minutes* 60 + seconds;
- totalSeconds++;
- hours = (totalSeconds / HOUR_TO_SECONDS % DAY_TO_HOUR);
- minutes = (totalSeconds % HOUR_TO_SECONDS / MINUTE_TO_SECONDS);
- seconds = (totalSeconds % MINUTE_TO_SECONDS);
- }
- public Clock addClock(Clock Cl)
- {
- Clock testClock;
- int totalSeconds, totalSecondsCl;
- totalSeconds = (hours + HOUR_TO_SECONDS) + (minutes + MINUTE_TO_SECONDS) + seconds;
- totalSecondsCl =(Cl.hours + HOUR_TO_SECONDS) + (Cl.minutes + MINUTE_TO_SECONDS) + Cl.seconds;
- totalSeconds += totalSecondsCl;
- testClock = new Clock(totalSeconds);
- return testClock;
- }
- public static void main(String[] args)
- {
- Clock Cl1, Cl2, Cl3;
- Cl1 = new Clock(1, 2, 3);
- Cl2 = new Clock(4,5,6);
- Cl3 = Cl1.addClock(Cl2);
- }
- //time zone
- public String getTimeZones()
- {
- retun TimeZones;
- }
- public void Clock(int timeZone)
- {
- int timeZone;
- }
- public static void main(String[] args)
- {
- timezone timezone1, timezone2,timezone3;
- timezone1 = new timezone( );
- timezone1.setregion("newyork");
- timezone2 = new timezone( );
- timezone2.setregion("Kiev");
- timezone3 = new timezone( );
- timezone3.setregion("LA");
- }
- }
Add Comment
Please, Sign In to add comment