예제 #1
0
        //Fråga: this? Förhållande mellan field och prop, get/set? Se metod nedan.

        public void LaggTillFordon(Fordon fordon)
        {
            //Använda switch här eller i main?
            //Fordonstyp x = 0;

            //switch (x)
            //{
            //    case Fordonstyp.bil:

            //    default:
            //        break;
            //}



            if (fordon is Bil)
            {
                Bilar.Add(fordon as Bil);
            }
            else if (fordon is Motorcykel)
            {
                Motorcyklar.Add(fordon as Motorcykel);
            }
            else if (fordon is Buss)
            {
                Bussar.Add(fordon as Buss);
            }
            else if (fordon is Lastbil)
            {
                Lastbilar.Add(fordon as Lastbil);
            }
            //else    //felkontroll
        }
예제 #2
0
파일: Program.cs 프로젝트: hrodvar/Bilar
 static void Main(string[] args)
 {
     // added some crap
     Console.WriteLine("hello!");
     Bilar bilar = new Bilar("family car", "blue", 4, 1);
     Console.WriteLine("Type of car: " + bilar.Type +
         "\nColor of the car: " + bilar.Color +
         "\nNumber of whells: " + bilar.NumberOfWheel);
     Bilar Lastbilar = new Bilar("Truck", "Green", 12, 1);
     Console.WriteLine("\nType of car: " + Lastbilar.Type +
         "\nColor of the car: " + Lastbilar.Color +
         "\nNumber of whells: " + Lastbilar.NumberOfWheel);
     bilar.TalkAboutYourCar();
     Lastbilar.TalkAboutYourCar();
 }
예제 #3
0
파일: Program.cs 프로젝트: Nitad/TestBilar
        static void Main(string[] args)
        {
            var saab = new Bilar("Saab", 4, 90);
            var BMW = new Bilar("BMW", 4, 200);

            Console.WriteLine(saab.CountWheels());
            Console.WriteLine(BMW.CountHorsepower());
            Console.ReadLine();

            ConsoleKeyInfo KeyInfo;
            do
            {
                Console.Clear();
                Console.WriteLine("You are in your Saab. Press enter to burnout...");
                KeyInfo = Console.ReadKey();
                saab.burnOut();
                Console.ReadLine();
            } while (KeyInfo.Key != ConsoleKey.Escape);
        }