-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
98 lines (71 loc) · 2.95 KB
/
Solution.java
File metadata and controls
98 lines (71 loc) · 2.95 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
package com.javarush.task.task13.task1317;
//The night is far gone, and the day is near. Let's therefore throw off the works of darkness,
//and let's put on the armor of light. (Romans 13:12)
/*
The weather is fine
*/
public class Solution {
public static void main(String[] args) {
System.out.println(new Today(WeatherType.CLOUDY));
System.out.println(new Today(WeatherType.FOGGY));
System.out.println(new Today(WeatherType.FROZEN));
}
static class Today implements Weather{
private String type;
Today(String type) {
this.type = type;
}
@Override
public String getWeatherType(){return type;}
@Override
public String toString() {
return String.format("%s for today", this.getWeatherType());
}
}
}
-------------------------------------------Weather.java-----------------------------------------------------------------
package com.javarush.task.task13.task1317;
public interface Weather extends WeatherType {
String getWeatherType();
}
------------------------------------------------------------------------------------------------------------------------
-------------------------------------------WeatherType.java-------------------------------------------------------------
package com.javarush.task.task13.task1317;
public interface WeatherType {
String CLOUDY = "Cloudy";
String FOGGY = "Foggy";
String FROZEN = "Frozen";
}
------------------------------------------------------------------------------------------------------------------------
/*
The weather is fine
1. В классе Today реализовать интерфейс Weather.
2. Подумай, как связан параметр type с методом getWeatherType().
3. Интерфейсы Weather и WeatherType уже реализованы в отдельных файлах.
Требования:
1. Интерфейс Weather должен быть реализован в классе Today.
2. В классе Today должен быть реализован метод getWeatherType объявленный в интерфейсе Weather.
3. Тип возвращаемого значения метода getWeatherType должен быть String.
4. Метод getWeatherType должен возвращать значение переменной type.
package com.javarush.task.task13.task1317;
/*
The weather is fine
*/
public class Solution {
public static void main(String[] args) {
System.out.println(new Today(WeatherType.CLOUDY));
System.out.println(new Today(WeatherType.FOGGY));
System.out.println(new Today(WeatherType.FROZEN));
}
static class Today {
private String type;
Today(String type) {
this.type = type;
}
@Override
public String toString() {
return String.format("%s for today", this.getWeatherType());
}
}
}
*/