Good afternoon!
I am doing a mini-bookstore program, and we need to read a file based on what the customer buys on the specified counter as follows:
counter 4,book1 2,book2 2,book3 2,tender 100.00
counter 1,book1 2,book2 1,book3 3, book4 5,tender 200.00
counter 1,book3 1,tender 50.00
In short, the format is: COUNTER → ITEMS BOUGHT → TENDER
I tried to do this, but it is not so efficient:
public List<String> getOrder(int i) {
List <String> tempQty = new ArrayList<String>();
String[] orders = orderList.get(0).split(",");
for (String order : orders) {
String[] fields = order.split(" ");
tempQty.add(fields[i]);
}
return tempQty;
}
How can I read the file and at the same time guarantee that I put it on the correct array? Besides the counter and the tender, I need to know the name of the book and the quantity so that I can get the price and the computer for the total price. Do I need to make multiple arrays to store all the values? Any suggestions / codes would be highly appreciated.
Thank.
source
share