1968: Abstract Class Shape(choose one from E and F)
题目描述
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:the pi for caculating an area of a circle is 3.14159
输入
there are many cases,for each case,input “C”and “R” to denote a circle and rectangle,and then input the shape's information; for circle,input its radius,for rectangle,input its width and length
输出
if the shape is filled,output its all properties and its area; if the shape is not filled,output its all properties and its perimeter; the area and the perimeter keep 2 decimals
样例输入 复制
C red true 4.5
R pink false 3.5 4.8
样例输出 复制
The circle: red,filled,its area is 63.62
The rectangle: pink,not filled,its perimeter is 16.60