package com.java1.day15;
class Shape2 {
private int x;
private int y;
public Shape2(int x, int y) {
System.out.println("Shape2()");
this.x = x;
this.y = y;
}
}
class Rectangle2 extends Shape2 {
private int width;
private int height;
public Rectangle2(int x, int y, int width, int height) {
super(x, y);
System.out.println("Rectangle2()");
this.width = width;
this.height = height;
}
double calcArea() {
return width * height;
}
}
public class ColoredRectangle extends Rectangle2 {
String color;
public ColoredRectangle(int x, int y, int width, int height, String color) {
super(x, y, width, height);
System.out.println("ColoredRectangle()");
this.color = color;
}
public static void main(String[] args) {
ColoredRectangle obj = new ColoredRectangle(10, 10, 20, 20, "red");
}
}
출력결과
Shape2()
Rectangle2()
ColoredRectangle()