forked from dravidjoseph/eecs448proj1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClock.java
More file actions
844 lines (672 loc) · 21.6 KB
/
Clock.java
File metadata and controls
844 lines (672 loc) · 21.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
/**
* @file: Clock.java
* @author: Ashley Hutton, Hannah Johnson, and Rabel Marte
* @date: 2/10/16
* @brief: Implementation file for Clock class
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Calendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Clock{
// create frame
private JFrame f;
// create panels for different views
private JPanel panelCont;
private JPanel p;
private JPanel stopWatchPanel;
private JPanel timerPanel;
private JPanel clearScreenPanel;
// create layout
CardLayout c1 = new CardLayout();
// create text fields for time, timer, and stopwatch
JTextField timeF;
JTextField timerF;
JTextField stopWatchF;
JTextField dateF;
// JTextField timeS;
// create buttons
private JButton changeTime;
private JButton stopWatch;
private JButton timer;
private JButton clearScreen;
private JButton changeDate;
private JButton zoomIn;
private JButton zoomOut;
private JButton switchToClock1;
private JButton switchToClock2;
private JButton redisplayScreen;
private JButton switchHourMode;
private JButton resetStopWatch;
private JButton pauseStopWatch;
private JButton pauseTimer;
private JButton resetTimer;
// create objects for time, timer and stopwatch
public Time timeClock = new Time();
public Time stopwatch = new Time();
public Time timerClock = new Time();
public DayOfWeek week = new DayOfWeek();
// default zoom and calendar date
private int m_zoomCounter = 3;
private int m_month = 1;
private int m_day = 3;
private String m_dayOfWeek;
private Boolean isEnable;
private Boolean timerSet = false;
private Boolean isStopWatchPaused = false;
private Boolean stopWatchRunning = false;
private Boolean goodTimeInput = false;
private Boolean goodTimerInput = false;
private Boolean goodCalendarInput = false;
private Boolean isTimerPaused = false;
/**
* @pre None
* @post Creates a Clock object which calls the gui method.
* @return None
*/
public Clock(){
gui();
}
/**
* @pre None
* @post None
* @return return m_zoomCounter
*/
public int getZoomCounter() {
return m_zoomCounter;
}
/**
* @pre passed in int counter
* @post sets member variable m_zoomCounter to passed in counter
* @return None
*/
public void setZoomCounter(int counter) {
m_zoomCounter = counter;
}
/**
* @pre None
* @post None
* @return return m_dayOfWeek
*/
public String getClockDayOfWeek() {
return m_dayOfWeek;
}
/**
* @pre None
* @post creates window, panels, buttons, and defaults calendar
* @return None
*/
public void gui(){
// Create window
f = new JFrame("Clock");
f.setVisible(true);
f.setSize(600,400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // program stops when x clicked
panelCont = new JPanel();
panelCont.setLayout(c1);
// add panel to the frame
f.add(panelCont);
// Create panel and make background white
p = new JPanel();
p.setBackground(Color.WHITE);
// Create buttons and button action
changeTime = new JButton("Change Time");
stopWatch = new JButton("Stopwatch");
timer = new JButton("Timer");
clearScreen = new JButton("Clear Screen");
changeDate = new JButton("Change Date");
zoomIn = new JButton("Zoom In");
zoomOut = new JButton("Zoom Out");
switchToClock1 = new JButton("Back to Clock");
switchToClock2 = new JButton("Back to Clock");
redisplayScreen = new JButton("Redisplay Screen");
switchHourMode = new JButton("Switch Hour Mode");
pauseStopWatch = new JButton("Pause/Resume");
resetStopWatch = new JButton("Reset");
pauseTimer = new JButton("Pause/Resume");
resetTimer = new JButton("Reset");
// Create clock text field
timeF = new JTextField(10);
timeF.setEditable(false);
timeF.setFont(new Font("Arial", Font.PLAIN, 30));
// Create timer text field
timerF = new JTextField(10);
timerF.setEditable(false);
timerF.setFont(new Font("Arial", Font.PLAIN, 30));
// Create stopwatch text field
stopWatchF = new JTextField(10);
stopWatchF.setEditable(false);
stopWatchF.setFont(new Font("Arial", Font.PLAIN, 30));
// Create a calendar text field
dateF = new JTextField(10);
dateF.setEditable(false);
dateF.setFont(new Font("Arial", Font.PLAIN, 30));
// add button to panel
p.add(changeTime);
p.add(stopWatch);
p.add(timer);
p.add(clearScreen);
p.add(changeDate);
p.add(zoomIn);
p.add(zoomOut);
p.add(switchHourMode);
p.add(timeF);
p.add(dateF);
//p.add(timeS);//
// set default day
week.setMonth(m_month);
week.setDay(m_day);
// calculate day of week from set month/day
week.calculateDayOfWeek();
m_dayOfWeek = week.getDayOfWeek();
// System.out.println(week.getDayOfWeek());
dateF.setText(week.getDayOfWeek());
// create stopwatch panel and add necessary fields and buttons
stopWatchPanel = new JPanel();
stopWatchPanel.setBackground(Color.WHITE);
stopWatchPanel.add(switchToClock1);
stopWatchPanel.add(stopWatchF);
stopWatchPanel.add(resetStopWatch);
stopWatchPanel.add(pauseStopWatch);
// create timer panel and add necessary fields and buttons
timerPanel = new JPanel();
timerPanel.setBackground(Color.WHITE);
timerPanel.add(switchToClock2);
timerPanel.add(pauseTimer);
timerPanel.add(resetTimer);
timerPanel.add(timerF);
// create panel to hide the display
clearScreenPanel = new JPanel();
clearScreenPanel.add(redisplayScreen);
// add panels to card layout
panelCont.add(p, "1");
panelCont.add(stopWatchPanel, "2");
panelCont.add(timerPanel, "3");
panelCont.add(clearScreenPanel, "4");
c1.show(panelCont, "1");
pauseStopWatch.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post resumes and pauses the stopwatch
* @return None
*/
public void actionPerformed(ActionEvent e){
if (isStopWatchPaused){
isStopWatchPaused = false;
}
else{
isStopWatchPaused = true;
}
}
});
resetStopWatch.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post resets the stopwatch to 00:00:00
* @return None
*/
public void actionPerformed(ActionEvent e){
stopwatch.setHour(0);
stopwatch.setMinute(0);
stopwatch.setSecond(0-1);
}
});
pauseTimer.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post pauses/resumes the timer
* @return None
*/
public void actionPerformed(ActionEvent e){
if (isTimerPaused){
isTimerPaused = false;
}
else{
isTimerPaused = true;
}
}
});
resetTimer.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post resets the timer to 00:00:00
* @return None
*/
public void actionPerformed(ActionEvent e){
timerSet = false;
timer.doClick();
}
});
switchToClock1.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post switches from stopwatch panel to main panel
* @return None
*/
public void actionPerformed(ActionEvent e){
// return to main page
c1.show(panelCont, "1");
}
});
switchToClock2.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post switches from timer panel to main panel
* @return None
*/
public void actionPerformed(ActionEvent e){
// return to main page
c1.show(panelCont, "1");
}
});
redisplayScreen.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post switches from redisplay panel to main panel
* @return None
*/
public void actionPerformed(ActionEvent e){
// return to main page
c1.show(panelCont, "1");
}
});
changeTime.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post changes the time to the user specified time
* @return None
*/
public void actionPerformed(ActionEvent e){
/** regular expression looking for the format "##:##:## AM/PM in 12hr */
String timePattern_12hr = "(^[1-9]|1[0-2]):([0-5][0-9]):([0-5][0-9])[ ]?(?i)(am|pm)$";
/** regular expression looking for the format "##:##:## in 24hr */
String timePattern_24hr = "(^[01]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$";
Pattern r;
Matcher m;
// Check if military time
// Create a Pattern object for appropriate hour Mode
while (!goodTimeInput){
if(timeClock.getIsMilitary()) {
String userTime = JOptionPane.showInputDialog("Enter the time (24 Hour):");
// if user clicks cancel, return
if (userTime == null){
return;
}
r = Pattern.compile(timePattern_24hr);
// Now create matcher object.
m = r.matcher(userTime);
}
else {
String userTime = JOptionPane.showInputDialog("Enter the time (12 Hour):");
// if user clicks cancel, return
if (userTime == null){
return;
}
r = Pattern.compile(timePattern_12hr);
// Now create matcher object.
m = r.matcher(userTime);
}
// if it's 12 hour mode, also set AM/PM
if(!timeClock.getIsMilitary()) {
if (m.find()){
goodTimeInput = true;
String ampm = m.group(4);
// System.out.println("Found value: " + m.group(0) );
// System.out.println("Found value: " + m.group(1) );
// System.out.println("Found value: " + m.group(2) );
// System.out.println("Found value: " + m.group(3) );
// System.out.println("Found value: " + m.group(4) );
timeClock.setSecond(Integer.parseInt(m.group(3))-1);
timeClock.setMinute(Integer.parseInt(m.group(2)));
timeClock.setHour(Integer.parseInt(m.group(1)));
if(ampm.equals("pm") || ampm.equals("PM")) {
//System.out.println("here");
timeClock.setAmPm(true);
timeClock.setMilitaryHour(Integer.parseInt(m.group(1)) + 12);
}
else if(ampm.equals("am") || ampm.equals("AM")) {
timeClock.setAmPm(false);
timeClock.setMilitaryHour(Integer.parseInt(m.group(1)));
}
}
}
else {
if (m.find( )) {
goodTimeInput = true;
// System.out.println("Found value: " + m.group(0) );
// System.out.println("Found value: " + m.group(1) );
// System.out.println("Found value: " + m.group(2) );
// System.out.println("Found value: " + m.group(3) );
timeClock.setSecond(Integer.parseInt(m.group(3))-1);
timeClock.setMinute(Integer.parseInt(m.group(2)));
timeClock.setHour(Integer.parseInt(m.group(1)));
timeClock.setMilitaryHour(Integer.parseInt(m.group(1)));
}
}
}
// automatically popup change date prompt
changeDate.doClick();
goodTimeInput = false;
}
});
stopWatch.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post starts the stopwatch and prints the stopwatch
* @return None
*/
public void actionPerformed(ActionEvent e){
if (!stopWatchRunning){
stopwatch.setSecond(0);
stopwatch.setMinute(0);
stopwatch.setHour(0);
stopWatchRunning = true;
}
stopWatchF.setText(stopwatch.getHour() + ":" +String.format("%02d", stopwatch.getMinute()) +":" + String.format("%02d",stopwatch.getSecond()));
// go to stopwatch page
c1.show(panelCont, "2");
//JOptionPane.showInputDialog(null, "working!");
}
});
timer.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post sets the timer to the user specified time and prints the timer
* @return None
*/
public void actionPerformed(ActionEvent e){
if (timerSet == false){
timerSet = true;
while (!goodTimerInput){
String userTimer = JOptionPane.showInputDialog("Enter the time:");
if (userTimer == null){
timerSet = false;
return;
}
/** regular expression looking for the format "##:##:## in 24hr */
String timerPattern = "(^[0-9]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$";
// Create a Pattern object
Pattern r = Pattern.compile(timerPattern);
// Now create matcher object.
Matcher m = r.matcher(userTimer);
if (m.find( )) {
goodTimerInput = true;
//System.out.println("Found value: " + m.group(0) );
//System.out.println("Found value: " + m.group(1) );
//System.out.println("Found value: " + m.group(2) );
//System.out.println("Found value: " + m.group(3) );
timerClock.setSecond(Integer.parseInt(m.group(3)));
timerClock.setMinute(Integer.parseInt(m.group(2)));
timerClock.setHour(Integer.parseInt(m.group(1)));
timerF.setText(timerClock.getHour() + ":" +String.format("%02d",timerClock.getMinute()) +":" + String.format("%02d",timerClock.getSecond()));
}
}
goodTimerInput = false;
}
// go to timer page
c1.show(panelCont, "3");
}
});
clearScreen.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post switches from clearScreen panel to main panel
* @return None
*/
public void actionPerformed(ActionEvent e){
c1.show(panelCont, "4");
}
});
changeDate.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post sets the day to the user specified date and prints the day
* @return None
*/
public void actionPerformed(ActionEvent e){
while (!goodCalendarInput){
String userDate = JOptionPane.showInputDialog("Enter the Date (MM/DD):");
if (userDate == null){
return;
}
// regular expression to find the date in the format MM/DD
String datePattern = "(^0[1-9]|1[0-2])/(0[1-9]|[1-2][0-9]|3[0-1])$";
// Create a Pattern object
Pattern r = Pattern.compile(datePattern);
// Now create matcher object.
Matcher m = r.matcher(userDate);
if (m.find()){
goodCalendarInput = true;
//System.out.println(m.group(0));
//System.out.println(m.group(1));
//System.out.println(m.group(2));
// set the month and day to the given input
m_month = Integer.parseInt(m.group(1));
m_day = Integer.parseInt(m.group(2));
if (( m_month == 2 && (m_day == 30 || m_day == 31)) ||
( m_month == 4 && m_day == 31 ) ||
( m_month == 6 && m_day == 31 ) ||
( m_month == 9 && m_day == 31 ) ||
( m_month == 11 && m_day == 31)){
// System.out.println("Bad Input");
}
else {
// Set member variables in DayOfWeek object and call calculateDayOfWeek
week.setMonth(m_month);
week.setDay(m_day);
week.calculateDayOfWeek();
dateF.setText(week.getDayOfWeek());
}
}
}
goodCalendarInput = false;
}
});
zoomIn.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post makes the clock text bigger
* @return None
*/
public void actionPerformed(ActionEvent e){
int counter = getZoomCounter();
if(counter == 1) {
setZoomCounter(2);
timeF.setFont(new Font("Arial", Font.PLAIN, 25));
}
else if(counter == 2) {
setZoomCounter(3);
timeF.setFont(new Font("Arial", Font.PLAIN, 30));
}
else if(counter == 3) {
setZoomCounter(4);
timeF.setFont(new Font("Arial", Font.PLAIN, 35));
}
else if(counter == 4) {
setZoomCounter(5);
timeF.setFont(new Font("Arial", Font.PLAIN, 40));
}
else if(counter == 5) {
setZoomCounter(6);
timeF.setFont(new Font("Arial", Font.PLAIN, 45));
}
}
});
zoomOut.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post makes the clock text smaller
* @return None
*/
public void actionPerformed(ActionEvent e){
int counter = getZoomCounter();
if(counter == 2) {
setZoomCounter(1);
timeF.setFont(new Font("Arial", Font.PLAIN, 20));
}
else if(counter == 3) {
setZoomCounter(2);
timeF.setFont(new Font("Arial", Font.PLAIN, 25));
}
else if(counter == 4) {
setZoomCounter(3);
timeF.setFont(new Font("Arial", Font.PLAIN, 30));
}
else if(counter == 5) {
setZoomCounter(4);
timeF.setFont(new Font("Arial", Font.PLAIN, 35));
}
else if(counter == 6) {
setZoomCounter(5);
timeF.setFont(new Font("Arial", Font.PLAIN, 40));
}
}
});
switchHourMode.addActionListener(new ActionListener(){
/**
* @pre passed in ActionEvent e
* @post switches from 12hr mode to 24hr mode and vice versa
* @return None
*/
public void actionPerformed(ActionEvent e){
// 24 hour
if(timeClock.getIsMilitary()) {
// convert hours back to 12 hour mode
// System.out.println("Hour: " + timeClock.getHour());
// System.out.println("Military Hour: " + timeClock.getMilitaryHour());
if(timeClock.getHour() > 12) {
timeClock.setHour(timeClock.getHour() - 12);
timeClock.setAmPm(true);
timeClock.setMilitaryHour(timeClock.getMilitaryHour() - 12);
}
// noon case
else if(timeClock.getHour() == 12) {
timeClock.setMilitaryHour(12);
timeClock.setAmPm(true);
}
else if(timeClock.getHour() == 0) {
timeClock.setMilitaryHour(0);
timeClock.setAmPm(false);
timeClock.setHour(12);
}
else {
timeClock.setAmPm(false);
}
timeClock.setIsMilitary(false);
// System.out.println("Set military to false");
}
// 12 hour
else {
// convert hours back to 24 hour mode
// System.out.println("Hour: " + timeClock.getHour());
// System.out.println("Military Hour: " + timeClock.getMilitaryHour());
if(timeClock.getAmPm() == true) {
timeClock.setHour(timeClock.getHour()+12);
timeClock.setMilitaryHour(timeClock.getMilitaryHour() + 12);
}
else {
if(timeClock.getHour() == 12) {
timeClock.setHour(0);
timeClock.setMilitaryHour(0);
}
}
timeClock.setIsMilitary(true);
// System.out.println("Set miliary to true");
}
}
});
//Initialize timer
Timer t = new Timer(1000, new Listener());
t.start();
Timer sw = new Timer(1000, new stopwatchListener());
sw.start();
Timer ti = new Timer(1000, new timerListener());
ti.start();
}
class stopwatchListener implements ActionListener {
/**
* @pre passed in ActionEvent e
* @post increments the stopwatch and prints the stopwatch
* @return None
*/
public void actionPerformed(ActionEvent e) {
// check if stopwatch should be paused or not
if (!isStopWatchPaused){
stopwatch.updateSeconds();
stopWatchF.setText(stopwatch.getHour() + ":" +String.format("%02d",stopwatch.getMinute()) +":" + String.format("%02d",stopwatch.getSecond()));
}
}
}
class timerListener implements ActionListener {
/**
* @pre passed in ActionEvent e
* @post decrements the timer and prints the timer
* @return None
*/
public void actionPerformed(ActionEvent e) {
// check that timer isn't at 0
if ( timerClock.getHour() == 0 &&
timerClock.getMinute() == 0 &&
timerClock.getSecond() == 0 ){
timerSet = false;
}
else {
if (!isTimerPaused){
timerClock.updateSecondsTimer();
timerF.setText(timerClock.getHour() + ":" + String.format("%02d",timerClock.getMinute()) + ":" + String.format("%02d",timerClock.getSecond()));
}
}
}
}
class Listener implements ActionListener {
/**
* @pre passed in ActionEvent e
* @post increments the clock and prints the clock
* @return None
*/
public void actionPerformed(ActionEvent e) {
timeClock.updateSeconds();
// print time to Screen
// if 24 hour
if(timeClock.getIsMilitary()) {
if(timeClock.getIsMidnight()) {
week.incrementDayOfWeek();
timeClock.setIsMidnight(false);
// System.out.println("Incremented day of week");
}
dateF.setText(week.getDayOfWeek());
timeF.setText(timeClock.getHour() + ":" + String.format("%02d",timeClock.getMinute()) + ":" + String.format("%02d",timeClock.getSecond()));
}
// if 12 hour
else {
if(timeClock.getIsMidnight()) {
week.incrementDayOfWeek();
timeClock.setIsMidnight(false);
// System.out.println(timeClock.getIsMidnight());
// System.out.println("Incremented day of week");
}
dateF.setText(week.getDayOfWeek());
// if pm
if(timeClock.getAmPm()) {
timeF.setText(timeClock.getHour() + ":" + String.format("%02d",timeClock.getMinute()) + ":" + String.format("%02d",timeClock.getSecond())
+ " " + "PM");
}
// if am
else {
timeF.setText(timeClock.getHour() + ":" + String.format("%02d",timeClock.getMinute()) + ":" + String.format("%02d",timeClock.getSecond())
+ " " + "AM");
}
}
}
}
/**
* @pre None
* @post runs the clock
* @return None
*/
public static void main(String[] args){
new Clock();
}
}