📄 mainclass.java
字号:
package problem_10;
//MainClass.java
import java.io.*;
public class MainClass {
public static void main(String[] args){
try{
//读入书籍信息
System.out.print("Number of books = ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Integer bookNum = new Integer(Integer.valueOf(br.readLine()));
Bag bookBag = new Bag(); //构造Bag类对象
//从指定文件读取书籍信息并对信息进行处理
FileInputStream fis = new FileInputStream("D:\\BookList.txt");
br = new BufferedReader(new InputStreamReader(fis));
String tempAll = br.readLine();
String[] tempRespect = tempAll.split(";"); //拆分各书
for(int i = 0; i < bookNum.intValue(); i++){ //拆分各项并向书包中添加各书
String[] temp = tempRespect[i].split(",");
Double tempPrice = Double.valueOf(temp[4]);
bookBag.add(new Book(temp[0], temp[1], temp[2], temp[3], tempPrice.doubleValue()));
}
BookShelf bookShelf = new BookShelf(bookBag); //构造书架类
bookShelf.displayBookShelf(); //显示书架
}
catch(IOException e){
System.out.println(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -