pullwall
Well done! 코딩
pullwall
전체 방문자
오늘
어제
  • 분류 전체보기 (151)
    • 개발환경 (2)
    • java study (21)
    • 백준 단계별 (51)
    • 알고리즘 (3)
    • AI (43)
    • 클라우드 (3)
      • Kubernetes in Google (3)
    • 논문 (5)
    • 리눅스 (1)
    • AWS (4)
    • 수학 (15)
    • 기타 (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 논문리뷰
  • 알고리즘
  • 백준
  • 백준 단계별
  • 자바독학
  • 자바
  • 선택정렬
  • 정렬
  • 정렬알고리즘
  • Kubernetes
  • Google
  • Ai
  • 쿠버네티스
  • AWS
  • pytorch
  • 단계별
  • 수학
  • Java
  • LLM
  • dataset

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
pullwall

Well done! 코딩

[Java Study] 입력과 출력
java study

[Java Study] 입력과 출력

2022. 6. 25. 19:45
728x90

 

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 OkJavaGoingHomeInput {
    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("JAVA APT 507 / Hall Lamp");
        hallLamp.on();

        DimmingLights moodLamp = new DimmingLights(id+" moodLamp");
        moodLamp.setBright(Double.parseDouble(bright));
        moodLamp.on();
    }
}

전에 만들었던 간단한 IoT 시스템에 기능 몇가지를 추가하였다.

JOptionPane.showInputDialog("Enter a ID");

위의 코드는 팝업창을 띄워 C언어의 scanf 기능과 유사한 역할을 한다.

moodLamp.setBright(Double.parseDouble(bright));

위의 코드는 moodLamp.setBright는 double형을 받아야만 하는 함수인데, 그 외 자료형이 들어올 경우

double형으로 변환하는 코드이다.

위의 사진과 같이 심플한 GUI가 출력된다.

728x90

'java study' 카테고리의 다른 글

[Java Study] 자바 문서 보는 법 (패키지, 클래스, 변수, 메소드)  (0) 2022.06.28
[Java Study] API와 UI의 개념  (0) 2022.06.28
[Java Study] 인텔리제이(intellij) 디버거 사용하기  (0) 2022.06.24
[Java Study] 간단한 IoT 구현하기  (0) 2022.06.20
[Java Study] 데이터 타입의 변환 (Casting)  (0) 2022.06.20
    'java study' 카테고리의 다른 글
    • [Java Study] 자바 문서 보는 법 (패키지, 클래스, 변수, 메소드)
    • [Java Study] API와 UI의 개념
    • [Java Study] 인텔리제이(intellij) 디버거 사용하기
    • [Java Study] 간단한 IoT 구현하기
    pullwall
    pullwall

    티스토리툴바