当前位置: 代码迷 >> Java相关 >> JAVA练习题求助
  详细解决方案

JAVA练习题求助

热度:256   发布时间:2010-05-16 13:45:41.0
JAVA练习题求助
1.In the superclass sale add a method named double computerCharge()  在superclass sale加上一个method叫double computerCharge()
2.As it cannot be defined(no common scheme)make this method abstract.这句没理解,好像是不能定义这个method abstract
3.this requires the class also to be abstract 这个class也要求abstract
4.Override this method in both subclasses using the scheme specified 也没理解
5.Now the method computerCharge() cna be called polymorphically in the class ManageSales 现在方法computerCharge()能叫polymorphically在class ManageSales

小弟在国外念书,老 师讲什么只略懂,所以寻求各位的帮助


class Sale {
     private String address;
     public Sale(String add);
     {  address= add;}
     public String getAddress()
     {return address;
     }

}

class NegotiatedSale extends Sale
{
     private String address;
     private double commRate;
     private double salePrice;
     public NegotiatedSale(String add, double price, double cRate)
   
     { super(add);
       salePrice=price;
       commRate=cRate;
     }
}


class AuctionSale extends Sale
{
     private double basePrice;
     private double actualPrice;
     private double bonusRate;
     public AuctionSale(String add, double bPrice, double aPrice, double bRate)
   
     {super(add);
     basePrice=bPrice;
     actualPrice=aPrice;
     bonusRate=bRate;
   
     }
}

public class ManageSales
{
    public static void man(String args[])
    {
        Sale s[]=new Sale[4];
        s[0]=new NegotiatedSale("34 Kew crt", 34000, 0.05);
        s[1]=new AuctionSale("5 Bet crt", 560000, 565000, 0.10);
        s[2]=new AuctionSale("12 Ron dr", 24000, 290000, 0.15);
        s[3]=new NegotiatedSale("2 Johnst", 420000, 0.03);
        for (int i=0;i<4;i++)
        System.out.println(s[i].getAddress());

    }
}
   
谢 谢


[ 本帖最后由 jackyshen 于 2010-5-16 18:47 编辑 ]
搜索更多相关的解决方案: JAVA  练习题  

----------------解决方案--------------------------------------------------------
提示: 作者被禁止或删除 内容自动屏蔽
2010-05-16 10:22:38
jackyshen

等 级:论坛游民
帖 子:53
专家分:35
注 册:2010-5-16
  得分:0 
分数都用完了,没了
----------------解决方案--------------------------------------------------------
那有办法追加分吗
----------------解决方案--------------------------------------------------------
提示: 作者被禁止或删除 内容自动屏蔽
2010-05-16 11:03:39
liubangchuan
该用户已被删除
  得分:0 
提示: 作者被禁止或删除 内容自动屏蔽
2010-05-16 11:04:59
jackyshen

等 级:论坛游民
帖 子:53
专家分:35
注 册:2010-5-16
  得分:0 
谢谢,可是第4题我还是没有很理解。
如何在子类里写computerCharge

----------------解决方案--------------------------------------------------------
提示: 作者被禁止或删除 内容自动屏蔽
2010-05-16 11:35:35
jackyshen

等 级:论坛游民
帖 子:53
专家分:35
注 册:2010-5-16
  得分:0 
那第5题也可以把代码写出来吗,谢谢


----------------解决方案--------------------------------------------------------
  相关解决方案