Ejemplo n.º 1
0
 public void undoBuy(FoodItem item, int undo)
 {
     for(int i = 0; i < items.Length; i++)
     {
        if (items[i].getName().Equals(item.getName()))
         {
             items[i].undoSold(undo);
          }
     }
 }
Ejemplo n.º 2
0
        /**
        * add an item to the reciept and its price to the bill
        *
        * newItem the food item to add
        */
        public void addItem(FoodItem newItem)
        {
            if(iNumItems >= itemsBought.Length)
            {
                return;
            }
            fBill += newItem.getPrice();
            itemsBought[iNumItems] = new FoodItem(newItem.getName(), newItem.getPrice(), newItem.getTime());
            itemsBought[iNumItems].setAmountSold(1);
            iNumItems++;

            this.updateTotalItemBought(newItem);
        }
Ejemplo n.º 3
0
 public void addItem(FoodItem item)
 {
     items[numFoods] = item;
     numFoods++;
 }
Ejemplo n.º 4
0
        /**
        * searches and updates one common item to have a total count of the number sold
        *
        * returns 0 if successful
        * returns 1 in nothing removed
        */
        public void updateTotalItemBought(FoodItem item)
        {
            for (int i = 0; i < itemsBought.Length; i++)
            {
                if (itemsBought[i] != null && itemsBought[i].getName().Equals(item.getName()))
                {
                    itemsBought[i].setAmountSold(itemsBought[i].getSold() + 1);
                    return;
               }

            }
        }
Ejemplo n.º 5
0
        /**
        * searches and removes one instance of a food item with the name of the given item
        *
        * returns 0 if successful
        * returns 1 in nothing removed
        */
        public int removeItem(FoodItem item)
        {
            fBill -= item.getPrice();

            for(int i = 0; i < itemsBought.Length; i++)
            {
                if(itemsBought[i] != null && itemsBought[i].getName().Equals(item.getName()))
                {
                    itemsBought[i] = null;

                    return 0;
                }

            }
            return 1;
        }
Ejemplo n.º 6
0
        /**
         * searches and removes one instance of a food item with the name of the given item
         *
         * returns 0 if successful
         * returns 1 in nothing removed
         */
        public int removeAllItem(FoodItem item)
        {
            fBill -= item.getPrice();

            int i = 0;
            ArrayList temp = new ArrayList();

            foreach (FoodItem list in itemsBought)
            {
                if (list != null && list.getName().Equals(item.getName()))
                {
                    list.setAmountSold(0);
                }

            }

            return 1;
        }
Ejemplo n.º 7
0
        Table[] tables = new Table[16]; //an array representing the table objects for the restaurant

        #endregion Fields

        #region Constructors

        /*
            Constructor
            Initializes the buttons and creates all objects necessary for the program
        */
        public Sections()
        {
            InitializeComponent();
            buttons = new Button[16]{tableButton1, tableButton2, tableButton3, tableButton4, tableButton5, tableButton6,  tableButton7,
                    tableButton8, tableButton9, tableButton10, tableButton11, tableButton12,  tableButton13, tableButton14,
                    tableButton15, toGoTable};

            tableBoxes = new PictureBox[16]{pictureBox1,pictureBox2,pictureBox3,pictureBox4,pictureBox5,pictureBox6,pictureBox7,
                        pictureBox8,pictureBox9,pictureBox10,pictureBox11,pictureBox12,pictureBox13,pictureBox14,pictureBox15,pictureBox16};
            //update button names
            for(int i = 0; i < buttons.Length;i++)
            {
                buttons[i].Text = "Table " + (i+1);
                buttons[i].BackColor = Color.Green;
            }
            buttons[15].Text = "TOGO";

            //initialize the staff members
            for(int i = 0; i < staff.Length; i++)
            {
                staff[i] = new Employee("Employee " + (i + 1));
            }

            //initialize the table objects
            for (int i = 0; i < tables.Length; i++)
            {
                tables[i] = new Table();
                tables[i].setTableNum(i + 1);

                //set certain employees to their corresponding tables
                if(i < 3)
                {
                    tables[i].setEmployee(staff[0]);
                }
                else if( i < 6 )
                {
                    tables[i].setEmployee(staff[1]);
                }
                else if( i < 9)
                {
                    tables[i].setEmployee(staff[2]);
                }
                else if( i < 12)
                {
                    tables[i].setEmployee(staff[3]);
                }
                else if( i < 15)
                {
                    tables[i].setEmployee(staff[4]);
                }
            }

            string userName = Environment.UserName;
            Console.WriteLine(userName);
            string[] menuFile = System.IO.File.ReadAllLines(@"C:\Users\" + userName + @"\Dropbox\CS 341\Waitstaff\menu.txt");
            menu = new FoodMenu(19);
            FoodItem temp;
            for(int i = 0; i < menuFile.Length; i+=4)
            {
                try
                {
                    Console.WriteLine("" + menuFile[i] + " "+ Int32.Parse(menuFile[i + 1]) + " " +Int32.Parse(menuFile[i + 2]));
                    temp = new FoodItem(menuFile[i], Int32.Parse(menuFile[i + 1]), Int32.Parse(menuFile[i + 2]));
                    menu.addItem(temp);

                }
                catch(Exception e)
                {
                    break;
                }
            }

            for(int i = 0; i < 19; i++)
            {
                if(menu.getFoodItem(i) == null)
                {
                    temp = new FoodItem("0", 0, 0);
                    menu.addItem(temp);

                }
            }
        }