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 编辑 ]