Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.time.*;
- class Clock {
- LocalTime time;
- public Clock (int hour, int minute) {
- this.time = LocalTime.of (hour, minute);
- }
- public LocalTime getTime() {
- return time;
- }
- public String toString() {
- return String.valueOf(time);
- }
- public LocalTime addMinutes (int minutes) {
- time = time.plusMinutes(minutes);
- return time;
- }
- }
- class Program {
- public static void main (String[] args) {
- List<Clock> clocks = new LinkedList<>();
- clocks.add (new Clock (12, 15));
- clocks.add (new Clock (14, 25));
- clocks.add (new Clock (17, 34));
- clocks.add (new Clock (23, 59));
- System.out.println(clocks);
- List<Clock> clocksAfterAddMinutes = new LinkedList<>();
- for (int i=0; i<clocks.size(); i++) {
- System.out.println(clocks.get(i).addMinutes(1));
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement