File tree 16 files changed +992
-0
lines changed
16 files changed +992
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <modelVersion >4.0.0</modelVersion >
6
+
7
+ <groupId >org.example</groupId >
8
+ <artifactId >lab_03</artifactId >
9
+ <version >1.0-SNAPSHOT</version >
10
+
11
+ <properties >
12
+ <maven .compiler.source>15</maven .compiler.source>
13
+ <maven .compiler.target>15</maven .compiler.target>
14
+ </properties >
15
+ <dependencies >
16
+ <dependency >
17
+ <groupId >org.openjfx</groupId >
18
+ <artifactId >javafx-controls</artifactId >
19
+ <version >13</version >
20
+ </dependency >
21
+ <dependency >
22
+ <groupId >org.openjfx</groupId >
23
+ <artifactId >javafx-fxml</artifactId >
24
+ <version >13</version >
25
+ </dependency >
26
+ <dependency >
27
+ <groupId >com.google.code.gson</groupId >
28
+ <artifactId >gson</artifactId >
29
+ <version >2.8.5</version >
30
+ <scope >compile</scope >
31
+ </dependency >
32
+ </dependencies >
33
+ <build >
34
+ <plugins >
35
+ <plugin >
36
+ <groupId >org.apache.maven.plugins</groupId >
37
+ <artifactId >maven-compiler-plugin</artifactId >
38
+ <version >3.8.0</version >
39
+ <configuration >
40
+ <release >11</release >
41
+ </configuration >
42
+ </plugin >
43
+ <plugin >
44
+ <groupId >org.openjfx</groupId >
45
+ <artifactId >javafx-maven-plugin</artifactId >
46
+ <version >0.0.3</version >
47
+ <configuration >
48
+ <mainClass >ClientForm</mainClass >
49
+ </configuration >
50
+ </plugin >
51
+ </plugins >
52
+ </build >
53
+ </project >
Original file line number Diff line number Diff line change
1
+ public class Alarm implements IAlarm {
2
+ int hours ;
3
+ int minutes ;
4
+
5
+ protected void checkValue (int value ) {
6
+ if (value < 0 )
7
+ throw new IllegalArgumentException ("Value must be not negative!" );
8
+ }
9
+
10
+ @ Override
11
+ public void setHours (int hours ) {
12
+ try {
13
+ checkValue (hours );
14
+ this .hours = hours % 24 ;
15
+ } catch (IllegalArgumentException e ) {
16
+ System .out .println (e .getMessage ());
17
+ }
18
+ }
19
+
20
+ @ Override
21
+ public void setMinutes (int minutes ) {
22
+ try {
23
+ checkValue (minutes );
24
+ setHours (this .hours + minutes / 60 );
25
+ this .minutes = minutes % 60 ;
26
+ } catch (IllegalArgumentException e ) {
27
+ System .out .println (e .getMessage ());
28
+ }
29
+ }
30
+
31
+ @ Override
32
+ public void setSeconds (int seconds ) {
33
+ throw new IllegalArgumentException ("Seconds are not supported!" );
34
+ }
35
+
36
+ @ Override
37
+ public int getHours () {
38
+ return this .hours ;
39
+ }
40
+
41
+ @ Override
42
+ public int getMinutes () {
43
+ return this .minutes ;
44
+ }
45
+
46
+ @ Override
47
+ public int getSeconds () {
48
+ throw new IllegalArgumentException ("Seconds are not supported!" );
49
+ }
50
+
51
+ @ Override
52
+ public boolean check (IClock clock ) {
53
+ return (this .hours == clock .getHours () && this .minutes == clock .getMinutes ());
54
+ }
55
+
56
+ @ Override
57
+ public void printTime () {
58
+ System .out .println ("\t Alarm: " + this .hours + "h. " + this .minutes + "m." );
59
+ }
60
+ }
Original file line number Diff line number Diff line change
1
+ public class AlarmAdvanced extends Alarm {
2
+ int seconds ;
3
+
4
+ @ Override
5
+ public void setSeconds (int seconds ) {
6
+ try {
7
+ checkValue (seconds );
8
+ setMinutes (this .minutes + seconds / 60 );
9
+ this .seconds = seconds % 60 ;
10
+ } catch (IllegalArgumentException e ) {
11
+ System .out .println (e .getMessage ());
12
+ }
13
+ }
14
+
15
+ @ Override
16
+ public int getSeconds () {
17
+ return this .seconds ;
18
+ }
19
+
20
+ @ Override
21
+ public boolean check (IClock clock ) {
22
+ return (this .hours == clock .getHours () && this .minutes == clock .getMinutes () && this .seconds == clock .getSeconds ());
23
+ }
24
+
25
+ @ Override
26
+ public void printTime () {
27
+ System .out .println ("\t Alarm: " + this .hours + "h. " + this .minutes + "m. " + this .seconds + "s." );
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments