Input은 문자열, 숫자 등의 인자가 될 수 있고,
Output은 파일, 네트워크를 통한 정보, 소리, 타프로그램에서의 출력된 정보일 수도 있음
Output -> 화면에 출력, 파일로 사용, 소리로 출력, 타프로그램으로 출력
새로운 객체를 만들어서 소스코드 입력
입력 받을 때 사용하는 메소드
표준 대화 상자를 팝업
JOptionPane.
JOptionPane.showInputDialog("입력 : ");
import javax.swing.JOptionPane; // 객체 import
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");
String bright = JOptionPane.showInputDialog("Enter a Bright level");
// Elevator call
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+" / floorLamp");
floorLamp.on();
DimmingLights moodLamp = new DimmingLights(id+" moodLamp");
moodLamp.setBright(Double.parseDouble(bright)); // 형 변환 후 인자로 전달
moodLamp.on();
}
}
Argument = 인자
eclipse 내에서 해당하는 클래스의 Argument를 설정
메소드의 paramter로 보낼 때 Argument의 위치 전달
import javax.swing.JOptionPane; // 객체 import
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 = args[0]; // paramter로 보낼 때 Argument의 위치 전달
Strign bright = args[1]; // `` `` `` ``
// Elevator call
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+" / floorLamp");
floorLamp.on();
DimmingLights moodLamp = new DimmingLights(id+" moodLamp");
moodLamp.setBright(Double.parseDouble(bright)); // 형 변환 후 인자로 전달
moodLamp.on();
}
}
당신의 시간이 헛되지 않는 글이 되겠습니다.
I'll write something that won't waste your time.