1920: Abstract Shape
题目描述
define a Shape class as follows:
1)contains two data fields: color(String type),filled(boolean type)
2)define a no-arg constructor and a constructor with all data fields
3)define two abstract methods,perimeter() and area()
define a Circle class extending Shape class:
1) add a new property, radius
2)define a no-arg constructor and a constructor with all data fields
3)implement the abstract methods : perimeter() and area()
define a Rectangle class extending Shape class:
1) add two new properties, width and length
2)define a no-arg constructor and a constructor with all data fields
3)implement the abstract methods : perimeter() and area()
Note:
1) the pi for caculating an area of a circle is 3.14159
2) you can be allowed to create an only object
输入
C red true 4.5
R pink false 3.5 4.8
输出
The circle: red,filled,and perimeter is 28.27,area is 63.62
The rectangle: pink,not filled,and the perimeter is 16.60,area is 16.80