44
55public class Clock {
66 protected String type ;
7- protected String brand ;
8- protected Integer cost ;
9- protected Integer hours , minutes ;
7+ private String brand ;
8+ private int cost ;
9+ protected int hours , minutes ;
1010
11- public Clock (String brand , Integer cost , Integer hours , Integer minutes ) throws Exception {
11+ public Clock (String brand , int cost , int hours , int minutes ) throws Exception {
1212 this .type = "Common" ;
1313 this .brand = brand ;
1414 this .cost = cost ;
@@ -17,7 +17,7 @@ public Clock(String brand, Integer cost, Integer hours, Integer minutes) throws
1717 setMinutes (minutes );
1818 }
1919
20- protected void checkValue (Integer value ) throws Exception {
20+ protected void checkValue (int value ) throws Exception {
2121 if (value < 0 )
2222 throw new Exception ("Value must be not negative!" );
2323 }
@@ -26,11 +26,12 @@ public void setBrand(String brand) {
2626 this .brand = brand ;
2727 }
2828
29- public void setCost (Integer cost ) {
29+ public void setCost (int cost ) throws Exception {
30+ checkValue (cost );
3031 this .cost = cost ;
3132 }
3233
33- public void setHours (Integer hours ) throws Exception {
34+ public void setHours (int hours ) throws Exception {
3435 try {
3536 checkValue (hours );
3637 this .hours = hours % 24 ;
@@ -39,7 +40,7 @@ public void setHours(Integer hours) throws Exception {
3940 }
4041 }
4142
42- public void setMinutes (Integer minutes ) throws Exception {
43+ public void setMinutes (int minutes ) throws Exception {
4344 try {
4445 checkValue (minutes );
4546 setHours (this .hours + minutes / 60 );
@@ -49,23 +50,23 @@ public void setMinutes(Integer minutes) throws Exception {
4950 }
5051 }
5152
52- public Integer getHours () {
53+ public int getHours () {
5354 return this .hours ;
5455 }
5556
56- public Integer getMinutes () {
57+ public int getMinutes () {
5758 return this .minutes ;
5859 }
5960
6061 public String getBrand () {
6162 return this .brand ;
6263 }
6364
64- public Integer getCost () {
65+ public int getCost () {
6566 return this .cost ;
6667 }
6768
68- public void increaseTime (Integer value ) throws Exception {
69+ public void increaseTime (int value ) throws Exception {
6970 try {
7071 checkValue (value );
7172 setMinutes ((this .minutes + value ));
@@ -85,16 +86,16 @@ public void printTime() {
8586
8687
8788 public static class AdvancedClock extends Clock {
88- private Integer seconds ;
89+ private int seconds ;
8990
90- public AdvancedClock (String brand , Integer cost , Integer hours , Integer minutes , Integer seconds ) throws Exception {
91+ public AdvancedClock (String brand , int cost , int hours , int minutes , int seconds ) throws Exception {
9192 super (brand , cost , hours , minutes );
9293
9394 this .type = "Advanced" ;
9495 setSeconds (seconds );
9596 }
9697
97- public void setSeconds (Integer seconds ) throws Exception {
98+ public void setSeconds (int seconds ) throws Exception {
9899 try {
99100 checkValue (seconds );
100101 setMinutes (this .minutes + seconds / 60 );
@@ -104,12 +105,12 @@ public void setSeconds(Integer seconds) throws Exception {
104105 }
105106 }
106107
107- public Integer getSeconds () {
108+ public int getSeconds () {
108109 return this .seconds ;
109110 }
110111
111112 @ Override
112- public void increaseTime (Integer value ) throws Exception {
113+ public void increaseTime (int value ) throws Exception {
113114 try {
114115 checkValue (value );
115116 setSeconds ((this .seconds + value ));
0 commit comments