forked from prmr/DesignBook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntroducedShow.java
49 lines (41 loc) · 1.1 KB
/
IntroducedShow.java
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
package chapter6;
import java.util.Objects;
public class IntroducedShow implements Show
{
private final Show aShow;
private final String aSpeaker;
private final int aSpeechTime;
public IntroducedShow(String pName, int pTime, Show pShow )
{
aShow = pShow;
aSpeaker = pName;
aSpeechTime = pTime;
}
@Override
public String description() { return "[" + aSpeaker + " introduces " + aShow.description() + "]"; }
@Override
public int runningTime() { return aSpeechTime + aShow.runningTime(); }
@Override
public IntroducedShow copy()
{
return new IntroducedShow(aSpeaker, aSpeechTime, aShow.copy());
}
@Override
public int hashCode()
{
return Objects.hash(aShow, aSpeaker, aSpeechTime);
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
IntroducedShow other = (IntroducedShow) obj;
return Objects.equals(aShow, other.aShow) && Objects.equals(aSpeaker, other.aSpeaker)
&& aSpeechTime == other.aSpeechTime;
}
}