package tui; import domain.Product; import fassade.OnlineShopSystem; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; public class TUI { private OnlineShopSystem shop; private Scanner sc; public static void main(String[] args) { try { new TUI(); } catch ( FileNotFoundException e){ System.out.print("Storage list couldn't be loaded. \n"); System.out.print("Cancelling. \n\n"); } } public TUI () throws FileNotFoundException { sc = new Scanner(System.in); String filePath = welcomeMessage(); shop = new OnlineShopSystem(filePath); itemListing(); while (true){ itemSearch(); } } private String welcomeMessage(){ System.out.println("Welcome to the Bauhaus online shop!"); System.out.print("Please input the product list location: "); return sc.nextLine(); } private void itemListing(){ System.out.print("We have this items in our storage: \n\n"); System.out.println(shop.listAllProducts()); } private void itemSearch(){ System.out.print("What are you looking for? \n"); System.out.print("> "); String searchQueue = sc.nextLine(); ArrayList searchResults = shop.getSearchResult(searchQueue); for (String result : searchResults) { System.out.println(result); System.out.println(); } } }