Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class Sandbox {
- public static void main(String args[]) {
- try {
- File storage = new File("store.txt");
- File purse = new File("purse.txt");
- Double[] coins = { 0.10, 0.2, 0.5, 1.0, 2.0 };
- ArrayList<Double> coinsList = new ArrayList<Double>();
- Collections.addAll(coinsList, coins);
- Application app = new Application(storage, purse, coinsList);
- Scanner sc = new Scanner(System.in);
- while(true){
- System.out.print("Enter command: ");
- try {
- app.execute(sc.nextLine());
- } catch(IndexOutOfBoundsException e){
- System.out.print("No such item! ");
- } catch(NumberFormatException e){
- System.out.print("Invalid parameter! ");
- } catch(Exception e){
- System.out.print(e.getMessage() + "! ");
- }
- }
- } catch(Exception e){
- System.out.println(e);
- e.printStackTrace();
- System.out.println("Unexpected error, sorry!");
- }
- }
- }
Add Comment
Please, Sign In to add comment