Задачи
Java Наследование Фигур
class Shape { private String shapeName;
Shape(String name) { this.shapeName = name; }
public String getShapeName() { return shapeName; }
public String toString()
{
return getShapeName();
}
}
class Circle extends Shape { // calling the constructor of the Shape class Circle() { super("Circle"); } }
class Rectangle extends Shape { // calling the constructor of the Shape class public Rectangle() { super("Rectangle"); } }
class Triangle extends Shape { // calling the constructor of the Shape class public Triangle() { super("Triangle"); } }