-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCandle.java
More file actions
52 lines (28 loc) · 948 Bytes
/
Copy pathCandle.java
File metadata and controls
52 lines (28 loc) · 948 Bytes
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
public class Candle extends Thing{
private final String state ;
public Candle(){
this.state = "Candle flickers.";
}
public Candle(String state){
this.state = state;
}
public Candle tick(){
if(state == "Candle flickers."){
return new Candle("Candle is getting shorter.");
}
else if(state == "Candle is getting shorter."){
return new Candle("Candle is about to burn out.");
}
else if(state == "Candle is about to burn out."){
return new Candle("Candle has burned out.");
}
else if(state == "Candle has burned out."){
return new Candle("Candle has burned out.");
}
return null;
}
@Override
public String toString(){
return this.state;
}
}