-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCeilingFan.java
45 lines (36 loc) · 1.01 KB
/
CeilingFan.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
package CeilingFan;
public class CeilingFan {
public static final int HIGH = 3;
public static final int MEDIUM = 2;
public static final int LOW = 1;
public static final int OFF = 0;
String location;
int speed;
public CeilingFan(String location) {
this.location = location;
}
// High speed
public void high() {
speed = HIGH;
System.out.println(location+"Fans are running at high speeds");
}
// Medium speed
public void medium() {
speed = MEDIUM;
System.out.println(location+"The fan is running at medium speed.");
}
// Low rotational speed
public void low() {
speed = LOW;
System.out.println(location+"Fans are running at low speeds");
}
// Close ceiling fan
public void off() {
speed = OFF;
System.out.println(location+"Fan off");
}
//Get the current ceiling fan speed
public int getSpeed(){
return speed;
}
}