/**
* @author: 袁
* @date: 2022-09-29 0:10
* @desc:
*/
abstract class Shape {
abstract public void showArea();
}
class Rectangle extends Shape{
int length;
int wide;
int area;
public Rectangle() {
}
public Rectangle(int length, int wide) {
this.length = length;
this.wide = wide;
}
public void showArea(){
area = length * wide;
System.out.println(area);
}
}
class Square extends Shape{
int length;
int area;
public Square() {
}
public Square(int length) {
this.length = length;
}
public void showArea(){
area = length * length;
System.out.println(area);
}
}
class Circle extends Shape{
int radius;
double area;
public Circle() {
}
public Circle(int radius) {
this.radius = radius;
}
public void showArea(){
double PI = 3.141596;
area = PI *radius * radius;
System.out.println(area);
}
public static void main(String[] args) {
Rectangle rectangle = new Rectangle(1,2);
rectangle.showArea();
Square square = new Square(1);
square.showArea();
Circle circle = new Circle(2);
circle.showArea();
}
}
11-18
1299
03-20
797
08-26
457