Exemple #1
0
        private static void Main(string[] args)
        {
            int  a     = 1;
            Load check = new Load();

            MP3.Mp3Info();

            Console.WriteLine("SoundSharp\n");

            while (a == 1)
            {
                Load.LogIn();
                a++;
            }
            Console.WriteLine("----MENU----\n");
            string[] menuArray = { "1. Overview mp3 players", "2. Overview stock", "3. Mutate stock", "4. Statistics", "5. Add new mp3",
                                   "8. Menu",                 "9. Exit" };

            foreach (string Menu in menuArray)
            {
                Console.WriteLine(Menu);
            }
            while (a == 2)
            {
                Load.ShowMenu();
            }
        }
Exemple #2
0
 static void showStock()
 {
     foreach (ProductInfo p in MP3.GetPlayers())
     {
         Console.WriteLine("MP3 Player " + p.intId + "");
         Console.WriteLine("Stock: " + p.intStock + "\n");
     }
     ShowMenu();
 }
Exemple #3
0
 static void showProducts()
 {
     foreach (ProductInfo p in MP3.GetPlayers())
     {
         Console.WriteLine("MP3 Player " + p.intId + "\n");
         Console.WriteLine("Make:\t\t" + p.strMake);
         Console.WriteLine("Model:\t\t" + p.strModel);
         Console.WriteLine("Size(Mb):\t" + p.dblSize);
         Console.WriteLine("Price:\t\t$" + p.dblPrice + "\n");
     }
     ShowMenu();
 }
Exemple #4
0
        static void Mp3Add()
        {
            Console.WriteLine("Enter a new Mp3 player");
            foreach (ProductInfo p in MP3.GetPlayers())
            {
                Console.WriteLine("Make: ");
                string make = Console.ReadLine();
                Console.WriteLine("Model: ");
                string model = Console.ReadLine();
                Console.WriteLine("Mb Size: ");
                double size = double.Parse(Console.ReadLine());
                Console.WriteLine("Price: ");
                double price = double.Parse(Console.ReadLine());

                int id = MP3.Product.Count + 1;

                MP3.Product.Add(new ProductInfo(id, make, model, size, price));
                ShowMenu();
            }
        }
Exemple #5
0
        static void NewStock()
        {
            Console.WriteLine("Vul het ID in van de MP3 speler: ");
            string mutateID = Console.ReadLine();

            if (string.IsNullOrEmpty(mutateID) || !mutateID.All(char.IsDigit))
            {
                Console.WriteLine("Wrong ID input!");
                NewStock();
            }
            else
            {
                int intMutateID = int.Parse(mutateID);
                foreach (ProductInfo p in MP3.GetPlayers())
                {
                    if (intMutateID == p.intId)
                    {
                        Console.WriteLine("Vul nieuwe stock waarde in:");
                        string strStock    = Console.ReadLine();
                        int    intNewStock = int.Parse(strStock);
                        if (strStock == string.Empty)
                        {
                            Console.WriteLine("You didn't enter anything");
                        }
                        else if (!strStock.All(char.IsDigit))
                        {
                            Console.WriteLine("You entered an invalid new stock!");
                        }
                        else
                        {
                            p.Storage = intNewStock;
                            Console.WriteLine("You have succesfully updated the stock for MP3 player {0} to {1}",
                                              p.intId,
                                              p.intStock);
                            ShowMenu();
                        }
                    }
                }
            }
            ShowMenu();
        }
Exemple #6
0
        public static void MutateStruct(ArrayList mp3Array)
        {
            Console.WriteLine("Please input the ID of which MP3 player you want to change the stock");
            try
            {
                int inputID = Convert.ToInt32(Console.ReadLine());

                for (int i = 0; i < mp3Array.Count; i++)
                {
                    if (inputID == ((MP3)mp3Array[i]).id)
                    {
                        MP3 selectedMP3 = ((MP3)mp3Array[i]);

                        Console.WriteLine("Model: {0} {1} selected, how many are left in stock?", selectedMP3.brand, selectedMP3.model);
                        int inputStock = Convert.ToInt32(Console.ReadLine());

                        if (inputStock >= 0)
                        {
                            Console.WriteLine("De stock inhoud van {1} {2} is aangepast naar: {0}", inputStock, selectedMP3.brand, selectedMP3.model);
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("Error: please enter a value greater then 0");
                            Console.ResetColor();
                        }
                    }
                }
            }
            catch
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Error: please enter a number");
                Console.ResetColor();
            }
        }
Exemple #7
0
        public static void ShowMenu()
        {
            //menu to show options
            ShowOptionMenu();

            //get all MP3 players
            ArrayList mp3Array = CreateStruct();

            //loop for key imput for available options
            while (true)
            {
                char keyChar = Console.ReadKey(true).KeyChar;

                if ((int)keyChar == 57)
                {
                    //9 button pressed, exit loop and program
                    break;
                }
                else if ((int)keyChar == 52)
                {
                    ShowStatistics(mp3Array);
                }
                else if ((int)keyChar == 53)
                {
                    //5 button is pressed. add mp3
                    //make new unique ID
                    int newMP3Id = mp3Array.Count + 1;

                    //get Brand name
                    Console.WriteLine("Please enter the brand name of the MP3 player.");
                    string newMP3Brand = Console.ReadLine();

                    //get Model name
                    Console.WriteLine("Please enter the Model name.");
                    string newMP3Model = Console.ReadLine();

                    //get storage amount
                    int newMP3Storage;
                    try
                    {
                        Console.WriteLine("Please enter the amount of storage in MB");
                        newMP3Storage = Convert.ToInt32(Console.ReadLine());
                    }
                    catch
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("please enter a number.");
                        Console.ResetColor();
                        return;
                    }
                    //get price
                    double newMP3Price;
                    try
                    {
                        Console.WriteLine("Please enter the price, including two decimals. even if i would be ,00");
                        newMP3Price = Convert.ToDouble(Console.ReadLine());
                    }
                    catch
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("please enter a number.");
                        Console.ResetColor();
                        return;
                    }

                    //set Stock amount
                    int newMP3Stock = 0;

                    //make a new MP3 and add it to the ArrayList
                    MP3 newMP3 = new MP3
                    {
                        id           = newMP3Id,
                        brand        = newMP3Brand,
                        model        = newMP3Model,
                        storageSpace = newMP3Storage,
                        price        = newMP3Price,
                        stock        = newMP3Stock
                    };

                    mp3Array.Add(newMP3);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("MP3 player added");
                    Console.ResetColor();
                }
                else if ((int)keyChar == 56)
                {
                    Console.Clear();
                    //8 button pressed, show menu again
                    ShowOptionMenu();
                }
                else if ((int)keyChar == 49)
                {
                    Console.Clear();
                    //1 button pressed, show all MP3 players by looping through them
                    foreach (MP3 i in mp3Array)
                    {
                        Console.WriteLine("");
                        Console.WriteLine(i.id);
                        Console.WriteLine(i.brand);
                        Console.WriteLine(i.model);
                        Console.WriteLine(i.storageSpace);
                        Console.WriteLine(i.price);
                    }
                    Console.WriteLine("");
                    Console.WriteLine("Press 8 to return back to the menu.");
                    Console.WriteLine("Press 9 to exit the console.");
                }
                else if ((int)keyChar == 50)
                {
                    Console.Clear();
                    //2 button pressed, show available stock by looping through all of them
                    foreach (MP3 i in mp3Array)
                    {
                        Console.WriteLine("");
                        Console.WriteLine(i.id);
                        Console.WriteLine(i.stock);
                    }
                    Console.WriteLine("");
                    Console.WriteLine("Press 8 to return back to the menu.");
                    Console.WriteLine("Press 9 to exit the console.");
                }
                else if ((int)keyChar == 51)
                {
                    Console.Clear();
                    //3 button pressed, mutate stock
                    MutateStruct(mp3Array);
                    Console.WriteLine("");
                    Console.WriteLine("Press 8 to return back to the menu.");
                    Console.WriteLine("Press 9 to exit the console.");
                }
            }
            Console.WriteLine("press any key to close the program");
            Console.ReadKey();
        }
Exemple #8
0
        public static ArrayList CreateStruct()
        {
            //make mp3 players and put them in Array list
            MP3 first = new MP3
            {
                id           = 1,
                brand        = "GET technologies.inc",
                model        = "HF 410",
                storageSpace = 4096,
                price        = 129.95,
                stock        = 500
            };

            MP3 second = new MP3
            {
                id           = 2,
                brand        = "Far & Loud",
                model        = "XM 600",
                storageSpace = 8192,
                price        = 224.95,
                stock        = 500
            };

            MP3 third = new MP3
            {
                id           = 3,
                brand        = "Innotivative",
                model        = "Z3",
                storageSpace = 4096,
                price        = 124.95,
                stock        = 500
            };

            MP3 fourth = new MP3
            {
                id           = 4,
                brand        = "Resistance S.A.",
                model        = "3001",
                storageSpace = 4096,
                price        = 124.95,
                stock        = 500
            };

            MP3 fifthMP3 = new MP3
            {
                id           = 5,
                brand        = "CBA",
                model        = "NXT volume",
                storageSpace = 2048,
                price        = 159.05,
                stock        = 500
            };

            ArrayList mp3Array = new ArrayList();

            mp3Array.Add(first);
            mp3Array.Add(second);
            mp3Array.Add(third);
            mp3Array.Add(fourth);
            mp3Array.Add(fifthMP3);

            return(mp3Array);
        }