- public interface Printx {
- public void printMyWay();
- }
- public class Squre implements Printx{
- double height,wide;
- double area,length;
- Squre(double height,double wide){
- this.height=height;
- this.wide=wide;
- }
- Squre(double height){
- this.height=height;
- }
- public void printMyWay(){
- area=height*wide;
- length=2*(height+wide);
- };
- }
- public class Squreson extends Squre {
- double diagonal;
- Squreson(double height){
- this.height=height;
- }
- public void printMyWay(){
- area=height*height;
- length=4*height;
- diagonal=sqrt(2*height*height);
- }
- }
- }
- public class Print {
- public static void main(String[] args) {
- Squre squre;
- Squreson squreson;
- squre=new Squre(4,5);
- squre.printMyWay();
- squreson=new Squreson(4);
- squreson.printMyWay();
- }
- }
复制代码 上面的编译出现了3个错误:
符号: 构造函数 Squreson(int)
位置: 类 接口.Squreson
squreson=new Squreson(4);
符号: 构造函数 Squre()
位置: 类 接口.Squre
public class Squreson extends Squre {
符号: 方法 sqrt(double)
位置: 类 接口.Squreson
diagonal=sqrt(2*height*height);
请问是什么问题呢? |
|