20210730) 메소드 - Window 창 클래스 작성하기

0

JAVA

목록 보기
46/71

필요한 내용?

가로
세로
보이는가?
위치 top
위치 left

package windowProgramming;

public class Window {

	private int width;
	private int height;
	private boolean isVisible;
	private int top;
	private int left;
	
	// get set 메소드
	public void setWidth(int width) {
		this.width = width;
	}
	public int getWidth() {
		return width;
	}
	
	// 나머지 만들어 보기
	public void setHeight(int height) {
		this.height = height;
	}
	public int getHeight() {
		return height;
	}
	
	
	public void setIsVisible(boolean isVisible) {
		this.isVisible = isVisible;
	}
	
	public boolean getisVisible() {
		return isVisible;
	}
	
	
	public void setTop(int top) {
		this.top = top;
	}
	
	public int gettop() {
		return top;
	}
	
	public void setLeft(int left) {
		this.left = left;
	}
	
	public int getleft() {
		return left;
	}


}

App 클래스의 main에서 Window 클래스의 get set 메소드를 사용하는 연습을 한다


package windowProgramming;

public class App {

	public static void main(String[] args) {
		// 윈도우 클래스를 작성하여 사용
		Window window =new Window();
		window.setWidth(800);
		window.setHeight(600);
		window.setIsVisible(true);
		window.setTop(100);
		window.setLeft(200);

		System.out.println(window.getWidth());
		System.out.println(window.getHeight());
		System.out.println(window.getisVisible());
		System.out.println(window.gettop());
		System.out.println(window.getleft());


	}

}

0개의 댓글

관련 채용 정보