[ 객체지향 프로그래밍 ]
class Box{
int x;//가로길이
private int y;//세로길이
private String color;//색상
public void setXY(int x,int y) {
this.x=x;
this.y=y;
}
public void setColor(String color) {
this.color=color;
}
public void draw() {
System.out.println(x+"," + y +"크기의 사각형그리기");
}
public void paint() {
System.out.println(color +"색상으로 사각형 칠하기");
}
}
public class Test04_class {
public static void main(String[] args) {
Box b=new Box();
b.setXY(100,100);
// b.x=-200;
//b.y=200;
b.setColor("빨강");
b.draw();
b.paint();
Box box1=new Box();
box1.setXY(50, 100);
box1.setColor("파랑");
box1.draw();
}
}