高手请进,抽象类的基础问题
abstract class Book{
int bookPage;
float discount;
double price;
abstract void show();//抽象方法
abstract double getPrice(int bookPage,float discount);
public Book(int bookPage,float discount){
this.bookPage=bookPage;
this.discount=discount;
}
public void show_price(){System.out.println("this book's price is "+price);
}
}
class Science_book extends Book{
public Science_book(int bookPage,float discount){
super(bookPage,discount);
}
public void show(){
System.out.println("the book's kind is discount");
}
public double getPrice(int bookPage,float discout){
return bookPage*0.1*discount;
}
}
public class Booksell{
public static void main(String[] arg){
Science_book bb=new Science_book(530,0.7f);
bb.price=(int)bb.getPrice(530,0.7f);
bb.show();
bb.show_price();
Literature_book ll=new Literature_book(530,0.7f);
ll.price=(int)ll.getPrice(530,0.7f);
ll.show();
ll.show_price();
}
}
问题是程序中有没有"abstract void show();//抽象方法"都是一样的结果,不明白抽象方法拿来干什么用??????????