├── .gitignore └── org └── opentutorials └── iot ├── .gitignore ├── Aircon.java ├── ColorDimmingLights.java ├── DimmingLights.java ├── Elevator.java ├── Lighting.java ├── OnOff.java ├── Refrigerator.java ├── Security.java └── Speaker.java /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | *.class 4 | -------------------------------------------------------------------------------- /org/opentutorials/iot/.gitignore: -------------------------------------------------------------------------------- 1 | /Aircon.class 2 | /ColorDimmingLights.class 3 | /DimmingLights.class 4 | /Elevator.class 5 | /Lighting.class 6 | /OnOff.class 7 | /Refrigerator.class 8 | /Security.class 9 | /Speaker.class 10 | -------------------------------------------------------------------------------- /org/opentutorials/iot/Aircon.java: -------------------------------------------------------------------------------- 1 | package org.opentutorials.iot; 2 | 3 | public class Aircon implements OnOff{ 4 | String _id; 5 | double _desiredTemperature = 26.0; 6 | 7 | public Aircon(String id) { 8 | this._id = id; 9 | } 10 | 11 | public boolean on() { 12 | System.out.println(this._id + " -> Aircon on : " + this._desiredTemperature); 13 | return true; 14 | } 15 | 16 | public Boolean on(double desiredTemperature) { 17 | this._desiredTemperature = desiredTemperature; 18 | this.on(); 19 | return true; 20 | } 21 | 22 | public boolean off() { 23 | System.out.println("Aircon off"); 24 | return true; 25 | } 26 | } -------------------------------------------------------------------------------- /org/opentutorials/iot/ColorDimmingLights.java: -------------------------------------------------------------------------------- 1 | package org.opentutorials.iot; 2 | 3 | import java.awt.Color; 4 | 5 | public class ColorDimmingLights extends DimmingLights { 6 | 7 | double _bright = 0; 8 | Color _color; 9 | 10 | public ColorDimmingLights(String id) { 11 | super(id); 12 | this._color = Color.white; 13 | } 14 | 15 | public void setColor(Color color) { 16 | this._color = color; 17 | System.out.println(this._id + " -> ColorDimmingLights color : "+color); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /org/opentutorials/iot/DimmingLights.java: -------------------------------------------------------------------------------- 1 | package org.opentutorials.iot; 2 | 3 | public class DimmingLights extends Lighting { 4 | 5 | double _bright; 6 | public DimmingLights(String _name) { 7 | super(_name); 8 | this._bright = 100; 9 | } 10 | 11 | public void setBright(double bright) { 12 | this._bright = bright; 13 | System.out.println(this._id + " -> DimmingLights bright : "+bright); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /org/opentutorials/iot/Elevator.java: -------------------------------------------------------------------------------- 1 | package org.opentutorials.iot; 2 | 3 | public class Elevator { 4 | String _id; 5 | public Elevator(String id) { 6 | this._id = id; 7 | } 8 | 9 | public Boolean callForUp(int stopFloor) { 10 | System.out.println(this._id+" -> Elevator callForUp stopFloor : "+stopFloor); 11 | return true; 12 | } 13 | 14 | public Boolean callForDown(int stopFloor) { 15 | System.out.println(this._id+" -> Elevator callForDown : "+stopFloor); 16 | return true; 17 | } 18 | } -------------------------------------------------------------------------------- /org/opentutorials/iot/Lighting.java: -------------------------------------------------------------------------------- 1 | package org.opentutorials.iot; 2 | 3 | import java.util.Random; 4 | 5 | public class Lighting implements OnOff{ 6 | String _id; 7 | public Lighting(String id){ 8 | this._id = id; 9 | } 10 | public boolean on() { 11 | System.out.println(this._id + " -> Lighting on"); 12 | return true; 13 | } 14 | public boolean off() { 15 | System.out.println(this._id + " -> Lighting off"); 16 | return true; 17 | } 18 | public Boolean isOn() { 19 | Random rand = new Random(); 20 | return rand.nextBoolean(); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /org/opentutorials/iot/OnOff.java: -------------------------------------------------------------------------------- 1 | package org.opentutorials.iot; 2 | 3 | public interface OnOff { 4 | public boolean on(); 5 | public boolean off(); 6 | } 7 | -------------------------------------------------------------------------------- /org/opentutorials/iot/Refrigerator.java: -------------------------------------------------------------------------------- 1 | package org.opentutorials.iot; 2 | 3 | import java.util.Random; 4 | 5 | public class Refrigerator implements OnOff { 6 | String _id; 7 | public Refrigerator(String id) { 8 | this._id = id; 9 | } 10 | public int getItemNumber(String name) { 11 | Random rand = new Random(); 12 | int number = rand.nextInt(5); 13 | return number; 14 | } 15 | public boolean on() { 16 | System.out.println(this._id + " -> Refrigerator on"); 17 | return true; 18 | } 19 | public boolean off() { 20 | System.out.println(this._id + " -> Refrigerator off"); 21 | return true; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /org/opentutorials/iot/Security.java: -------------------------------------------------------------------------------- 1 | package org.opentutorials.iot; 2 | 3 | import java.util.Random; 4 | 5 | public class Security implements OnOff{ 6 | String _id; 7 | public Security(String id) { 8 | this._id = id; 9 | } 10 | public boolean on() { 11 | System.out.println(this._id+" -> Security on"); 12 | return true; 13 | } 14 | public boolean off() { 15 | System.out.println(this._id+" -> Security off"); 16 | return true; 17 | } 18 | public int getExistPeopleNumber() { 19 | Random rand = new Random(); 20 | System.out.println(this._id+"\tSecurity exist people number : "+rand); 21 | return rand.nextInt(4); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /org/opentutorials/iot/Speaker.java: -------------------------------------------------------------------------------- 1 | package org.opentutorials.iot; 2 | 3 | import java.util.Random; 4 | 5 | public class Speaker { 6 | String _id; 7 | public Speaker(String id) { 8 | this._id = id; 9 | } 10 | public Boolean makeVoice(String content) { 11 | System.out.println(this._id + " -> Speaker on : " + content); 12 | return true; 13 | } 14 | } --------------------------------------------------------------------------------