import javax.swing.JOptionPane;
// 다이얼로그를 불러올 수 있게 JOptionPane클래스 불러오기
public static void main(String[] args) {
// 다이얼로그 호출
String id = JOptionPane.showInputDialog("Enter a ID");
String bright = JOptionPane.showInputDialog("Enter a Bright level");
// 위에서 입력한 다이얼로그는 String이므로 Double형으로 변환
moodLamp.setBright(Double.parseDouble(bright));
import javax.swing.JOptionPane;
import org.opentutorials.iot.DimmingLights;
import org.opentutorials.iot.Elevator;
import org.opentutorials.iot.Lighting;
import org.opentutorials.iot.Security;
// import를 통해 다른 클래스를 불러올 수 있다.
public class OKJavaGoInHomeInput {
public static void main(String[] args) {
// String이라는 데이터 타입을 변수 id로 지정
String id = JOptionPane.showInputDialog("Enter a ID");
String bright = JOptionPane.showInputDialog("Enter a Bright level");
// Elevator call
// myElevator 라는 변수는 반드시 Elevator라는 데이터 타입에 해당되는 데이터만 올 수 있다.
// 위에서 import를 통해 org폴더의 Elevator를 불러옴
Elevator myElevator = new Elevator(id);
myElevator.callForUp(1);
// Security off
Security mySecurity = new Security(id);
mySecurity.off();
//Light on
Lighting hallLamp = new Lighting(id+" / Hall Lamp");
hallLamp.on();
Lighting floorLamp = new Lighting(id+" / Floor Lamp");
floorLamp.on();
DimmingLights moodLamp = new DimmingLights(id+" moodLamp");
moodLamp.setBright(Double.parseDouble(bright));
moodLamp.on();
}
}
매개변수는 프로그램과 사람 사이의 값을 매개 해준다고 하여 매개변수라고 한다.
// args = parameter(매개변수)
public static void main(String[] args) {
String id = args[0] ;
String bright = args[1];
import javax.swing.JOptionPane;
import org.opentutorials.iot.DimmingLights;
import org.opentutorials.iot.Elevator;
import org.opentutorials.iot.Lighting;
import org.opentutorials.iot.Security;
// import를 통해 다른 클래스를 불러올 수 있다.
public class OKJavaGoInHomeInput {
public static void main(String[] args) {
// String이라는 데이터 타입을 변수 id로 지정
String id = args[0] ;
String bright = args[1];
// Elevator call
// myElevator 라는 변수는 반드시 Elevator라는 데이터 타입에 해당되는 데이터만 올 수 있다.
// 위에서 import를 통해 org폴더의 Elevator를 불러옴
Elevator myElevator = new Elevator(id);
myElevator.callForUp(1);
// Security off
Security mySecurity = new Security(id);
mySecurity.off();
//Light on
Lighting hallLamp = new Lighting(id+" / Hall Lamp");
hallLamp.on();
Lighting floorLamp = new Lighting(id+" / Floor Lamp");
floorLamp.on();
DimmingLights moodLamp = new DimmingLights(id+" moodLamp");
moodLamp.setBright(Double.parseDouble(bright));
moodLamp.on();
}
}