From b14d380976e09d525c44726f6337cc726e28425f Mon Sep 17 00:00:00 2001 From: egoing Date: Wed, 4 Sep 2019 00:08:12 +0900 Subject: [PATCH] =?UTF-8?q?9.2.=20IOT=20=EB=9D=BC=EC=9D=B4=EB=B8=8C?= =?UTF-8?q?=EB=9F=AC=EB=A6=AC=20=EC=84=A4=EC=B9=98=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programming/org/opentutorials/iot/.gitignore | 9 +++++++ Programming/org/opentutorials/iot/Aircon.java | 26 +++++++++++++++++++ .../opentutorials/iot/ColorDimmingLights.java | 20 ++++++++++++++ .../org/opentutorials/iot/DimmingLights.java | 16 ++++++++++++ .../org/opentutorials/iot/Elevator.java | 18 +++++++++++++ .../org/opentutorials/iot/Lighting.java | 23 ++++++++++++++++ Programming/org/opentutorials/iot/OnOff.java | 6 +++++ .../org/opentutorials/iot/Refrigerator.java | 23 ++++++++++++++++ .../org/opentutorials/iot/Security.java | 23 ++++++++++++++++ .../org/opentutorials/iot/Speaker.java | 12 +++++++++ 10 files changed, 176 insertions(+) create mode 100644 Programming/org/opentutorials/iot/.gitignore create mode 100644 Programming/org/opentutorials/iot/Aircon.java create mode 100644 Programming/org/opentutorials/iot/ColorDimmingLights.java create mode 100644 Programming/org/opentutorials/iot/DimmingLights.java create mode 100644 Programming/org/opentutorials/iot/Elevator.java create mode 100644 Programming/org/opentutorials/iot/Lighting.java create mode 100644 Programming/org/opentutorials/iot/OnOff.java create mode 100644 Programming/org/opentutorials/iot/Refrigerator.java create mode 100644 Programming/org/opentutorials/iot/Security.java create mode 100644 Programming/org/opentutorials/iot/Speaker.java diff --git a/Programming/org/opentutorials/iot/.gitignore b/Programming/org/opentutorials/iot/.gitignore new file mode 100644 index 0000000..38f478d --- /dev/null +++ b/Programming/org/opentutorials/iot/.gitignore @@ -0,0 +1,9 @@ +/Aircon.class +/ColorDimmingLights.class +/DimmingLights.class +/Elevator.class +/Lighting.class +/OnOff.class +/Refrigerator.class +/Security.class +/Speaker.class diff --git a/Programming/org/opentutorials/iot/Aircon.java b/Programming/org/opentutorials/iot/Aircon.java new file mode 100644 index 0000000..1b77443 --- /dev/null +++ b/Programming/org/opentutorials/iot/Aircon.java @@ -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; + } +} \ No newline at end of file diff --git a/Programming/org/opentutorials/iot/ColorDimmingLights.java b/Programming/org/opentutorials/iot/ColorDimmingLights.java new file mode 100644 index 0000000..e2b8d8e --- /dev/null +++ b/Programming/org/opentutorials/iot/ColorDimmingLights.java @@ -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); + } + +} diff --git a/Programming/org/opentutorials/iot/DimmingLights.java b/Programming/org/opentutorials/iot/DimmingLights.java new file mode 100644 index 0000000..9331825 --- /dev/null +++ b/Programming/org/opentutorials/iot/DimmingLights.java @@ -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); + } + +} diff --git a/Programming/org/opentutorials/iot/Elevator.java b/Programming/org/opentutorials/iot/Elevator.java new file mode 100644 index 0000000..2d2437a --- /dev/null +++ b/Programming/org/opentutorials/iot/Elevator.java @@ -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; + } +} \ No newline at end of file diff --git a/Programming/org/opentutorials/iot/Lighting.java b/Programming/org/opentutorials/iot/Lighting.java new file mode 100644 index 0000000..9368adb --- /dev/null +++ b/Programming/org/opentutorials/iot/Lighting.java @@ -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(); + } + +} \ No newline at end of file diff --git a/Programming/org/opentutorials/iot/OnOff.java b/Programming/org/opentutorials/iot/OnOff.java new file mode 100644 index 0000000..5a1b48c --- /dev/null +++ b/Programming/org/opentutorials/iot/OnOff.java @@ -0,0 +1,6 @@ +package org.opentutorials.iot; + +public interface OnOff { + public boolean on(); + public boolean off(); +} diff --git a/Programming/org/opentutorials/iot/Refrigerator.java b/Programming/org/opentutorials/iot/Refrigerator.java new file mode 100644 index 0000000..30002db --- /dev/null +++ b/Programming/org/opentutorials/iot/Refrigerator.java @@ -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; + } +} diff --git a/Programming/org/opentutorials/iot/Security.java b/Programming/org/opentutorials/iot/Security.java new file mode 100644 index 0000000..397845b --- /dev/null +++ b/Programming/org/opentutorials/iot/Security.java @@ -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); + } +} diff --git a/Programming/org/opentutorials/iot/Speaker.java b/Programming/org/opentutorials/iot/Speaker.java new file mode 100644 index 0000000..425fa45 --- /dev/null +++ b/Programming/org/opentutorials/iot/Speaker.java @@ -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; + } +} \ No newline at end of file