'프로그램'이라는 것은 '입력을 받아 출력을 만들어내는 것'이라고 정의할 수 있다.
Java에 한정짓지 않고 프로그램에서는 다양한 것들이 입력값이 될 수 있다.
JOptionPane.showInputDialog()
import javax.swing.JOptionPane;
import org.opentutorials.iot.DimmingLights;
import org.opentutorials.iot.Elevator;
import org.opentutorials.iot.Lighting;
import org.opentutorials.iot.Security;
public class OkJavaGoInHomeInput {
public static void main(String[] args) {
String id = JOptionPane.showInputDialog("Enter a ID");
// Elevator call
Elevator myElevator = new Elevator(id);
myElevator.callForUp(1);
// Security off
Security mySecurity = new Security(id);
mySecurity.off();
Parsing(파싱) : 구문 분석. 컴퓨터과학에서는, 주어진 정보를 내가 원하는대로 가공하여 원하는 때 불러올 수 있도록 하는 것을 칭한다.
import javax.swing.JOptionPane;
import org.opentutorials.iot.DimmingLights;
import org.opentutorials.iot.Lighting;
public class OkJavaGoInHomeInput {
public static void main(String[] args) {
String id = JOptionPane.showInputDialog("Enter a ID");
String bright = JOptionPane.showInputDialog("Enter a Bright level");
// Light on
Lighting hallLamp = new Lighting(id+" / Hall Lamp");
hallLamp.on();
Lighting floorLamp = new Lighting(id+" / floorLamp");
floorLamp.on();
DimmingLights moodLamp = new DimmingLights(id+" moodLamp");
moodLamp.setBright(Double.parseDouble(bright));
moodLamp.on();
}
}
Double.parseDouble()
: 문자열에서 더블형으로 바꾸는 메소드