1,实现循环购书功能
(1)for------->while
(2)OrderItem[]数组尽量给大些
2,购买相同的书籍,数量进行叠加
(1)使用循环检查数组是是否存在书籍信息,存在则叠加数量,否则添加到数组中
(2)数组采用传址引用方式
3,解决购买时图书编号、图书价格的输入问题
(1)输入不存在的编号
(2)非法输入
4,解决库存量显示问题
(1)库存为0的书籍不显示
(2)库存不足不能购买
(3)购买成功后更新库存
public class Book {
private int bookId;//图书编号
private String bookName;//图书名称
private double price;//图书单价
private int storage;//库存数量
//无参构造
public Book() {
super();
}
//带参构造
public Book(int bookId, String bookName, double price, int storage) {
super();
this.bookId = bookId;
this.bookName = bookName;
this.price = price;
this.storage = storage;
}
public int getBookId() {
return bookId;
}
public void setBookId(int bookId) {
this.bookId = bookId;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getStorage() {
return storage;
}
public void setStorage(int storage) {
this.storage = storage;
}
//重写toString方法
public String toString() {
// TODO Auto-generated method stub
return bookId+"\t"+bookName+"\t"+price+"\t