mainclass.java

来自「大学java作业源程序」· Java 代码 · 共 31 行

JAVA
31
字号
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 + =
减小字号Ctrl + -
显示快捷键?