설계

    [숙제#3] 프로그램 설계 방법론(아날로그 시계)

    언어 : JAVA 과제 : 아날로그 시계에 초가 지남에 따라 동심원이 커지도록 프로그래밍 하시오. 숙제#1과 숙제 #2는 이미 제출한 관계로 작성하지 않겠다. import java.awt.Color; import java.awt.Graphics; import java.time.LocalTime; import javax.swing.*; public class ClockWriter extends JPanel{ private final int SIZE; private final int MARGIN; private int diameter; public ClockWriter(int _s, int _rate) { SIZE = _s; MARGIN = SIZE/_rate; JFrame frame = new JFrame..

    [08] 프로그램 설계 방법론(제어 구조_조건-선택)

    주제 : 제어 구조(Control Structure) 기술한 순서대로 진행 메서드 호출 선택 구조 : If와 else문을 사용하여 작성하는 문법 import javax.swing.JOptionPane; public class Conditional { public static void main(String[] args) { String input = JOptionPane.showInputDialog("나이를 알려주세요"); int age = Integer.parseInt(input); if(age

    [07] 프로그램 설계 방법론

    주제 : 생성 메서드와 필드 변수 변수의 유효범위는 다음 코드를 통해 알 수 있다. import java.awt.Graphics; public class Scope { private double d = 3.14; public Scope() { System.out.println(s); System.out.println(d); int d = 2; System.out.println(d); System.out.println(s); } private String s = "X" + d; public void printComponent(Graphics g) { System.out.println(d + " " + s); } public static void main(String[] args) { new Scope();..

    [06] 프로그램 설계 방법론(생성자와 필드 변수)

    주제 : 생성 메서드와 필드 변수 생성 메서드(constructor method) : 객체가 태어나면서 저절로 한번 실행하는 메서드를 뜻한다. 생성 메서드를 만들 때는 클래스 이름과 동일하게 만든다. public class ClassName { public ClassName( par_1, …, par_n) { // 몸체 코드 블록 } } 실습 : 아날로그 시계를 만들어보자 import javax.swing.*; public class ClockWriter extends JPanel{ public ClockWriter() { JFrame frame = new JFrame(); frame.setTitle("Clock"); frame.setSize(300, 400); frame.setVisible(true);..