请大家看一下哪里需要简化改正一下
package com;
import java.util.Scanner;
public class test1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Square square1 = new Circle();
System.out.println("圆的面积为:"+square1.Area()+",圆的周长为:"+square1.Circumference());
Square square2 = new Rectangle();
System.out.println("矩形的面积为:"+square2.Area()+",矩形的周长为:"+square2.Circumference());
}
}
abstract class Square{
abstract float Area();
abstract float Circumference();
}
class Circle extends Square{
public int r;
public float p = 3.14f;
public Circle() {
Scanner input = new Scanner(System.in);
System.out.print("请输入圆的半径:");
r = input.nextInt();
}
@Override
float Area() {
// TODO Auto-generated method stub
return r*r*p;
}
@Override
float Circumference() {
// TODO Auto-generated method stub
return p*r*2;
}
}
class Rectangle extends Square{
public int len,wid;
public Rectangle() {
// TODO Auto-generated constructor stub
Scanner input = new Scanner(System.in);
System.out.print("请输入矩形的长:");
len = input.nextInt();
System.out.print("请输入矩形的宽:");
wid = input.nextInt();
}
@Override
float Area() {
// TODO Auto-generated method stub
return len*wid;
}
@Override
float Circumference() {
// TODO Auto-generated method stub
return (len+wid)*2;
}
}