¶
향 한 하. 클 하 향 . 클 하 해 해 클 클 해 .
클 클(superclass) 하 하클(subclass) .클 한.
하클 클 .클 한 행 했 하 클 할 . 클 클 행 . 클 Object 클 . 클 클 . 클 한 .
클 할 클 할 . Button 한 클 Button 하 하 . Button 해 .
한 subclassing.
클 클(superclass) 하 하클(subclass) .클 한.
하클 클 .클 한 행 했 하 클 할 . 클 클 행 . 클 Object 클 . 클 클 . 클 한 .
클 할 클 할 . Button 한 클 Button 하 하 . Button 해 .
한 subclassing.
클 ¶
¶
클 , 클 클 . 클 합 한 템플 형하 한 .
하 한. 클 한. 호 택. 한 호하 클 펴. 클 할 클 .
하클 클 한 하 ? 행 . 한 클 하클 한 할 . (overriding) .
하 한. 클 한. 호 택. 한 호하 클 펴. 클 할 클 .
하클 클 한 하 ? 행 . 한 클 하클 한 할 . (overriding) .
Point 클 ¶
- x,y
- x,y 표
- x , 하
- y , 하
- 클
~cpp import javax.swing.JOptionPane; public class Point { private int x; private int y; public Point() { } public Point(int aX, int aY) { // . this.x = aX; y = aY; } public int getX() { return x; } public int getY() { return y; } public void setX(int Ax) { x = Ax; } public void setY(int Ay) { y = Ay; } public String getName() { return "Point"; } public void Say(String str) { JOptionPane.showMessageDialog(null, str); } public void Say(int temp) { String str = Integer.toString(temp); JOptionPane.showMessageDialog(null, str); } public static void main(String[] args) { Point P1 = new Point(20,20); Point P2 = new Point(10,10); //RECTANGLE Rectangle p = new Rectangle(P1,P2); // System.out.println(p.getArea()); //circle Circle c = new Circle(P1,P2); System.out.println(c.getArea()); } }
Shape 클 ¶
- x,y, x,y
- 해
- 클
~cpp public class Shape { protected Point left_top; protected Point right_bottom; public String name; public Shape() { } public Shape ( Point p1 , Point p2) { left_top = p1; right_bottom = p2; name = "Shape"; } public Shape ( int x1, int y1, int x2, int y2) { this.left_top = new Point(x1,y1); this.right_bottom = new Point( x2,y2 ); name = "Shape"; } public double getArea() { return 0; } public String getName() { return name; } }
Circle 클 ¶
~cpp public class Circle extends Shape { private double radius; public Circle() { } public Circle(Point p1, Point p2) { super(p1, p2); name = "Circle"; } public Circle(int x1, int y1, int x2, int y2) { super(x1, y1, x2, y2); name = "Circle"; } public double getArea() { if(Math.abs(left_top.getX()-right_bottom.getX()) >= Math.abs(left_top.getY()-right_bottom.getY())) radius = Math.abs(left_top.getY()-right_bottom.getY()); else radius = Math.abs(left_top.getX()-right_bottom.getX()); return Math.PI * radius * radius; } public String getName() { return super.getName(); } }
Rectangle 클 ¶
~cpp public class Rectangle extends Shape { //right_bottom //Point left_top public Rectangle() { } public Rectangle(Point P1, Point P2) { super(P1, P2); name = "Rectangle"; } public Rectangle(int x1, int y1, int x2, int y2) { super(x1, y1, x2, y2); name = "Rectangle"; } public double getArea() { return Math.abs(right_bottom.getX()-left_top.getX()) * Math.abs(left_top.getY()-right_bottom.getY()); } }
펙 ¶
클 ¶
- Unit 클
- HP, , 태(, , , 탑),
- 한, 한, 한, 탑한(태 )
- HP ( ) (ex public void underattack(int aAttackPoint) )
- HP, , 태(, , , 탑),
- (Unit 클 )
- HP 100, 10, 함
- 100
- HP 100, 10, 함
- (Unit 클 )
- HP 150, 20, 함
- 150
- HP 150, 20, 함
¶
- 한, 한 .
- 킨.