Esempio n. 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();
        }
Esempio n. 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";
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****");

            //Motorcycle object instantiation
            Motorcycle mc  = new Motorcycle(7);
            Motorcycle mc2 = new Motorcycle("Sarah");
            Motorcycle mc3 = new Motorcycle();

            // Motorcyle object functions.
            //mc.SetDriverName("George");
            //mc.PopAWheely();
            //mc2.PopAWheely();

            // Default Constructor
            Car myCar = new Car();

            myCar.PrintState();

            // Non-Default Constructor - 1 Parameter
            Car myCar2 = new Car("Harry");

            myCar2.PrintState();

            // Non-Default Constructr - 2 Parameters
            Car myCar3 = new Car("Sally", 40);

            myCar3.PrintState();



            Console.ReadLine();
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun With Class Types ******\n");
            // Allocate and configure a Car object.
            Car myCar = new Car //this could also be Car myCar = new Car(); and the properties could be set by myCar.currSpeed = 10; myCar.petName = "Henry";
            {
                currSpeed = 10,
                petName   = "Henry"
            };

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

            Car Chuck = new Car();

            Chuck.PrintState(); // here we see the new constructor already set the values of the Car class properties to a new default

            Car Mary = new Car("Mary");

            Mary.PrintState();

            Car Daisy = new Car("Daisy", 75);

            Daisy.PrintState();

            // we just used the new overloaded constructor to create three cars. It was much quicker to initialize a new instance of Car and fill out field data

            Console.ReadLine();
        }
Esempio n. 7
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();
        }
Esempio n. 8
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();
        }
Esempio n. 9
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();
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            Console.WriteLine("****Fun with Class types****\n");
            // разместить в памяти и сконфигурировать обьект Car.
            Car myCar = new SimpleClassExample.Car();

            // Создать обьект  Car по именя Chuck со скоростью 10 миль в час.
            Car chuck = new Car();

            chuck.PrintState();
            // Создать обьект  Car по именя Mary со скоростью 0 миль в час.
            Car mary = new Car("Mary");

            mary.PrintState();
            // Создать обьект  Car по именя Daisy со скоростью 75 миль в час.
            Car daisy = new Car("Daisy", 75);

            daisy.PrintState();


            Books book1 = new Books(12, "Programmig C++");

            book1.PrintState();
            Books book2 = new Books(8, "Programmig Java Scripts");

            book2.PrintState();



            Console.ReadLine();
        }
Esempio n. 11
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();
        }
Esempio n. 12
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();
        }
Esempio n. 13
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();
        }
Esempio n. 14
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";
        }
Esempio n. 15
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();
        }
Esempio n. 16
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();
        }
Esempio n. 17
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();
        }
Esempio n. 19
0
        private static void InstantiateMultipleCars()
        {
            Car chuck = new Car();

            chuck.PrintState();

            Car mary = new Car("Mary");

            mary.PrintState();

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

            daisy.PrintState();
        }
Esempio n. 20
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();
        }
Esempio n. 21
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();
            }
        }
Esempio n. 22
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();
        }
Esempio n. 23
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();
        }
Esempio n. 24
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();
        }
Esempio n. 25
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();
            }

            // 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();
        }
Esempio n. 26
0
        static void Main(string[] args)
        {
            Console.WriteLine("*** Fun with Class Types ***\n");
                // Allocate and configure a Car object
                Car mycar = new Car();
                Car myCar2 = new Car("Cherry", 20000){ petName = "Henry", 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();
                }

                // Weird method using optinal a
                myCar2.weirdMethod();
                myCar2.weirdMethod(10,10);
                myCar2.weirdMethod(x: 10);
                myCar2.weirdMethod(y: 4);

            Console.WriteLine("**** Employee class ***\n");
                Employee joe = new Employee();
                Employee martin = new Employee("Martin", 23, 222222, 8);
                Console.WriteLine(Employee.p_empCompanyName);
                Employee.p_empCompanyName = "BOY COORP";
                Console.WriteLine(Employee.p_empCompanyName);
                martin.ssn = 22222;
                Console.WriteLine(martin.ssn);

             Console.WriteLine("**** Point class ***\n");
                Point p1 = new Point();
                p1.p_X = 10;
                p1.p_Y = 10;
                p1.DisplayStats();

                Point p2 = new Point(20, 20);
                p2.DisplayStats();

                Point p3 = new Point { p_Y = 20, p_X = 40, p_name = "Martin" };
                p3.DisplayStats();

            // Trigger to stop the program
            Console.ReadLine();
        }
Esempio n. 27
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();
        }
Esempio n. 28
0
        static void Main(string[] args)
        {
            Car chuck = new Car();

            chuck.PrintState();

            Car mary = new Car("MAry");

            mary.PrintState();

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

            daisy.PrintState();

            Motorcycle c = new Motorcycle(5);

            c.SetDriverName("Tiny");
            c.PopAwheely();
            Console.WriteLine(c.name);
        }
Esempio n. 29
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}");
        }
Esempio n. 30
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.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();
            }
            // default constructor
            myCar = new Car();
            myCar.PrintState();

            // Try starting with a chosen name but default speed.
            myCar = new Car("Kirby");
            myCar.PrintState();

            // Chose all starting parameters
            myCar = new Car("Stringy", 22);
            myCar.PrintState();

            Motorcycle mc = new Motorcycle(5);

            mc.SetDriversName("Tiny");
            mc.PopAWheely();
            mc = new Motorcycle("Namey booooi!");
            mc.PopAWheely();

            Console.WriteLine();
            MakeSomeSportsCars();

            Console.ReadLine();
        }
Esempio n. 31
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Class Types *****\n");
            // Создать объект Car по имени Chuck co скоростью 10 миль в час.
            Car chuck = new Car();

            chuck.PrintState();
            // Создать объект Car по имени Mary co скоростью 0 миль в час.
            Car тагу = new Car("Mary");

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

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

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

            Motorcycle me = new Motorcycle();

            me.PopAWheely();

            Motorcycle c = new Motorcycle(5);

            c.SetDriverName("Tiny");
            c.PopAWheely();
            Console.WriteLine("Rider name is {0}", c.name); // Выводит пустое значение name!

            Console.ReadLine();
        }
        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();
        }
Esempio n. 33
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();
        }
Esempio n. 34
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();
        }
Esempio n. 35
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);
        }
Esempio n. 36
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();
        }
        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();
            }
        }