├── .gitattributes ├── .gitignore ├── Data_and_operation ├── Casting.java ├── Datatype.java ├── Letter.java ├── Number.java ├── StringApp.java ├── StringOperation.java └── Variable.java ├── HelloWorld └── HelloWorldApp.java ├── HelloWorldGUI └── HelloWorldGUIApp.java ├── HelloWorld_IOT ├── .settings │ └── org.eclipse.jdt.core.prefs └── HelloWorldRaspberryPi.java ├── MyApp ├── AccountingApp.java ├── AccountingArrayApp.java ├── AccountingArrayLoopApp.java ├── AccountingClassApp.java ├── AccountingIFApp.java ├── AccountingIFUnder10000App.java └── AccountingMethodApp.java └── Programming ├── .gitignore ├── .settings └── .gitignore ├── ClassApp.java ├── InstanceApp.java ├── OkJavaGoInHome.java ├── OkJavaGoInHomeInput.java ├── Program.java └── org └── opentutorials └── iot ├── .gitignore ├── Aircon.java ├── ColorDimmingLights.java ├── DimmingLights.java ├── Elevator.java ├── Lighting.java ├── OnOff.java ├── Refrigerator.java ├── Security.java └── Speaker.java /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | .classpath 25 | .project 26 | -------------------------------------------------------------------------------- /Data_and_operation/Casting.java: -------------------------------------------------------------------------------- 1 | 2 | public class Casting { 3 | 4 | public static void main(String[] args) { 5 | 6 | double a = 1.1; 7 | double b = 1; 8 | double b2 = (double) 1; 9 | 10 | System.out.println(b); 11 | 12 | // int c = 1.1; 13 | double d = 1.1; 14 | int e = (int) 1.1; 15 | System.out.println(e); 16 | 17 | // 1 to String 18 | String f = Integer.toString(1); 19 | System.out.println(f.getClass()); 20 | 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Data_and_operation/Datatype.java: -------------------------------------------------------------------------------- 1 | public class Datatype{ 2 | public static void main(String[] args) { 3 | System.out.println(6); // Number 4 | System.out.println("six"); // String 5 | 6 | System.out.println("6"); // String 6 7 | 8 | System.out.println(6+6); // 12 9 | System.out.println("6"+"6"); // 66 10 | 11 | System.out.println(6*6); // 36 12 | // System.out.println("6"*"6"); 13 | 14 | System.out.println("1111".length()); // 4 15 | // System.out.println(1111.length()); 16 | 17 | System.out.println("Hello World"); //String 문자열 18 | System.out.println('H'); //Char 문자 19 | System.out.println("H"); 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /Data_and_operation/Letter.java: -------------------------------------------------------------------------------- 1 | 2 | public class Letter { 3 | 4 | public static void main(String[] args) { 5 | String name = "leezche"; 6 | System.out.println("Hello, "+name+" ... "+name+" ... egoing ... bye"); 7 | 8 | double VAT = 10.0; 9 | System.out.println(VAT); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Data_and_operation/Number.java: -------------------------------------------------------------------------------- 1 | 2 | public class Number { 3 | 4 | public static void main(String[] args) { 5 | // Operator 6 | System.out.println(6 + 2); // 8 7 | System.out.println(6 - 2); // 4 8 | System.out.println(6 * 2); // 12 9 | System.out.println(6 / 2); // 3 10 | 11 | System.out.println(Math.PI); // 3.141592653589793 12 | System.out.println(Math.floor(Math.PI)); 13 | System.out.println(Math.ceil(Math.PI)); 14 | 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Data_and_operation/StringApp.java: -------------------------------------------------------------------------------- 1 | 2 | public class StringApp { 3 | 4 | public static void main(String[] args) { 5 | 6 | // Character VS String 7 | System.out.println("Hello World"); // String 8 | System.out.println('H'); // Character 9 | System.out.println("H"); 10 | 11 | System.out.println("Hello " 12 | + "World"); 13 | 14 | // new line 15 | System.out.println("Hello \nWorld"); 16 | 17 | // escape 18 | System.out.println("Hello \"World\"");// Hello "World" 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Data_and_operation/StringOperation.java: -------------------------------------------------------------------------------- 1 | 2 | public class StringOperation { 3 | 4 | public static void main(String[] args) { 5 | 6 | System.out.println("Hello World".length()); // 11 7 | System.out.println("Hello, [[[name]]] ... bye. ".replace("[[[name]]]", "duru")); 8 | 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Data_and_operation/Variable.java: -------------------------------------------------------------------------------- 1 | 2 | public class Variable { 3 | 4 | public static void main(String[] args) { 5 | 6 | int a = 1; // Number -> integer ... -2, -1 , 0, 1, 2 ... 7 | System.out.println(a); 8 | 9 | double b = 1.1; // real number -> double ... -2.0, -1.0, 0, 1.0, 2.0 ... 10 | System.out.println(b); 11 | 12 | String c = "Hello World"; 13 | System.out.println(c); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /HelloWorld/HelloWorldApp.java: -------------------------------------------------------------------------------- 1 | public class HelloWorldApp{ 2 | public static void main(String[] args) { 3 | System.out.println("Hello world!!"); 4 | } 5 | } -------------------------------------------------------------------------------- /HelloWorldGUI/HelloWorldGUIApp.java: -------------------------------------------------------------------------------- 1 | import javax.swing.*; 2 | import java.awt.Dimension; 3 | import java.awt.Toolkit; 4 | public class HelloWorldGUIApp{ 5 | public static void main(String[] args){ 6 | javax.swing.SwingUtilities.invokeLater(new Runnable() { 7 | public void run() { 8 | JFrame frame = new JFrame("HelloWorld GUI"); 9 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 10 | frame.setPreferredSize(new Dimension(800, 300)); 11 | JLabel label = new JLabel("Hello World!!", SwingConstants.RIGHT); 12 | frame.getContentPane().add(label); 13 | Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); 14 | frame.setLocation(dim.width/2-400/2, dim.height/2-300/2); 15 | 16 | frame.pack(); 17 | frame.setVisible(true); 18 | } 19 | }); 20 | } 21 | } -------------------------------------------------------------------------------- /HelloWorld_IOT/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=9 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.release=enabled 12 | org.eclipse.jdt.core.compiler.source=9 13 | -------------------------------------------------------------------------------- /HelloWorld_IOT/HelloWorldRaspberryPi.java: -------------------------------------------------------------------------------- 1 | import com.pi4j.io.gpio.GpioController; 2 | import com.pi4j.io.gpio.GpioFactory; 3 | import com.pi4j.io.gpio.GpioPinDigitalOutput; 4 | import com.pi4j.io.gpio.PinState; 5 | import com.pi4j.io.gpio.RaspiPin; 6 | 7 | public class HelloWorldRaspberryPi { 8 | 9 | public static void main(String[] args) throws InterruptedException { 10 | 11 | final GpioController gpio = GpioFactory.getInstance(); 12 | final GpioPinDigitalOutput pin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_01, "PinLED", PinState.LOW); 13 | final int SHORT_INTERVAL = 200; 14 | final int LONG_INTERVAL = SHORT_INTERVAL * 3; 15 | final int LETTER_INTERVAL = SHORT_INTERVAL * 7; 16 | 17 | while (true) { 18 | // H 19 | pin.high(); 20 | Thread.sleep(SHORT_INTERVAL); 21 | pin.low(); 22 | Thread.sleep(SHORT_INTERVAL); 23 | pin.high(); 24 | Thread.sleep(SHORT_INTERVAL); 25 | pin.low(); 26 | Thread.sleep(SHORT_INTERVAL); 27 | pin.high(); 28 | Thread.sleep(SHORT_INTERVAL); 29 | pin.low(); 30 | Thread.sleep(SHORT_INTERVAL); 31 | pin.high(); 32 | Thread.sleep(SHORT_INTERVAL); 33 | pin.low(); 34 | Thread.sleep(LETTER_INTERVAL); 35 | 36 | // e 37 | pin.high(); 38 | Thread.sleep(SHORT_INTERVAL); 39 | pin.low(); 40 | Thread.sleep(LETTER_INTERVAL); 41 | 42 | // l 43 | pin.high(); 44 | Thread.sleep(SHORT_INTERVAL); 45 | pin.low(); 46 | Thread.sleep(SHORT_INTERVAL); 47 | 48 | pin.high(); 49 | Thread.sleep(LONG_INTERVAL); 50 | pin.low(); 51 | Thread.sleep(SHORT_INTERVAL); 52 | 53 | pin.high(); 54 | Thread.sleep(SHORT_INTERVAL); 55 | pin.low(); 56 | Thread.sleep(SHORT_INTERVAL); 57 | pin.high(); 58 | Thread.sleep(SHORT_INTERVAL); 59 | pin.low(); 60 | Thread.sleep(LONG_INTERVAL); 61 | 62 | // l 63 | pin.high(); 64 | Thread.sleep(SHORT_INTERVAL); 65 | pin.low(); 66 | Thread.sleep(SHORT_INTERVAL); 67 | 68 | pin.high(); 69 | Thread.sleep(LONG_INTERVAL); 70 | pin.low(); 71 | Thread.sleep(SHORT_INTERVAL); 72 | 73 | pin.high(); 74 | Thread.sleep(SHORT_INTERVAL); 75 | pin.low(); 76 | Thread.sleep(SHORT_INTERVAL); 77 | pin.high(); 78 | Thread.sleep(SHORT_INTERVAL); 79 | pin.low(); 80 | Thread.sleep(LONG_INTERVAL); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /MyApp/AccountingApp.java: -------------------------------------------------------------------------------- 1 | 2 | public class AccountingApp { 3 | 4 | public static void main(String[] args) { 5 | 6 | double valueOfSupply = Double.parseDouble(args[0]); 7 | double vatRate = 0.1; 8 | double expenseRate = 0.3; 9 | double vat = valueOfSupply * vatRate; 10 | double total = valueOfSupply + vat; 11 | double expense = valueOfSupply * expenseRate; 12 | double income = valueOfSupply - expense; 13 | double dividend1 = income * 0.5; 14 | double dividend2 = income * 0.3; 15 | double dividend3 = income * 0.2; 16 | 17 | System.out.println("Value of supply : " + valueOfSupply); 18 | System.out.println("VAT : " + vat); 19 | System.out.println("Total : " + total); 20 | System.out.println("Expense : " + expense); 21 | System.out.println("Income : " + income); 22 | System.out.println("Dividend 1 : " + dividend1); 23 | System.out.println("Dividend 2 : " + dividend2); 24 | System.out.println("Dividend 3 : " + dividend3); 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /MyApp/AccountingArrayApp.java: -------------------------------------------------------------------------------- 1 | 2 | public class AccountingArrayApp { 3 | 4 | public static void main(String[] args) { 5 | 6 | double valueOfSupply = Double.parseDouble(args[0]); 7 | double vatRate = 0.1; 8 | double expenseRate = 0.3; 9 | double vat = valueOfSupply * vatRate; 10 | double total = valueOfSupply + vat; 11 | double expense = valueOfSupply * expenseRate; 12 | double income = valueOfSupply - expense; 13 | 14 | double[] dividendRates = new double[3]; 15 | dividendRates[0] = 0.5; 16 | dividendRates[1] = 0.3; 17 | dividendRates[2] = 0.2; 18 | 19 | double dividend1 = income * dividendRates[0]; 20 | double dividend2 = income * dividendRates[1]; 21 | double dividend3 = income * dividendRates[2]; 22 | 23 | System.out.println("Value of supply : " + valueOfSupply); 24 | System.out.println("VAT : " + vat); 25 | System.out.println("Total : " + total); 26 | System.out.println("Expense : " + expense); 27 | System.out.println("Income : " + income); 28 | System.out.println("Dividend 1 : " + dividend1); 29 | System.out.println("Dividend 2 : " + dividend2); 30 | System.out.println("Dividend 3 : " + dividend3); 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /MyApp/AccountingArrayLoopApp.java: -------------------------------------------------------------------------------- 1 | 2 | public class AccountingArrayLoopApp { 3 | 4 | public static void main(String[] args) { 5 | 6 | double valueOfSupply = Double.parseDouble(args[0]); 7 | double vatRate = 0.1; 8 | double expenseRate = 0.3; 9 | double vat = valueOfSupply * vatRate; 10 | double total = valueOfSupply + vat; 11 | double expense = valueOfSupply * expenseRate; 12 | double income = valueOfSupply - expense; 13 | 14 | 15 | 16 | System.out.println("Value of supply : " + valueOfSupply); 17 | System.out.println("VAT : " + vat); 18 | System.out.println("Total : " + total); 19 | System.out.println("Expense : " + expense); 20 | System.out.println("Income : " + income); 21 | 22 | double[] dividendRates = new double[3]; 23 | dividendRates[0] = 0.5; 24 | dividendRates[1] = 0.3; 25 | dividendRates[2] = 0.2; 26 | 27 | 28 | int i = 0; 29 | while(i < dividendRates.length) { 30 | System.out.println("Dividend : " + (income*dividendRates[i]) ); 31 | i = i + 1; 32 | } 33 | 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /MyApp/AccountingClassApp.java: -------------------------------------------------------------------------------- 1 | class Accounting{ 2 | public double valueOfSupply; 3 | public double vatRate; 4 | public double expenseRate; 5 | public void print() { 6 | System.out.println("Value of supply : " + valueOfSupply); 7 | System.out.println("VAT : " + getVAT()); 8 | System.out.println("Total : " + getTotal()); 9 | System.out.println("Expense : " + getExpense()); 10 | System.out.println("Income : " + getIncome()); 11 | System.out.println("Dividend 1 : " + getDiviend1()); 12 | System.out.println("Dividend 2 : " + getDiviend2()); 13 | System.out.println("Dividend 3 : " + getDiviend3()); 14 | } 15 | 16 | public double getDiviend1() { 17 | return getIncome() * 0.5; 18 | } 19 | public double getDiviend2() { 20 | return getIncome() * 0.3; 21 | } 22 | public double getDiviend3() { 23 | return getIncome() * 0.2; 24 | } 25 | 26 | public double getIncome() { 27 | return valueOfSupply - getExpense(); 28 | } 29 | 30 | public double getExpense() { 31 | return valueOfSupply * expenseRate; 32 | } 33 | 34 | public double getTotal() { 35 | return valueOfSupply + getVAT(); 36 | } 37 | 38 | public double getVAT() { 39 | return valueOfSupply * vatRate; 40 | } 41 | } 42 | public class AccountingClassApp { 43 | 44 | public static void main(String[] args) { 45 | // instance 46 | Accounting a1 = new Accounting(); 47 | a1.valueOfSupply = 10000.0; 48 | a1.vatRate = 0.1; 49 | a1.expenseRate = 0.3; 50 | a1.print(); 51 | 52 | Accounting a2 = new Accounting(); 53 | a2.valueOfSupply = 20000.0; 54 | a2.vatRate = 0.05; 55 | a2.expenseRate = 0.2; 56 | a2.print(); 57 | 58 | a1.print(); 59 | } 60 | } 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /MyApp/AccountingIFApp.java: -------------------------------------------------------------------------------- 1 | 2 | public class AccountingIFApp { 3 | 4 | public static void main(String[] args) { 5 | 6 | double valueOfSupply = Double.parseDouble(args[0]); 7 | double vatRate = 0.1; 8 | double expenseRate = 0.3; 9 | double vat = valueOfSupply * vatRate; 10 | double total = valueOfSupply + vat; 11 | double expense = valueOfSupply * expenseRate; 12 | double income = valueOfSupply - expense; 13 | 14 | double dividend1; 15 | double dividend2; 16 | double dividend3; 17 | 18 | if(income > 10000.0) { 19 | dividend1 = income * 0.5; 20 | dividend2 = income * 0.3; 21 | dividend3 = income * 0.2; 22 | } else { 23 | dividend1 = income * 1.0; 24 | dividend2 = income * 0; 25 | dividend3 = income * 0; 26 | } 27 | 28 | System.out.println("Value of supply : " + valueOfSupply); 29 | System.out.println("VAT : " + vat); 30 | System.out.println("Total : " + total); 31 | System.out.println("Expense : " + expense); 32 | System.out.println("Income : " + income); 33 | System.out.println("Dividend 1 : " + dividend1); 34 | System.out.println("Dividend 2 : " + dividend2); 35 | System.out.println("Dividend 3 : " + dividend3); 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /MyApp/AccountingIFUnder10000App.java: -------------------------------------------------------------------------------- 1 | 2 | public class AccountingIFUnder10000App { 3 | 4 | public static void main(String[] args) { 5 | 6 | double valueOfSupply = Double.parseDouble(args[0]); 7 | double vatRate = 0.1; 8 | double expenseRate = 0.3; 9 | double vat = valueOfSupply * vatRate; 10 | double total = valueOfSupply + vat; 11 | double expense = valueOfSupply * expenseRate; 12 | double income = valueOfSupply - expense; 13 | 14 | double dividend1 = income * 1; 15 | double dividend2 = income * 0; 16 | double dividend3 = income * 0; 17 | 18 | System.out.println("Value of supply : " + valueOfSupply); 19 | System.out.println("VAT : " + vat); 20 | System.out.println("Total : " + total); 21 | System.out.println("Expense : " + expense); 22 | System.out.println("Income : " + income); 23 | System.out.println("Dividend 1 : " + dividend1); 24 | System.out.println("Dividend 2 : " + dividend2); 25 | System.out.println("Dividend 3 : " + dividend3); 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /MyApp/AccountingMethodApp.java: -------------------------------------------------------------------------------- 1 | 2 | public class AccountingMethodApp { 3 | public static double valueOfSupply; 4 | public static double vatRate; 5 | public static double expenseRate; 6 | public static void main(String[] args) { 7 | valueOfSupply = 10000.0; 8 | vatRate = 0.1; 9 | expenseRate = 0.3; 10 | print(); 11 | } 12 | 13 | public static void print() { 14 | System.out.println("Value of supply : " + valueOfSupply); 15 | System.out.println("VAT : " + getVAT()); 16 | System.out.println("Total : " + getTotal()); 17 | System.out.println("Expense : " + getExpense()); 18 | System.out.println("Income : " + getIncome()); 19 | System.out.println("Dividend 1 : " + getDiviend1()); 20 | System.out.println("Dividend 2 : " + getDiviend2()); 21 | System.out.println("Dividend 3 : " + getDiviend3()); 22 | } 23 | 24 | public static double getDiviend1() { 25 | return getIncome() * 0.5; 26 | } 27 | public static double getDiviend2() { 28 | return getIncome() * 0.3; 29 | } 30 | public static double getDiviend3() { 31 | return getIncome() * 0.2; 32 | } 33 | 34 | public static double getIncome() { 35 | return valueOfSupply - getExpense(); 36 | } 37 | 38 | public static double getExpense() { 39 | return valueOfSupply * expenseRate; 40 | } 41 | 42 | public static double getTotal() { 43 | return valueOfSupply + getVAT(); 44 | } 45 | 46 | public static double getVAT() { 47 | return valueOfSupply * vatRate; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Programming/.gitignore: -------------------------------------------------------------------------------- 1 | /letter.out.txt 2 | -------------------------------------------------------------------------------- /Programming/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.jdt.core.prefs 2 | -------------------------------------------------------------------------------- /Programming/ClassApp.java: -------------------------------------------------------------------------------- 1 | 2 | public class ClassApp { 3 | 4 | public static void main(String[] args) { 5 | 6 | System.out.println(Math.PI); 7 | System.out.println(Math.floor(1.6)); 8 | System.out.println(Math.ceil(1.6)); 9 | 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Programming/InstanceApp.java: -------------------------------------------------------------------------------- 1 | import java.io.FileNotFoundException; 2 | import java.io.IOException; 3 | import java.io.PrintWriter; 4 | public class InstanceApp { 5 | 6 | public static void main(String[] args) throws IOException{ 7 | 8 | PrintWriter p1 = new PrintWriter("result1.txt"); 9 | p1.write("Hello 1"); 10 | p1.close(); 11 | 12 | PrintWriter p2 = new PrintWriter("result2.txt"); 13 | p2.write("Hello 2"); 14 | p2.close(); 15 | System.out.println(p1.toString()); 16 | p2.toString(); 17 | p2.write("Hello 2"); 18 | 19 | 20 | // PrintWriter.write("result1.txt", "Hello 1"); 21 | // PrintWriter.write("result2.txt", "Hello 2"); 22 | // PrintWriter.write("result1.txt", "Hello 1"); 23 | // PrintWriter.write("result2.txt", "Hello 2"); 24 | // PrintWriter.write("result1.txt", "Hello 1"); 25 | // PrintWriter.write("result2.txt", "Hello 2"); 26 | // PrintWriter.write("result1.txt", "Hello 1"); 27 | // PrintWriter.write("result2.txt", "Hello 2"); 28 | // PrintWriter.write("result1.txt", "Hello 1"); 29 | // PrintWriter.write("result2.txt", "Hello 2"); 30 | // PrintWriter.write("result1.txt", "Hello 1"); 31 | // PrintWriter.write("result2.txt", "Hello 2"); 32 | // PrintWriter.write("result1.txt", "Hello 1"); 33 | // PrintWriter.write("result2.txt", "Hello 2"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Programming/OkJavaGoInHome.java: -------------------------------------------------------------------------------- 1 | import org.opentutorials.iot.Elevator; 2 | import org.opentutorials.iot.Lighting; 3 | import org.opentutorials.iot.Security; 4 | 5 | public class OkJavaGoInHome { 6 | 7 | public static void main(String[] args) { 8 | 9 | String id = "JAVA APT 507"; 10 | 11 | // Elevator call 12 | Elevator myElevator = new Elevator(id); 13 | myElevator.callForUp(1); 14 | 15 | // Security off 16 | Security mySecurity = new Security(id); 17 | mySecurity.off(); 18 | 19 | // Light on 20 | Lighting hallLamp = new Lighting(id+" / Hall Lamp"); 21 | hallLamp.on(); 22 | 23 | Lighting floorLamp = new Lighting(id+" / floorLamp"); 24 | floorLamp.on(); 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Programming/OkJavaGoInHomeInput.java: -------------------------------------------------------------------------------- 1 | import javax.swing.JOptionPane; 2 | 3 | import org.opentutorials.iot.DimmingLights; 4 | import org.opentutorials.iot.Elevator; 5 | import org.opentutorials.iot.Lighting; 6 | import org.opentutorials.iot.Security; 7 | 8 | public class OkJavaGoInHomeInput { 9 | 10 | // paramter, 매개변수 11 | public static void main(String[] args) { 12 | 13 | String id = args[0]; 14 | String bright = args[1]; 15 | 16 | // Elevator call 17 | Elevator myElevator = new Elevator(id); 18 | myElevator.callForUp(1); 19 | 20 | // Security off 21 | Security mySecurity = new Security(id); 22 | mySecurity.off(); 23 | 24 | // Light on 25 | Lighting hallLamp = new Lighting(id+" / Hall Lamp"); 26 | hallLamp.on(); 27 | 28 | Lighting floorLamp = new Lighting(id+" / floorLamp"); 29 | floorLamp.on(); 30 | 31 | DimmingLights moodLamp = new DimmingLights(id+" moodLamp"); 32 | moodLamp.setBright(Double.parseDouble(bright)); 33 | moodLamp.on(); 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Programming/Program.java: -------------------------------------------------------------------------------- 1 | 2 | public class Program { 3 | 4 | public static void main(String[] args) { 5 | 6 | System.out.println(1); 7 | System.out.println(2); 8 | System.out.println(3); 9 | 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Programming/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 | -------------------------------------------------------------------------------- /Programming/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 | } -------------------------------------------------------------------------------- /Programming/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 | -------------------------------------------------------------------------------- /Programming/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 | -------------------------------------------------------------------------------- /Programming/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 | } -------------------------------------------------------------------------------- /Programming/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 | } -------------------------------------------------------------------------------- /Programming/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 | -------------------------------------------------------------------------------- /Programming/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 | -------------------------------------------------------------------------------- /Programming/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 | -------------------------------------------------------------------------------- /Programming/org/opentutorials/iot/Speaker.java: -------------------------------------------------------------------------------- 1 | package org.opentutorials.iot; 2 | 3 | public class Speaker { 4 | String _id; 5 | public Speaker(String id) { 6 | this._id = id; 7 | } 8 | public Boolean makeVoice(String content) { 9 | System.out.println(this._id + " → Speaker on : " + content); 10 | return true; 11 | } 12 | } --------------------------------------------------------------------------------