-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSensor.java
46 lines (34 loc) · 884 Bytes
/
Sensor.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
// Example of 4.3 from EDX java part:1
class Sensor
{
private double value;
public Sensor(double value)
{
this.value = value;
}
public void setValue(double value)
{
this.value = value;
}
public double getValue()
{
return value;
}
public void clearValue()
{
value = 0;
}
}
class TestSensor
{
public static void main(String []args)
{
Sensor a = new Sensor(0.0);
Sensor b = new Sensor(10.0);
System.out.println("(" +a.getValue()+" , "+b.getValue()+")");
a.clearValue();
b.clearValue();
a.setValue(100.0);
System.out.println("("+a.getValue()+" , "+b.getValue()+")");
}
}