eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Java Наследование Фигур

опубликовано 03.04.2024, 23:05:18

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"); } }