廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 3928 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
coon
數位造型
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x4 鮮花 x31
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[Java][求助] 有誰可以當我解決錯誤的地方
一直不知道哪裡出問題
不太會改
請各位大大幫我

import java.util.Scanner;

class Book{
private String name;
private String author;
private String publisher;
private int price;

Book(){

}

Book(String name, String author, String publisher, int price){
this.name = name;
this.author = author;
this.publisher = publisher;
this.price = price;
}

public String toString(){
return "書名:" + this.name + "\n作者:" + this.author +
"\n出版社:" + this.publisher + "\n訂價:" + this.price;

}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getAuthor() {
return author;
}

public void setAuthor(String author) {
this.author = author;
}

public String getPublisher() {
return publisher;
}

public void setPublisher(String publisher) {
this.publisher = publisher;
}

public int getPrice() {
return price;
}

public void setPrice(int price) {
this.price = price;
}

public double getSellPrice(){
Calculator calculator = new Calculator();
double price = (double)this.price;
return calculator.calculate(price, 0.8);
}
}
class ComBook extends Book{
boolean hasDisc;

String hasDisc(){
return this.hasDisc==true?"附光碟":"沒光碟";
}
void setHasDisc(boolean hasDisc){
this.hasDisc = hasDisc;
}
ComBook(){

}
ComBook(String name, String author, String publisher,
int price, boolean hasDisc){
super( name, author, publisher, price);
this.hasDisc = hasDisc;
}
}

class Comic extends Book{
boolean isComic;

String isComic(){
return this.isComic==true?"書":"漫畫書";
}
void setHasDisc(boolean isComic){
this.isComic = isComic;
}


class BookShop{
private ComBook[] comBook = new ComBook;
BookShop(){
comBook = new ComBook("資料結構\t","曾志軒\t","碁峰文化\t",500,true);
comBook = new ComBook("J2EE\t\t\t","楊泰昇\t","博碩文化\t",380,true);
comBook = new Comic("火影忍者\t","岸本齊史\t","東立",80,true);
comBook = new ComBook("MacOSX 10.5\t\t","施威銘研究室","旗標\t",560,true);
comBook = new Comic("灌籃高手\t","井上雄彥\t","東立",80,true);
comBook = new ComBook("Java程式設計藝術\t","Deitel\t","全華圖書\t",650,true);

}
public String toString(){
String result = "";
for(int i=0;i<comBook.length;i++){
result += "("+(i ..

訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容




獻花 x0 回到頂端 [樓 主] From:未知地址 | Posted:2008-12-13 19:23 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.061246 second(s),query:15 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言