コード例 #1
0
        public static void Mutate()
        {
            Console.WriteLine("Muteer voorraad:\n");
            Console.WriteLine("Vul het id waarvan u de voorraad wilt veranderen in.");
            int MutatieID;

            try
            {
                MutatieID = Convert.ToInt32(Console.ReadLine());
                for (int i = 0; i < MPlayerArrayList.Count; i++)
                {
                    MPlayer temp = (MPlayer)MPlayerArrayList[i];
                    if (temp.Player_id == MutatieID)
                    {
                        Console.WriteLine("How much MP3 Players were bought(+) or sold(-)?");
                        int MutatieMod = Convert.ToInt32(Console.ReadLine());
                        temp.Player_stock   = temp.Player_stock + MutatieMod;
                        MPlayerArrayList[i] = temp;
                        Console.WriteLine("ID: " + temp.Player_id + ", voorraad: " + temp.Player_stock);
                        Console.ReadKey();
                        Console.Clear();
                    }
                }
            }
            catch (System.FormatException)
            {
                Console.WriteLine("U heeft een ongeldige waarde ingevoerd.");
                return;
            }
        }
コード例 #2
0
        public static void Stats()
        {
            MPlayer temp  = (MPlayer)MPlayerArrayList[0];
            MPlayer temp2 = (MPlayer)MPlayerArrayList[1];
            MPlayer temp3 = (MPlayer)MPlayerArrayList[2];
            MPlayer temp4 = (MPlayer)MPlayerArrayList[3];
            MPlayer temp5 = (MPlayer)MPlayerArrayList[4];

            int TotalMp3     = temp.Player_stock + temp2.Player_stock + temp3.Player_stock + temp4.Player_stock + temp5.Player_stock;
            int PriceMp3     = (temp.Player_stock * Convert.ToInt32(temp.Player_price)) + (temp2.Player_stock * Convert.ToInt32(temp2.Player_price)) + (temp3.Player_stock * Convert.ToInt32(temp3.Player_price)) + (temp4.Player_stock * Convert.ToInt32(temp4.Player_price)) + (temp5.Player_stock * Convert.ToInt32(temp5.Player_price));
            int AveragePrice = Convert.ToInt32(temp.Player_price + temp2.Player_price + temp3.Player_price + temp4.Player_price + temp5.Player_price) / 5;


            Console.WriteLine("Statistics: ");
            Console.WriteLine();
            Console.WriteLine("Total amount of MP3 Players in stock: " + TotalMp3);
            Console.WriteLine("Total price of all MP3 Players in stock: " + PriceMp3 + " euro's.");
            Console.WriteLine("Average price of players at SoundSharp: " + AveragePrice + " euro's");

            Console.ReadKey();
            Console.Clear();
        }