Exemple #1
0
        static void Main(string[] args)
        {
            Cars      car   = new Cars(true);
            MotorBike motor = new MotorBike(true);
            Boat      boat  = new Boat();

            car.Steer();
            car.SteerLeft(true);
            car.SteerRight(false);
            car.directio(true, false);
            car.Reverse();

            motor.Steer();
            motor.SteerLeft(true);
            motor.directio(true, true);
            motor.SteerRight(false);

            boat.Steer();
            boat.SteerLeft(true);
            boat.directio(false, true);
            boat.SteerRight(false);
            boat.Reverse();



            motor.Start();
            Console.WriteLine(motor.IsOn);
            motor.SteerLeft(false);
            motor.Stop();
            Console.WriteLine(motor.IsOn);

            car.Start();
            Console.WriteLine(car.IsOn);

            car.Stop();
            Console.WriteLine(car.IsOn);

            Console.ReadLine();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("car: c");
            Car c = new Car();

            Console.WriteLine(c.IsOn);
            c.Start();
            c.SteerLeft();
            c.SteerRight();
            c.Reverse();
            c.Break();
            c.Stop();
            Console.WriteLine(c.IsOn);

            Console.WriteLine("motorbike: m");
            MotorBike m = new MotorBike();

            Console.WriteLine(m.IsOn);
            m.Start();
            m.SteerLeft();
            m.SteerRight();
            m.Break();
            m.Stop();
            Console.WriteLine(m.IsOn);

            Console.WriteLine("boat: b");
            Boat b = new Boat();

            Console.WriteLine(b.IsOn);
            b.Start();
            b.SteerLeft();
            b.SteerRight();
            b.Reverse();
            b.Stop();
            Console.WriteLine(b.IsOn);
        }
        static void Main(string[] args)
        {
            // NO NO can't have instances of an abstract class or interface
            //AutoMobile auto = new AutoMobile();

            //Console.WriteLine("car c");
            //Car c = new Car(true);
            //c.SteerLeft();

            Console.WriteLine("car");
            Car car = new Car();

            Console.WriteLine(car.IsOn);
            car.Start();
            car.SteerLeft();
            Console.WriteLine(car.Steering);
            Console.WriteLine(car.Steering);
            Console.WriteLine(car.Steering);
            car.SteerRight();
            Console.WriteLine(car.Steering);
            Console.WriteLine(car.Steering);
            car.SteerLeft();
            Console.WriteLine(car.Steering);
            Console.WriteLine(car.Steering);
            Console.WriteLine(car.IsOn);

            car.Stop();
            Console.WriteLine(car.IsOn);

            // with private set doesn't work
            //car.IsOn = false;



            Console.WriteLine("motorbike");
            MotorBike moto = new MotorBike();

            moto.Start();
            moto.SteerLeft();
            moto.SteerRight();
            moto.Stop();
            Console.WriteLine(moto.IsOn);

            //Console.WriteLine("motorbike moto2");
            //MotorBike moto2 = new MotorBike(true);
            //Console.WriteLine(moto2.IsOn);
            //moto2.SteerLeft();
            //moto2.Stop();
            //Console.WriteLine(moto2.IsOn);
            Console.WriteLine("Boat");
            Boat boat = new Boat();

            Console.WriteLine(boat.IsOn);
            boat.Start();
            boat.SteerLeft();
            boat.SteerRight();
            boat.Stop();
            Console.WriteLine(boat.IsOn);



            Console.ReadLine();
        }