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();
}
}