-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRest.java
59 lines (49 loc) · 1.21 KB
/
Rest.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
50
51
52
53
54
55
56
57
58
59
package music;
/**
* Rest represents a pause in a piece of music.
*/
public class Rest implements Music {
private final double duration;
private void checkRep() {
assert duration >= 0;
}
/**
* Make a Rest that lasts for duration beats.
* @param duration duration in beats, must be >= 0
*/
public Rest(double duration) {
this.duration = duration;
checkRep();
}
/**
* @return duration of this rest
*/
@Override
public double duration() {
return duration;
}
/**
* Play this rest.
*/
@Override
public void play(SequencePlayer player, double atBeat) {
return;
}
@Override
public int hashCode() {
long durationBits = Double.doubleToLongBits(duration);
return (int) (durationBits ^ (durationBits >>> 32));
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
final Rest other = (Rest) obj;
return duration == other.duration;
}
@Override
public String toString() {
return "." + duration;
}
}