1918: Shape_Circle_Rectangle
题目描述
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)add a toString method
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)define a method named "area()" to get the area of a circle
4)override toString method
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)define a method named "perimeter()" to get the perimeter of a rectangle
3)override toString method
finally, you should define a common static method to display the information of a circle and a rectangle as required.
Note: the pi for caculating an area of a circle is 3.14159
输入
输出
output the information of the circle or the rectangle as required,the area and the perimeter keep 2 decimals
样例输入 复制
C red true 4.5
R pink false 3.5 4.8
样例输出 复制
The circle: red,filled,and the area is 63.62
The rectangle: pink,not filled,and the perimeter is 16.60