001package myhw3.main; 002 003import myhw3.data.Data; 004import myhw3.ui.UI; 005 006class Main { 007 public static void main(String[] args) { 008 UI ui = null; 009 010 if (args.length > 0) { 011 if ("GUI".equalsIgnoreCase(args[0])) { 012 ui = new myhw3.ui.PopupUI(); 013 } else if ("TEXT".equalsIgnoreCase(args[0])) { 014 ui = new myhw3.ui.TextUI(); 015 } else { 016 System.out.println("Argument must be GUI or TEXT"); 017 System.exit(1); 018 } 019 } else { 020 if (Math.random() <= 0.5) { 021 ui = new myhw3.ui.TextUI(); 022 } else { 023 ui = new myhw3.ui.PopupUI(); 024 } 025 } 026 Control control = new Control(Data.newInventory(), ui); 027 control.run(); 028 } 029}