-
Notifications
You must be signed in to change notification settings - Fork 1
/
CircleCapsulation.java
75 lines (67 loc) · 1.59 KB
/
CircleCapsulation.java
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
class Point {
int xPos, yPos;
public Point(int x, int y) {
xPos = x;
yPos = y;
}
public void showPointInfo() {
System.out.println("[" + xPos + "," + yPos + "]");
}
}
class Circle2 {
int rad;
Point center;
public Circle2(int xc, int yc, int r) {
center = new Point(xc, yc);
rad = r;
}
public void showCircleInfo() {
System.out.println("[" + center.xPos + "," + center.yPos + "," + rad + "]");
center.showPointInfo();
}
}
public class CircleCapsulation {
public static void main(String[] args) {
Circle2 c = new Circle2(2, 2, 4); // 좌표 2,2 이고 반지름 4 인 원 생성.
c.showCircleInfo(); // 원의 좌표 정보와 반지름 정보 출력.
}
}
//
//class Point {
// int xPos, yPos;
//
// public Point(int x, int y) {
// xPos = x;
// xPos = y;
// }
//
// public void showPointInfo() {
// System.out.println("[" + xPos + ", " + yPos + "]");
// }
//}
//
//class Circle
//{
// int rad; // ¹ÝÁö¸§
// Point center; // ¿øÀÇ Áß½É
//
// public Circle(int x, int y, int r) {
// center = new Point(x, y);
// rad = r;
// }
//
// public void showCircleInfo() {
// System.out.println("radius: " + rad);
// center.showPointInfo();
// }
//}
//
//class UseCircle {
// public static void main(String[] args) {
// // ÁÂÇ¥ [2, 2] ¹ÝÁö¸§ 4ÀÎ ¿øÀÇ »ý¼º
// Circle c = new Circle(2, 2, 4);
//
// // ¿øÀÇ Á¤º¸ Ãâ·Â
// c.showCircleInfo();
// }
//}