Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/Aircon.class | ||
/ColorDimmingLights.class | ||
/DimmingLights.class | ||
/Elevator.class | ||
/Lighting.class | ||
/OnOff.class | ||
/Refrigerator.class | ||
/Security.class | ||
/Speaker.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.opentutorials.iot; | ||
|
||
public class Aircon implements OnOff{ | ||
String _id; | ||
double _desiredTemperature = 26.0; | ||
|
||
public Aircon(String id) { | ||
this._id = id; | ||
} | ||
|
||
public boolean on() { | ||
System.out.println(this._id + " → Aircon on : " + this._desiredTemperature); | ||
return true; | ||
} | ||
|
||
public Boolean on(double desiredTemperature) { | ||
this._desiredTemperature = desiredTemperature; | ||
this.on(); | ||
return true; | ||
} | ||
|
||
public boolean off() { | ||
System.out.println("Aircon off"); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.opentutorials.iot; | ||
|
||
import java.awt.Color; | ||
|
||
public class ColorDimmingLights extends DimmingLights { | ||
|
||
double _bright = 0; | ||
Color _color; | ||
|
||
public ColorDimmingLights(String id) { | ||
super(id); | ||
this._color = Color.white; | ||
} | ||
|
||
public void setColor(Color color) { | ||
this._color = color; | ||
System.out.println(this._id + " → ColorDimmingLights color : "+color); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.opentutorials.iot; | ||
|
||
public class DimmingLights extends Lighting { | ||
|
||
double _bright; | ||
public DimmingLights(String _name) { | ||
super(_name); | ||
this._bright = 100; | ||
} | ||
|
||
public void setBright(double bright) { | ||
this._bright = bright; | ||
System.out.println(this._id + " → DimmingLights bright : "+bright); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.opentutorials.iot; | ||
|
||
public class Elevator { | ||
String _id; | ||
public Elevator(String id) { | ||
this._id = id; | ||
} | ||
|
||
public Boolean callForUp(int stopFloor) { | ||
System.out.println(this._id+" → Elevator callForUp stopFloor : "+stopFloor); | ||
return true; | ||
} | ||
|
||
public Boolean callForDown(int stopFloor) { | ||
System.out.println(this._id+" → Elevator callForDown : "+stopFloor); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.opentutorials.iot; | ||
|
||
import java.util.Random; | ||
|
||
public class Lighting implements OnOff{ | ||
String _id; | ||
public Lighting(String id){ | ||
this._id = id; | ||
} | ||
public boolean on() { | ||
System.out.println(this._id + " → Lighting on"); | ||
return true; | ||
} | ||
public boolean off() { | ||
System.out.println(this._id + " → Lighting off"); | ||
return true; | ||
} | ||
public Boolean isOn() { | ||
Random rand = new Random(); | ||
return rand.nextBoolean(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.opentutorials.iot; | ||
|
||
public interface OnOff { | ||
public boolean on(); | ||
public boolean off(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.opentutorials.iot; | ||
|
||
import java.util.Random; | ||
|
||
public class Refrigerator implements OnOff { | ||
String _id; | ||
public Refrigerator(String id) { | ||
this._id = id; | ||
} | ||
public int getItemNumber(String name) { | ||
Random rand = new Random(); | ||
int number = rand.nextInt(5); | ||
return number; | ||
} | ||
public boolean on() { | ||
System.out.println(this._id + " → Refrigerator on"); | ||
return true; | ||
} | ||
public boolean off() { | ||
System.out.println(this._id + " → Refrigerator off"); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.opentutorials.iot; | ||
|
||
import java.util.Random; | ||
|
||
public class Security implements OnOff{ | ||
String _id; | ||
public Security(String id) { | ||
this._id = id; | ||
} | ||
public boolean on() { | ||
System.out.println(this._id+" → Security on"); | ||
return true; | ||
} | ||
public boolean off() { | ||
System.out.println(this._id+" → Security off"); | ||
return true; | ||
} | ||
public int getExistPeopleNumber() { | ||
Random rand = new Random(); | ||
System.out.println(this._id+"\tSecurity exist people number : "+rand); | ||
return rand.nextInt(4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.opentutorials.iot; | ||
|
||
public class Speaker { | ||
String _id; | ||
public Speaker(String id) { | ||
this._id = id; | ||
} | ||
public Boolean makeVoice(String content) { | ||
System.out.println(this._id + " → Speaker on : " + content); | ||
return true; | ||
} | ||
} |