디버거
bug 의도하지 않는 문제
debugging 버그 잡는 행위
debugger debugging을 할 때 사용하는 도구
실행되는 것을 일단 멈추고싶다면 멈추고싶은곳에 더블클릭하면 점이 생긴다
이 점은 브레이크 포인터라고 부른다
Debug 버튼을 눌러 실행해줘야한다
이 때 switch로 변환하면 화면구성이 완전히 달라진다
입력과 출력
INPUT(Argument, File, Network, Audio, Program) -> Program -> OUTPUT(Monitor, File, Audio, Program)
String id = JOptionPane.showInputDialog("Enter a ID"); 이것을 사용해주면 값을 물어보고 입력한 값을 받는다
Double.parseDouble(text)를 해주면 String에서 Double형으로 변환이 된다
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");
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();
}
}
Run Configurations 로 들어가준 뒤 Arguments 탭에서
"Java APT 507" "15.0" 을 입력해본다
받는값을 String id = args[0]; Stirng 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;
public class OkJavaGoInHomeInput {
// parameter, 매개변수
public static void main(String[] args) {
String id = args[0];
String 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();
}
}