-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAC.java
More file actions
51 lines (36 loc) · 750 Bytes
/
Copy pathAC.java
File metadata and controls
51 lines (36 loc) · 750 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
50
51
public class AC {
public static void main(String[] args) {
AirConditioner ac= new AirConditioner();
ac.setTemp(25.05f);
System.out.println("Current temp is: "+ac.getTemp());
ac.getTemp();
ac.increaseTemp(5);
System.out.println("Increased temp by: "+ac.temp);
ac.getTemp();
ac.decreaseTemp(6);
System.out.println("Decreased temp by: "+ac.temp);
ac.getTemp();
}
}
class AirConditioner
{
float temp;
int status;
float getTemp()
{
return temp;
}
void setTemp(float t)
{
System.out.println("Temp is set to : "+t);
temp = t;
}
void increaseTemp(int cnt)
{
temp = temp + cnt;
}
void decreaseTemp(int cnt)
{
temp = temp - cnt;
}
}