| sametim |
ÄÚµå ³¶ºñÀÏÁöµµ ¸ð¸£Áö¸¸.. Àú·Î¼´Â À̰Ÿ»°í´Â µÇÁö°¡ ¾Ê³×¿ä. ¹«´É·ÂÇØ Á˼ÛÇÕ´Ï´Ù.
public class Box01 {
int boxId, amount=0;
String width, length, height;
Box01(int boxId, String width, String length, String height) {
this.boxId = boxId;
this.width = width;
this.length = length;
this.height = height;
amount ++;
}
Box01(int boxId, String width, String length, String height, Box01 obj) {
this.boxId = boxId;
this.width = width;
this.length = length;
this.height = height;
this.amount = obj.amount + 1;
}
}
===============================================
public class Box01Test {
int amount=0;
public static void main(String args[]) {
Box01 obj1, obj2, obj3, obj4;
obj1 = new Box01(1, "1", "2", "3");
obj2 = new Box01(2, "4", "5", "6", obj1);
obj3 = new Box01(3, "7", "8", "9", obj2);
obj4 = new Box01(4, "10", "11", "12", obj3);
printBox01(obj1);
printBox01(obj2);
printBox01(obj3);
printBox01(obj4);
}
static void printBox01(Box01 obj) {
System.out.println("Box"+obj.boxId+"¹øÀÇ id ¹øÈ£ : " + obj.boxId);
System.out.println("boxÀÇ °³¼ö : "+ obj.amount);
}
} |
2014/12/19 |
|