Beispiel #1
0
        public static string FromArray(Garage <Vehicle> garage)
        {
            Console.Clear();
            Scene.title();
            int k = -1;

            for (int i = 0; i < garage.ToArray().Length; i++)
            {
                Console.WriteLine("\nSlot number: " + (i + 1) + " " + garage.ToArray()[i].Stats());
            }

            do
            {
                Console.WriteLine("\nType the slot number of the vehicle you whant to remove");
                Console.Write("> ");
                try
                {
                    k = int.Parse(Console.ReadLine());
                }
                catch
                {
                    Console.WriteLine("Invalid input");
                }
            } while (k < 1);

            int idxrem = k;

            if (k < 1 || k > garage.ToArray().Length)
            {
                Console.WriteLine("Det är bara och starta om dumstrut");
            }
            else
            {
                garage.RemoveFromArray(idxrem);
            }

            Console.ReadKey();
            return("");
        }
Beispiel #2
0
        static void ShowType(Garage <Vehicle> garage, int c)
        {
            Console.Clear();
            Scene.title();

            int car    = 0;
            int aplane = 0;
            int mc     = 0;
            int buss   = 0;
            int boat   = 0;
            int tank   = 0;

            for (int i = 0; i < garage.ToArray().Length; i++)
            {
                if (garage.ToArray()[i].GetType() == typeof(Car))
                {
                    car++;
                }
                else if (garage.ToArray()[i].GetType() == typeof(Airplane))
                {
                    aplane++;
                }
                else if (garage.ToArray()[i].GetType() == typeof(Buss))
                {
                    buss++;
                }
                else if (garage.ToArray()[i].GetType() == typeof(Boat))
                {
                    boat++;
                }
                else if (garage.ToArray()[i].GetType() == typeof(Motorcycle))
                {
                    mc++;
                }
                else if (garage.ToArray()[i].GetType() == typeof(Tank))
                {
                    tank++;
                }
            }
            Console.WriteLine("There are:"
                              + "\n" + car + " Cars"
                              + "\n" + aplane + " Airplanes"
                              + "\n" + buss + " Busses"
                              + "\n" + boat + " Boats"
                              + "\n" + mc + " Motorcycles"
                              + "\n" + tank + " Tanks"
                              + "\nIn the garage");

            Console.ReadKey();
        }