Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");
            // Allocate and configure a Car object.
            Car myCar = new Car();
            myCar.currSpeed = 10;
            myCar.petName = "Herry";

            for (int i = 0; i <= 10; ++i)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            Car chuck = new Car();
            chuck.PrintState();

            Car daisy = new Car("Daisy", 75);
            daisy.PrintState();

            Console.WriteLine("Test:");
            // Car Jon = new Car("Jon");
            myCar.SetDriveName("Hello");
            myCar.PrintState();

            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun With Claa Type****");
            Console.WriteLine("Just write it's");
            // розместить в памяти и конфигурировать обьект типа Car
            Car firstCar = new Car();
            firstCar.PrintState();
            firstCar.currSpeed = 17;
            firstCar.carName = "zapar";
            // SpeedUP
            for (int i = 0; i <= 3; i++)
            {
                firstCar.SpeedUp(10);
                firstCar.PrintState();
            }

            Car secondCar = new Car(100, "Maliby");
            secondCar.PrintState();
            Car thredCar = new Car("Lover");
            thredCar.PrintState();
            Console.WriteLine("MOTO");
            Moto firstMoto = new Moto();
            firstMoto.PopAWheely();
            Moto secondMoto = new Moto(3);
            secondMoto.PopAWheely();
            Console.WriteLine("Rider name is {0}", secondMoto.name);

            Ship firstShip = new Ship("Ship", 160);
            firstShip.printShip();
            Console.ReadLine();
            //firstShip.weight = 150;
            //firstShip.name = "Chippo";
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            Car myCar = new Car();
            myCar.petName = "Henry";
            myCar.currSpeed = 10;

            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            Car chuck = new Car();
            chuck.PrintState();

            Car mary = new Car("Mary");
            mary.PrintState();

            Car daisy = new Car("Daysy", 75);
            daisy.PrintState();

            Motorcycle mc = new Motorcycle();
            mc.PopAWheely();

            Motorcycle c = new Motorcycle(5);
            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Rider name is {0}", c.driverName);

            Console.ReadLine();
        }
Example #4
0
        static void Main(string[] args)
        {
            Console.WriteLine
            (
                "--------------------\n" +
                "Fun With Class Types\n" +
                "--------------------\n"
            );

            // Allocate and Configure a Car object
            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            // Speed up the car a few times and print out the new state
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            Console.WriteLine
            (
                "\n--------------" +
                "\nEnd of Program\n" +
                "--------------"
            );
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
Example #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            // Make a Motorcycle with a rider named Tiny?
            Motorcycle c = new Motorcycle(5);

            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Rider name is {0}", c.driverName); // Prints an empty name value!

            Console.WriteLine();

            // Allocate and configure a Car object.
            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            // Speed up the car a few times and print out the
            // new state.
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            // Allocate and configure a Car object
            Car aCar = new Car();

            aCar.petName   = "Meowings";
            aCar.currSpeed = 10;

            for (int i = 0; i <= 10; i++)
            {
                aCar.SpeedUp(5);
                aCar.PrintState();
            }

            Console.WriteLine("\n**** Fun With Static Data ****");
            Account a1 = new Account(50);

            // Print the current intRate
            Console.WriteLine("Int Rate: {0}", Account.GetIntRate());

            // Try to change the int rate via property
            Account.SetIntRate(0.08);

            // Make a second account
            Account a2 = new Account(100);

            Console.WriteLine("Int Rate: {0}", Account.GetIntRate());

            Console.ReadLine();
        }
Example #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            // Allocate and configure a Car object.
            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            // Speed up the car a few times and print out the new state.
            for (int i = 0; i < 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            Car myCar2;

            myCar2         = new Car();
            myCar2.petName = "Fred";

            // Invoking the default constructor.
            Car chuck = new Car();

            // Prints "Chuck is going 10 MPH."
            chuck.PrintState();

            // Make a Car called Mary going 0 MPH.
            Car mary = new Car("Mary");

            mary.PrintState();

            // Make a Car called Daisy going 75 MPH.
            Car daisy = new Car("Daisy", 75);

            daisy.PrintState();

            Motorcycle mc = new Motorcycle();

            mc.PopAWheely();

            // Make a Motorcycle with a rider named Tiny?
            Motorcycle c = new Motorcycle(5);

            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Rider name is {0}", c.driverName);

            MakeSomeBikes();

            Console.ReadLine();
        }
Example #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            // Chamando constructor Default Motorcycle
            Motorcycle mc = new Motorcycle();

            mc.PopAWheely();

            // Chamando constructor Default
            // Chuck 10 MPH
            Car chuck = new Car();

            chuck.PrintState();

            // Mary 0 MPH
            Car mary = new Car("Mary");

            mary.PrintState();

            // Daisy 75 MPH
            Car daisy = new Car("Daisy", 75);

            daisy.PrintState();

            Console.WriteLine("\n");

            // Aloque e configure um objeto Car.
            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            // Aumenta a velocidade de car algumas vezes e imprime o novo estado
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            Console.WriteLine("\n");

            Motorcycle c = new Motorcycle(5);

            c.setDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Rider name is {0}", c.name);// Imprime nome vazio

            Console.WriteLine("\n");
            MakeSomeBikes();

            Console.ReadLine();
        }
Example #9
0
        public static void Main(string[] args)
        {
            Console.WriteLine("***Fun With Class Types ****");
            Car myCar = new Car
            {
                currSpeed = 10,
                petName   = "Jetta"
            };

            // speed up the car a few times and print our the new stat

            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            //Invoking the default Constructor
            Car chuck = new Car();

            // Prints Chuck is going 10 MPH
            chuck.PrintState();

            // Make  a Car called Marry going 0MPH
            Car mary = new Car("Mary");

            mary.PrintState();

            // Make a Car called Daisy going 75MPH
            Car daisy = new Car("Daisy", 75);

            daisy.PrintState();


            // Using default constructor on Motorcycle class
            Console.WriteLine("MotorCycle Class");
            MotorCycle mc = new MotorCycle();

            mc.PopAWheely();

            // make Motorcyle with a rider named Tiny

            MotorCycle c = new MotorCycle(5);

            c.SetDriverName("Tiny");

            c.PopAWheely();
            Console.WriteLine($" Rider name is  {c.driverName}");

            MakeSomeBikes();
        }
Example #10
0
        static void Main( string[] args )
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            #region Make some motorcycles
            Motorcycle mc = new Motorcycle();
            mc.PopAWheely();
            Console.WriteLine();

            // Make a Motorcycle with a rider named Tiny?
            Motorcycle c = new Motorcycle(5);
            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Rider name is {0}", c.driverName); // Prints an empty name value!
            Console.WriteLine();
            #endregion

            #region Make some cars!
            // Make a Car called Chuck going 10 MPH.
            Car chuck = new Car();
            chuck.PrintState();

            // Make a Car called Mary going 0 MPH.
            Car mary = new Car("Mary");
            mary.PrintState();

            // Make a Car called Daisy going 75 MPH.
            Car daisy = new Car("Daisy", 75);
            daisy.PrintState();

            Console.WriteLine();

            // Allocate and configure a Car object.
            Car myCar = new Car();
            myCar.petName = "Henry";
            myCar.currSpeed = 10;

            // Speed up the car a few times and print out the
            // new state.
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }
            Console.WriteLine();
            #endregion

            MakeSomeBikes();

            Console.ReadLine();
        }
Example #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            #region Make some motorcycles
            Motorcycle mc = new Motorcycle();
            mc.PopAWheely();
            Console.WriteLine();

            // Make a Motorcycle with a rider named Tiny?
            Motorcycle c = new Motorcycle(5);
            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Rider name is {0}", c.driverName); // Prints an empty name value!
            Console.WriteLine();
            #endregion

            #region Make some cars!
            // Make a Car called Chuck going 10 MPH.
            Car chuck = new Car();
            chuck.PrintState();

            // Make a Car called Mary going 0 MPH.
            Car mary = new Car("Mary");
            mary.PrintState();

            // Make a Car called Daisy going 75 MPH.
            Car daisy = new Car("Daisy", 75);
            daisy.PrintState();

            Console.WriteLine();

            // Allocate and configure a Car object.
            Car myCar = new Car();
            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            // Speed up the car a few times and print out the
            // new state.
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }
            Console.WriteLine();
            #endregion

            MakeSomeBikes();

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("*******FUN WITH CLASS TYPES********\n");

            // Make a Motorcycle with a rider named Tiny?
            Motorcycle c = new Motorcycle(5);

            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Rider name is {0}", c.driverName);
            Console.WriteLine();
            // Prints an empty name value!

            //instantiating the motorcycle
            Motorcycle mc = new Motorcycle();

            mc.PopAWheely();

            //invoking the default constructor
            Car chuck = new Car();

            chuck.PrintState();

            //make a car called Mary going 0 km/h.
            Car mary = new Car("Mary");

            mary.PrintState();

            //make a car called Daisy going 75km/.
            Car daisy = new Car("Daisy", 75);

            daisy.PrintState();

            //allocate and configure a Car object.
            Car mycar = new Car();

            mycar.petName   = "Henry";
            mycar.currSpeed = 10;

            //speed up the car a few times
            //and print new state out

            for (int i = 0; i <= 10; i++)
            {
                mycar.SpeedUp(5);
                mycar.PrintState();
            }
            Encapsulation : constructors :
            Console.ReadLine();
        }
Example #13
0
        private static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            Console.WriteLine("\n***** Fun with Class Types *****");

            //Car chuck = new Car();
            //chuck.PrintState();

            //Car mary = new Car("Mary");
            //mary.PrintState();

            //Car daisy = new Car("Daisy", 75);
            //daisy.PrintState();

            //Motorcycle mc = new Motorcycle();
            //mc.PopAWheely();

            Motorcycle c = new Motorcycle(5);

            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Rider name is {0}", c.driverName);

            Motorcycle m1 = new Motorcycle();

            Console.WriteLine("Name = {0}, Intensity = {1}", m1.driverName, m1.driverIntensity);

            Motorcycle m2 = new Motorcycle(name: "Tiny");

            Console.WriteLine("Name = {0}, Intensity = {1}", m2.driverName, m2.driverIntensity);

            Motorcycle m3 = new Motorcycle(7);

            Console.WriteLine("Name = {0}, Intensity = {1}", m3.driverName, m3.driverIntensity);

            Console.ReadLine();
        }
Example #14
0
        private static void FirstCar()
        {
            // allocate and configure a Car object
            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            // speed up the car a few times and print the new state
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }
        }
Example #15
0
        static void Main(string[] args)
        {
            //Car myCar; would cause use of unassigned local variable error
            Car myCar = new Car();
            myCar.PrintState();


            myCar.petName = "Henry";
            myCar.currSpeed = 10;
            for (int i = 0; i<= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            Console.WriteLine();
            Car mary = new Car(pn: "Mary");  //nmaed param
            mary.PrintState();

            Car daisy = new Car("Daisy", 25);
            daisy.PrintState();

            Console.WriteLine();

            Motorcycle c = new Motorcycle();
            c.SetDriverName("AAA");
            Console.WriteLine("Rider name is {0}", c.name);
            Console.WriteLine("Rider name is null: {0}", c.name == null);

            Console.WriteLine();
            Console.WriteLine("=> Constructor flow");
            Motorcycle cc = new Motorcycle(5);
            Console.WriteLine();

            Console.WriteLine("=> Optional params instead of constructor chaining");

            Motorcycle1 m1 = new Motorcycle1();
            Motorcycle1 m2 = new Motorcycle1(name: "Tiny");
            Motorcycle1 m3 = new Motorcycle1(7);
            Motorcycle1 m4 = new Motorcycle1(7, "Tiny2");

            Console.WriteLine("Name = {0}, Intensity = {1}", m1.name, m1.driverIntensity);
            Console.WriteLine("Name = {0}, Intensity = {1}", m2.name, m2.driverIntensity);
            Console.WriteLine("Name = {0}, Intensity = {1}", m3.name, m3.driverIntensity);
            Console.WriteLine("Name = {0}, Intensity = {1}", m4.name, m4.driverIntensity);

            Console.ReadLine();
        }
Example #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** FUN WITH CLASS TYPES *****\n");

            Motorcycle mc = new Motorcycle();

            mc.PopAWheely();

            //Размещаем в памяти и конфигурируем объект Car
            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            //Увеличим скорость автомобиля в несколько раз и выведем новое состояние.
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            Console.WriteLine();

            //Создаем объект Car по имени Chuck со скоростью 10 миль в час (специальный стандартный конструктор)
            Car chack = new Car();

            chack.PrintState();

            //Создаем объект Car по имени Mary со скоростью 0 миль в час (специальный конструктор)
            Car mary = new Car("Mary");

            mary.PrintState();

            //Создаем объект Car по имени Daisy со скоростью 75 миль в час (специальный конструктор)
            Car daisy = new Car("Daisy", 75);

            daisy.PrintState();

            //Создаем объект Motorcycle с мотоциклистом по имени Tiny
            Motorcycle c = new Motorcycle(5);

            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine($"Rider name is {c.driverName}");

            Console.ReadLine();
        }
Example #17
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            // Car constructors
            Car myCar = new Car();
            Car chuck = new Car();
            Car mary  = new Car("Mary");
            Car daisy = new Car("Daisy", 75);

            // Motorcycle constructors
            Motorcycle mc = new Motorcycle();
            Motorcycle c  = new Motorcycle(5);
            Motorcycle m1 = new Motorcycle();
            Motorcycle m2 = new Motorcycle(name: "Tiny");
            Motorcycle m3 = new Motorcycle(7);

            // Change myCar fields.
            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            // Set c's driver name.
            c.SetDriverName("Tiny");

            // Speed up myCar a few times and print out the new state.
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            // Print states for Chuck, Mary, and Daisy.
            chuck.PrintState();
            mary.PrintState();
            daisy.PrintState();

            // mc and c pop a wheely.
            mc.PopAWheely();
            c.PopAWheely();
            Console.WriteLine("The rider of c is {0}", c.driverName);
            Console.WriteLine("Name = {0}, Intensity = {1}", m1.driverName, m1.driverIntensity);
            Console.WriteLine("Name = {0}, Intensity = {1}", m2.driverName, m2.driverIntensity);
            Console.WriteLine("Name = {0}, Intensity = {1}", m3.driverName, m3.driverIntensity);

            Console.ReadLine();
        }
Example #18
0
        static void FunWithClassTypes()
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            //  创建一个叫Chuck的Car,速度为10MPH
            Car chuck = new Car();

            chuck.PrintState();
            Console.WriteLine();

            //  创建一个叫Mary的Car,速度为0MPH
            Car mary = new Car("Mary");

            mary.PrintState();
            Console.WriteLine();

            //  创建一个叫Daisy的Car,速度为75MPH
            Car daisy = new Car("Daisy", 75);

            daisy.PrintState();

            //  分配和设置Car对象
            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            //  将Car加速几次,然后就输出新的状态
            for (int i = 0; i < 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }
            Console.WriteLine();

            Console.WriteLine("***** Fun with class Types *****\n");

            //创建Motorcycle
            Motorcycle c = new Motorcycle(5);

            c.SetDriveName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Rider name is {0}", c.driverName);
            Console.WriteLine();
        }
Example #19
0
        static void Main(string[] args)
        {
            Console.WriteLine("**** Fun with class types ****");
            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }
            Console.WriteLine();

            Car chuckCar = new Car();

            chuckCar.PrintState();
            Console.WriteLine();

            Car mary = new Car("Mary");

            mary.PrintState();
            Console.WriteLine();

            Car dasy = new Car("Dasy", 75);

            dasy.PrintState();
            Console.WriteLine();

            Motorcycle mc = new Motorcycle();

            mc.PopAWheely();
            Console.WriteLine();

            Motorcycle c = new Motorcycle(5);

            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Driver name is {0}", c.driverName);
            Console.WriteLine();

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            // Allocate and configure a Car object.
            Car myCar = new Car();
            myCar.petName = "Henry";
            myCar.currSpeed = 10;

            // Speed up the car a few times and print out the new state.
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            // Invoking the default constructor.
            Car chuck = new Car();

            // Prints "Chuck is going 10 MPH."
            chuck.PrintState();

            // Make a Car called Mary going 0 MPH.
            Car mary = new Car("Mary");
            mary.PrintState();

            // Make a Car called Daisy going 75 MPH.
            Car daisy = new Car("Daisy", 75);
            daisy.PrintState();

            Motorcycle mc = new Motorcycle();
            mc.PopAWheely();

            Motorcycle c = new Motorcycle(5);
            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Rider name is {0}", c.driverName);

            OptMotorcyle omc = new OptMotorcyle(name:"Kevin");
            Console.WriteLine("Opt Rider Name is {0}", omc.driverName);

            Console.ReadKey();
        }
Example #21
0
        static void Main(string[] args)
        {
            Car myCar = new Car();

            myCar.PrintState();

            myCar.PetName   = "Henry";
            myCar.CurrSpeed = 10;
            myCar.MyColor   = Color.GreenYellow;

            myCar.PrintState();

            for (int i = 0; i < 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            Car[] carArray = new Car[10];

            for (int i = 0; i < 10; i++)
            {
                carArray[i]           = new Car();
                carArray[i].CurrSpeed = 5 + i;
                carArray[i].PetName   = $"Car{i}";
                carArray[i].MyColor   = Color.Azure;
            }

            foreach (Car item in carArray)
            {
                item.PrintState();
            }

            Console.WriteLine();

            Car bmw = new Car("Betsy");

            bmw.PrintState();

            Console.ReadLine();
        }
Example #22
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun With Claa Type****");
            Console.WriteLine("Just write it's");
            // розместить в памяти и конфигурировать обьект типа Car
            Car firstCar = new Car();

            firstCar.PrintState();
            firstCar.currSpeed = 17;
            firstCar.carName   = "zapar";
            // SpeedUP
            for (int i = 0; i <= 3; i++)
            {
                firstCar.SpeedUp(10);
                firstCar.PrintState();
            }

            Car secondCar = new Car(100, "Maliby");

            secondCar.PrintState();
            Car thredCar = new Car("Lover");

            thredCar.PrintState();
            Console.WriteLine("MOTO");
            Moto firstMoto = new Moto();

            firstMoto.PopAWheely();
            Moto secondMoto = new Moto(3);

            secondMoto.PopAWheely();
            Console.WriteLine("Rider name is {0}", secondMoto.name);


            Ship firstShip = new Ship("Ship", 160);

            firstShip.printShip();
            Console.ReadLine();
            //firstShip.weight = 150;
            //firstShip.name = "Chippo";
        }
Example #23
0
        static void Main(string[] args)
        {
            Console.WriteLine("Setting Up a car");

            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(3);
                myCar.PrintState();
            }

            Motorcycle c = new Motorcycle(5);

            c.SetDriverName("Tiny");
            c.PopAWheelie();

            Console.WriteLine($"Driver name: {c.name}");
        }
        static void Main(string[] args)
        {
            Console.WriteLine("***** Simple Class Example *****\n");

            Console.WriteLine("-- Motorcycles --");

            // Make a Motorcycle with a rider named Tiny
            Motorcycle myMotorCycle = new Motorcycle(5);

            Console.WriteLine(myMotorCycle); // blank name

            myMotorCycle.SetDriverName("Harley");

            Console.WriteLine($"motorcycle name now set, {myMotorCycle}");
            Console.WriteLine("PopAWheely()");
            myMotorCycle.PopAWheely();

            Console.WriteLine("MakeSomeBikes()");
            MakeSomeBikes();

            Console.WriteLine();
            Console.WriteLine("-- Car Example --");

            // Allocate and configure a Car object.
            Car myCar = new Car();

            myCar.carName      = "BMW i3";
            myCar.currentSpeed = 10;

            // Speed up the car a few times and print out the
            // new state.
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }
            Console.ReadLine();
        }
Example #25
0
        static void Main(string[] args)
        {
            Console.WriteLine("=> Fun with Class Types");

            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            for (int i = 0; i < 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            Car chuck = new Car();

            chuck.PrintState();

            Motorcycle mc = new Motorcycle(1);

            mc.PopAWheely();
        }
Example #26
0
        static void Main(string[] args)
        {
            Console.WriteLine("** Fun with Class Types **\n");

            Car myCar = new Car();
            Car chuck = new Car();

            chuck.PrintState();
            Car mary = new Car("Mary");

            mary.PrintState();
            Car daisy = new Car("Daisy", 75);

            daisy.PrintState();
            myCar.petName   = "Henry";
            myCar.currSpeed = 10;
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }
            Console.ReadLine();
        }
Example #27
0
        /// <summary>
        ///  метод funcCarForHenry описывает несколько вариантов объявление экземплярв классов;
        /// </summary>
        static public void funcCarForHenry()
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            //Разместить в памяти и сконфигурировать объект Car;
            Car myCar = new Car();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            //Альтернативное объявление экземпляра класса Car;
            //Car myCar;
            //myCar = new Car();
            //myCar.petName = "Fred";

            //Увеличитm скорость автомобиля в несколько раз и вывести новое сообщение;
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.printState();
            }
            Console.ReadLine();
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            var m1 = new MotorcycleAlt();
            Console.WriteLine(@"Name {0} , Intersity {1}", m1.driverName, m1.driverIntensity);

            var m2 = new MotorcycleAlt(name: "Boss");
            Console.WriteLine(@"Name {0} , Intersity {1}", m2.driverName, m2.driverIntensity);
            var m3 = new MotorcycleAlt(7);
            Console.WriteLine(@"Name {0} , Intersity {1}", m3.driverName, m3.driverIntensity);

            var c = new Motorcycle(5);
            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine(@"Rider name is {0} ", c.driverName);
            var cuck = new Car();
            cuck.PrintState();
            Console.WriteLine(@"--------------------------------------");
            Car mary = new Car("Mary");
            mary.PrintState();
            var myCar = new Car("Henry", 10);
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }
        }
Example #29
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            //Aloque e configure um objeto Car.
            Car myCar = new Car();

            myCar.petName = "Henry";
            myCar.currSpeed = 10;

            //Aumente a velocidade de car algumas vezes e imprima o novo estado.

            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            Console.WriteLine();

            Car chuck = new Car();

            chuck.PrintState();

            Console.WriteLine();

            //Cria um carro chamado chuck indo a 10MPH
            Car nchuck = new Car();

            nchuck.PrintState();

            Console.WriteLine();

            //Cria um carro chamado Marry indo a 10MPH
            Car mary = new Car("Marry");

            mary.PrintState();

            Console.WriteLine();

            //Cria um carro chamado Daisy indo a 75MPH
            Car daisy = new Car("Daisy", 75);

            daisy.PrintState();

            Console.WriteLine();

            Motorcycle mc = new Motorcycle();

            mc.PopAWheely();

            Console.WriteLine("############FUN WITH CTOR##############");

            Motorcycle c = new Motorcycle(5);

            c.SetDriverName("Tiny");
            c.PopAWheely();

            Console.WriteLine("Rider name is{0}", c.driverName);

            Console.WriteLine("############FUN WITH MC2##############");

            Motorcycle2 m1 = new Motorcycle2();
            Console.WriteLine("Name= {0}, Intensity = {1}", m1.driverName, m1.driverIntensity);

            Motorcycle2 m2 = new Motorcycle2(name: "Tiny");
            Console.WriteLine("Name = {0}, Intensity = {1}", m2.driverName, m2.driverIntensity);

            Motorcycle2 m3 = new Motorcycle2(7);
            Console.WriteLine("Name = {0}, Intensity = {1}", m3.driverName, m3.driverIntensity);

            Console.ReadLine();
        }
Example #30
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");

            //  Allocate and configure a Car object.
            Car myCar = new Car();

            //  Invoking the default constructor.
            Car chuck = new Car();

            //  Prints "Chuck is going 10 MPH.
            chuck.PrintState();
            Console.WriteLine();

            //  Make a car called Mary going 0 MPH.
            Car mary = new Car("Mary");

            mary.PrintState();
            Console.WriteLine();

            //  Make a car called Daisy going 75 MPH.
            Car daisy = new Car("Daisy", 75);

            daisy.PrintState();
            Console.WriteLine();

            myCar.petName   = "Henry";
            myCar.currSpeed = 10;

            //  Speed up the car a few times and print out the new state.
            for (int i = 0; i <= 10; i++)
            {
                myCar.SpeedUp(5);
                myCar.PrintState();
            }

            //  Must allocate calss objects with 'new' keyword.
            //  Compiler error! Forgot to use 'new' to create object!
            //Car myCar2;
            //myCar2.petName = "Fred";

            //  Can define and allocate on seperate lines.
            Car myCar2;

            myCar2         = new Car();
            myCar2.petName = "Fred";

            //MotorCycle mc = new MotorCycle();
            //mc.PopAWheely();

            ////  Make a motorcycle with a rider named Tiny?
            //MotorCycle c = new MotorCycle(5);
            //c.SetDriverName("Tiny");
            //c.PopAWheely();
            //Console.WriteLine("Rider name is {0}", c.driverName); //  Prints an empty name value!

            //  driverName = "", driverIntensity = 0
            MotorCycle m1 = new MotorCycle();

            Console.WriteLine("Name = {0}, Intensity = {1}", m1.driverName, m1.driverIntensity);
            Console.WriteLine();

            //  driverName = "Tiny", driverIntensity = 0
            MotorCycle m2 = new MotorCycle(name: "Tiny");

            Console.WriteLine("Name = {0}, Intensity = {1}", m2.driverName, m2.driverIntensity);
            Console.WriteLine();

            //  driverName = "", driverIntensity = 7
            MotorCycle m3 = new MotorCycle(7);

            Console.WriteLine("Name = {0}, Intensity = {1}", m3.driverName, m3.driverIntensity);
        }