Notice
Recent Posts
Recent Comments
Link
«   2025/03   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter01 : rect / rectmain 본문

JAVA/chapter09_this

chapter01 : rect / rectmain

GAWON 2023. 5. 26. 18:08
package org.joonzis.ex;

public class Ex01_Rect {
	int width, height;
	
	public Ex01_Rect() {}
	public Ex01_Rect(int width, int height) {
		this.width = width;
		this.height = height;
	}
	void setWidth(int width) {
		this.width = width;
	}
	void setHeight(int height) {
		this.height = height;
	}
	void output() {
		System.out.println("너비 : " + width);
		System.out.println("높이 : " + height);
	}
}
package org.joonzis.ex;

public class Ex01_RectMain {
	public static void main(String[] args) {
		
		Ex01_Rect r = new Ex01_Rect(3, 5);
		r.output();
		
		r.setWidth(8);
		r.setHeight(10);
		r.output();
		
	}
}

'JAVA > chapter09_this' 카테고리의 다른 글

chapter02 : book  (0) 2023.05.26