import java.util.Scanner;
class Circle {
private double x,y;
private int radius;
public Circle(double x, double y, int radius) {
this.radius=radius;
this.x=x;
this.y=y;
}
public void show() {
System.out.println("("+x+","+y+")"+radius);
}
}
public class Main{
public static void main(String[] args) {
Scanner scanner = new Scanner (System.in);
Circle c [] = new Circle[3];
for (int i=0;i<c.length;i++) {
System.out.print("x, y, radius >>");
double x = scanner.nextDouble();
double y = scanner.nextDouble();
int radius = scanner.nextInt();
c[i] = new Circle(x,y,radius);
}
for (int i=0;i<c.length;i++) {
c[i].show();
}
}
}
extends 연장하다 확장하다
Person : 슈퍼클래스 or 부모클래스
Student
Teacher : 서브클래스 or 자식클래스
접근지정자 : 접근할 수 있는 권한을 지정
public - 다른 모든 클래스에서 볼 수있다
private - 그 클래스에서만! 볼 수있다
*/
/*
class Person{
private int age;
String name;
public void setAge(int age) { //private 필드를 set, get 할 수 있는 메소드를 만들어 줘야 한다 !!
this.age=age;
}
}
//Person 클래스를 상속받은 Student 클래스
//Person 클래스의 모든 필드, 메소드를 가진다.
class Student extends Person{
char grade;
}
//선생님 클래스
class Teacher extends Person{
String subject;
}
class Main{
public static void main(String[] args) {
Student s = new Student();
//s.age=10; (x)
s.setAge(10);
}
}*/
class Point {
private int x,y;
public void set(int x, int y) {
this.x = x; this.y=y;
}
public void showPoint() {
System.out.println("("+x+","+y+")");
}
}
class ColorPoint extends Point {
//Point 클래스를 상속받았으므로, Point 클래스의 필드, 메소드 모두 가지고 있다!
private String color;
public void setColor(String color) {
this.color=color;
}
public void showColorPoint() {
System.out.println(color);
showPoint();
}
}
public class Main {
public static void main(String [] args) { //메인 메소드를 가진 클래스는 Main 클래스
Point p = new Point();
p.set(1, 2);
p.showPoint();
ColorPoint cp = new ColorPoint();
cp.set(3, 4);
cp.setColor("red");
cp.showColorPoint();
}
}



