Skip to content

Commit

Permalink
9.2. IOT 라이브러리 설치하기
Browse files Browse the repository at this point in the history
  • Loading branch information
egoing committed Sep 17, 2019
1 parent c531579 commit b14d380
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 0 deletions.
9 changes: 9 additions & 0 deletions 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
26 changes: 26 additions & 0 deletions 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;
}
}
20 changes: 20 additions & 0 deletions 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);
}

}
16 changes: 16 additions & 0 deletions 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);
}

}
18 changes: 18 additions & 0 deletions 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;
}
}
23 changes: 23 additions & 0 deletions 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();
}

}
6 changes: 6 additions & 0 deletions Programming/org/opentutorials/iot/OnOff.java
@@ -0,0 +1,6 @@
package org.opentutorials.iot;

public interface OnOff {
public boolean on();
public boolean off();
}
23 changes: 23 additions & 0 deletions 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;
}
}
23 changes: 23 additions & 0 deletions 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);
}
}
12 changes: 12 additions & 0 deletions 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;
}
}

0 comments on commit b14d380

Please sign in to comment.