Esempio n. 1
0
        private void InitializePreMadeSnacks()
        {
            for(int x = 0; x < amountOfColumns; x++)
            {
                preMadeChips[x] = new Chips(chipsCompany, fritoLaysBrands[x], 0, fritoLaysPrice[x]);

                preMadeChocolate[x] = new Chocolate(chocolateCompany, marsBrands[x], 0, marsPrice[x]);

                preMadeCookies[x] = new Cookies(cookiesCompany, nabiscoBrands[x], 0, nabiscoPrice[x]);

                preMadeGum[x] = new Gum(gumCompany, wrigleyBrands[x], 0, wrigleyPrice[x]);
            }
        }
Esempio n. 2
0
        private void ReadSnackType(string path)
        {
            string line;
            bool finished = false;
            string[] lineValue;
            StreamReader sr = null;
            ISnacks snack = null;

            try
            {
                using (sr = new StreamReader(path))
                {
                    while (!(finished))
                    {
                        line = sr.ReadLine();

                        if (line != null)
                        {
                            lineValue = line.Split(',');

                            if (path == filePaths[0])
                                snack = new Chips(lineValue[0], lineValue[1], Convert.ToInt32(lineValue[2]), Convert.ToDouble(lineValue[3]));
                            else if (path == filePaths[1])
                                snack = new Chocolate(lineValue[0], lineValue[1], Convert.ToInt32(lineValue[2]), Convert.ToDouble(lineValue[3]));
                            else if (path == filePaths[2])
                                snack = new Cookies(lineValue[0], lineValue[1], Convert.ToInt32(lineValue[2]), Convert.ToDouble(lineValue[3]));
                            else if (path == filePaths[3])
                                snack = new Gum(lineValue[0], lineValue[1], Convert.ToInt32(lineValue[2]), Convert.ToDouble(lineValue[3]));

                            SnacksPresent.Add(snack);
                        }
                        else
                            finished = true;
                    }
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }