Java Inheritance Shape#9656

Java Inheritance Shape

1 second
128 megabytes
Very easy

Implement a class Shape.

Implement classes Circle, Rectangle, Triangle that extend Shape.

class Shape {
  private String shapeName; // private variable
  Shape(String name) // Constructor
  public String getShapeName() // return name of the shape
  public String toString() // Print the variable
}

class Circle extends Shape {
  Circle() // Constructor 
}

class Rectangle extends Shape {
  Rectangle() // Constructor 
}

class Triangle extends Shape {
  Triangle() // Constructor 
}

Input

Each line contains one of the next words:

  • Circle

  • Rectangle

  • Triangle

Output

For each word create a corresponding class and print the name of the shape.

Examples

Example 1

Loading
Loading