생활코딩 [자바 입문 수업] 공부 기록
11.1 입력과 출력
팝업창이 뜨면서 입력할 수 있었으면 좋겠어!
google searching
java popup input text swing
package java09;
import org.opentutorials.iot.Elevator;
import org.opentutorials.iot.Lighting;
import org.opentutorials.iot.Security;
import javax.swing.*;
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); // 올라갈 거니까, 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();
}
}
String id = JOptionPane.showInputDialog("Enter a ID");
이 부분을 추가했고!
run 하니, 팝업창이 떴다.
입력한 것이 이렇게 뜬다!
good.
사용자가 입력한 값에 따라 다르게 동작할 수 있는!
굉장히 똑똑하고 범용적으로 쓰일 만한 프로그램이다.
google searching
java string to double conversion
package java09;
import org.opentutorials.iot.DimmingLights;
import org.opentutorials.iot.Elevator;
import org.opentutorials.iot.Lighting;
import org.opentutorials.iot.Security;
import javax.swing.*;
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); // 올라갈 거니까, 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 moodLmap = new DimmingLights(id + " moodLamp"); //★
moodLmap.setBright(Double.parseDouble(bright)); //string to double //★
moodLmap.on(); //★
}
}
11.2 입력과 출력 : arguments & parameter
argument: 인자
parameter: 매개변수
12.1 직접 컴파일하고 실행하기
java 확장자가 붙은 소스 코드를 class 확장자가 붙은 실행 파일로 바꾸는 거.
Compile
Run
Input
12.2 직접 컴파일하고 실행하기 : 실행환경 살펴보기
windows + R => cmd
우리카 컴파일 하고, 실행을 하기 위해서는 javac를 이용해서 컴파일 할 수 있다.
cd: change directory
ls: list
자바 환경 변수 설정
(여기서부터는 부스트코스에서 봄)
똑같이 따라하지 않아도 되니, 흐름을 이해하는 걸로.
12.3 직접 컴파일-실행 : 컴파일과 실행하기
dir 명령어로 프로젝트 디렉토리 내부 구조를 확인할 수 있음
12.4 직접 컴파일-실행 - 라이브러리 이용
Library
--class-path 옵션은 -cp로 줄여 표현 가능
12.5 직접 컴파일-실행 - 입력과 출력
12강은 cmd 창으로 따라해야 하는 부분이었다.
cmd창으로 코드를 작성하는 건 매우 낯설다.
일단은 영상 보며 최대한 이해하면서 보려고 했다.
300x250
'Language > JAVA' 카테고리의 다른 글
[JAVA] 14~15 나의 앱 만들기 (조건문 배열 반복문 메소드 클래스 인스턴스) (0) | 2022.01.31 |
---|---|
[JAVA] 13 자바 문서 보는 법 - API UI 클래스 인스턴스 상속 (0) | 2022.01.31 |
[JAVA] 9~10 프로그래밍, 프로그램, 디버거 (0) | 2022.01.30 |
[JAVA] 7~8 변수 variable , casting (int to String) (0) | 2022.01.29 |
[JAVA] 6 데이터와 연산 Number String (new line, escape) (0) | 2022.01.29 |