// public OrderClient(UserClient user, Store store, List<Transaction> orderRepo, ReadOrderNumberDelegate readOrderNumber, WriteOrderNumberDelegate writeOrderNumber, WriteDelegate writeData)
        public OrderClient(UserClient user, Store store, List <Transaction> orderRepo)
        {
            this.theOrders    = orderRepo;
            this.CurrentUser  = user;
            this.CurrentStore = store;
            MyPizzas          = new List <APizza>();
            this.TotalCost    = 0;

            // this.readOrderNumber = readOrderNumber;
            // this.writeOrderNumber = writeOrderNumber;
            // this.writeData = writeData;

            pizzaFactory = new PizzaFactory();
        }
示例#2
0
        private static void Main(string[] args)
        {
            // Loading data from repository

            // UserRepository.Create();
            // OrderRepository.Create();

            Hashtable usersData = UserRepository.readData();

            string[]           storesData = StoreRepository.stores;
            List <Transaction> ordersData = OrderRepository.ReadData();


            bool option = true;
            int  inputValue;

            Console.WriteLine("Welcome to PizzaBox!!\n");

            while (option)
            {
                Console.WriteLine("Select the following Options");
                Console.WriteLine("[0] To Login\n[1] To Create an Account\n[2] To Quit");

                string inputString = Console.ReadLine();
                if (!int.TryParse(inputString, out inputValue))
                {
                    System.Console.WriteLine("Please try again.\n");
                    inputValue = 4;
                }

                UserClient  currentUser  = new UserClient(usersData);                              //, UserRepository.writeData);
                Store       currentStore = new Store(storesData);
                OrderClient currentOrder = new OrderClient(currentUser, currentStore, ordersData); //, OrderRepository.ReadOrderNum, OrderRepository.StoreOrderNum, OrderRepository.WriteData);

                /**************
                * User Login *
                **************/
                if (inputValue == 0)
                {
                    if (currentUser.Login())
                    {
                        // if (Login(currentUser)) {
                        currentUser.ViewOrderHistory(currentOrder.GetOrders());
                        if (currentUser.CanChangeStore())
                        {
                            currentStore.SelectStore();
                            currentUser.ChangeStore(currentStore.MyStore);

                            currentOrder.StartOrder();
                        }
                        else
                        {
                            currentStore.MyStore = currentUser.LastStore;
                            Console.WriteLine("Your current store is");
                            Console.WriteLine(currentStore.MyAddress);

                            currentOrder.StartOrder();
                        }
                    }

                    /***************
                    * Create User *
                    ***************/
                }
                else if (inputValue == 1)
                {
                    if (currentUser.CreateAccount())
                    {
                        currentStore.SelectStore();
                        currentUser.ChangeStore(currentStore.MyStore);

                        currentOrder.StartOrder();
                    }
                }
                else if (inputValue == 2)
                {
                    option = false;
                }
            }
        }