static void addItem()
        {
            Console.WriteLine("---------------------------");
            Console.WriteLine();
            string input = "";
            string name;
            float  price    = -1f;
            string itemType = "";

            Console.Write("Enter Item name: ");
            name = Console.ReadLine();

            Console.Write("Enter Item price: ");
            input = Console.ReadLine();
            price = float.Parse(input);

            //------------- Edit from this point to implement Clothing --------//
            // Get Item type
            Console.Write("Enter Item type : (F)ood or (C)lothing");
            itemType = Console.ReadLine();

            // Get data for food - this may be of use as an example
            if (itemType.ToLower() == "f")
            {
                int grossWeight = -1;

                Console.Write("Enter Gross Weight: ");
                input       = Console.ReadLine();
                grossWeight = int.Parse(input);

                Console.Write("Is Food (P)erishable or (N)ot: ");
                string p**N = Console.ReadLine();
                // I did not mean for it to be P**n, acedent.... honestly its meant to stand for Perishable Or Not //
                if (p**N.ToLower() == "p")
                {
                    int elpireY = 1;
                    int elpireM = 1;

                    Console.Write("Enter Expirey Year: ");
                    elpireY = int.Parse(Console.ReadLine());
                    Console.Write("Enter Expirey Month: ");
                    elpireM = int.Parse(Console.ReadLine());

                    Perishable newFood = new Perishable(name, price, grossWeight, elpireM, elpireY);
                    items.Add(newFood);
                }
                else if (p**N.ToLower() == "n")
                {
                    int netWeight = 1;

                    Console.Write("Enter Expirey Year: ");
                    netWeight = int.Parse(Console.ReadLine());

                    NonPerishable newFood = new NonPerishable(name, price, grossWeight, netWeight);
                    items.Add(newFood);
                }
                else
                {
                    Console.WriteLine("Sorry, i dont understand that command");
                }
            }
            else if (itemType.ToLower() == "c")
            {
                Console.Write("Enter Size of Clothing: ");
                string size = Console.ReadLine();

                Console.Write("Is Clothing (S)afty or (C)asual: ");
                string sOrC = Console.ReadLine();

                if (sOrC.ToLower() == "s")
                {
                    string rating = "";
                    Console.Write("What is the safty Rating (H, M, L): ");
                    input = Console.ReadLine();
                    if (input.ToLower() == "h")
                    {
                        rating = "H";
                    }
                    else if (input.ToLower() == "M")
                    {
                        rating = "H";
                    }
                    else if (input.ToLower() == "L")
                    {
                        rating = "L";
                    }
                    else
                    {
                        Console.WriteLine("Sorry, i dont understand that command");
                    }
                    Console.Write("Is it already used y/n: ");
                    input = Console.ReadLine();
                    if (input.ToLower() == "y")
                    {
                        Safty newClothing = new Safty(name, price, size, true, rating);
                        items.Add(newClothing);
                    }
                    else if (input.ToLower() == "n")
                    {
                        Safty newClothing = new Safty(name, price, size, false, rating);
                        items.Add(newClothing);
                    }
                    else
                    {
                        Console.WriteLine("Sorry, i dont understand that command");
                    }
                }
                else if (sOrC.ToLower() == "c")
                {
                    string style = "";
                    Console.Write("Is the Style (D)ayWear, (N)ightWear or (S)wimWear): ");
                    input = Console.ReadLine();
                    if (input.ToLower() == "d")
                    {
                        style = "Daywear";
                    }
                    else if (input.ToLower() == "n")
                    {
                        style = "Nightware";
                    }
                    else if (input.ToLower() == "s")
                    {
                        style = "Swimwear";
                    }
                    Console.Write("Is it already used y/n: ");
                    input = Console.ReadLine();
                    if (input.ToLower() == "y")
                    {
                        Casual newClothing = new Casual(name, price, size, true, style);
                        items.Add(newClothing);
                    }
                    else if (input.ToLower() == "n")
                    {
                        Casual newClothing = new Casual(name, price, size, false, style);
                        items.Add(newClothing);
                    }
                    else
                    {
                        Console.WriteLine("Sorry, i dont understand that command");
                    }
                }
                else
                {
                    Console.WriteLine("Sorry, i dont understand that command");
                }
            }
            else
            {
                Console.WriteLine("Sorry, i dont understand that command");
            }
        }
Esempio n. 2
0
        static void addItem()
        {
            Console.WriteLine("---------------------------");
            Console.WriteLine();
            string input = "";
            string name;
            float  price               = -1f;
            string itemType            = "";
            string foodType            = "";
            string clothingType        = "";
            string visibilityselection = "";

            Console.Write("Enter Item name: ");
            name = Console.ReadLine();

            Console.Write("Enter Item price: $");
            input = Console.ReadLine();
            price = float.Parse(input);

            //------------- Edit from this point to implement Clothing --------//
            // Get Item type
            Console.WriteLine("Enter Item type: ");
            Console.WriteLine("(F)ood");
            Console.WriteLine("(C)lothing");
            Console.Write("Enter selection: ");
            itemType = Console.ReadLine();

            // Get data for food - this may be of use as an example
            if (itemType.ToLower() == "f")
            {
                int grossWeight = -1;

                Console.Write("Enter Gross Weight: ");
                input       = Console.ReadLine();
                grossWeight = int.Parse(input);

                Console.WriteLine("Enter Food type: ");
                Console.WriteLine("(P)erishable");
                Console.WriteLine("(N)on Perishable");
                Console.Write("Enter selection: ");
                foodType = Console.ReadLine();

                if (foodType.ToLower() == "p")
                {
                    int expirymonth = 0;
                    int expiryyear  = 0;

                    Console.Write("Enter Expiry Month: ");
                    expirymonth = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Enter Expiry Year: ");
                    expiryyear = Convert.ToInt32(Console.ReadLine());

                    Perishable newPerishable = new Perishable(name, price, grossWeight, expirymonth, expiryyear);
                    items.Add(newPerishable);
                }
                else if (foodType.ToLower() == "n")
                {
                    int netweight = 0;

                    Console.Write("Enter Net Weight: ");
                    netweight = Convert.ToInt32(Console.ReadLine());

                    NonPerishable newNonperishable = new NonPerishable(name, price, grossWeight, netweight);
                    items.Add(newNonperishable);
                }
                else
                {
                    Console.WriteLine("Enter a proper value");
                }

                //Food newFood = new Food(name, price, grossWeight);
                //items.Add(newFood);
            }
            else if (itemType.ToLower() == "c")
            {
                string size = "";

                Console.Write("Enter Clothing Size: ");
                size = Console.ReadLine();

                Console.WriteLine("Enter Clothing type: ");
                Console.WriteLine("(S)afety");
                Console.WriteLine("C(A)sual");
                Console.Write("Enter selection: ");
                clothingType = Console.ReadLine();

                if (clothingType.ToLower() == "s")
                {
                    bool highvisibility = new bool();

                    Console.WriteLine("Is this clothing high visibility?");
                    Console.WriteLine("Y or N");
                    Console.Write("Your selection: ");
                    visibilityselection = Console.ReadLine();

                    if (visibilityselection.ToLower() == "y")
                    {
                        highvisibility = true;
                    }
                    else if (visibilityselection.ToLower() == "n")
                    {
                        highvisibility = false;
                    }
                    else
                    {
                        Console.WriteLine("Enter a proper value");
                    }

                    Safety newSafety = new Safety(name, price, size, highvisibility);
                    items.Add(newSafety);
                }
                else if (clothingType.ToLower() == "a")
                {
                    string brand = "";

                    Console.WriteLine("What brand is this clothing? ");
                    brand = Console.ReadLine();

                    Casual newCasual = new Casual(name, price, size, brand);
                    items.Add(newCasual);
                }
                else
                {
                    Console.WriteLine("Enter a proper value");
                }
                //Clothing newClothing = new Clothing(name, price, size);
                //items.Add(newClothing);
            }


            // ---------------------------------------------------------------//
        }