// Fill with some Car oibjects upon startup public Garage() { carArray[0] = new Car("Rusty", 30); carArray[1] = new Car("R", 40); carArray[2] = new Car("Rust", 50); carArray[3] = new Car("Rus", 60); }
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(); }
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"; }
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(); }
private void btnGarage_Click(object sender, RoutedEventArgs e) { var c = new Car(); c.petName = "Opel"; var g = new Garage(); g.MyAuto = c; Console.WriteLine(@"Number of Car: {0}", g.NumberofGar); Console.WriteLine(@"PetName is: {0}", g.MyAuto.petName); }
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) { //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(); }
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(); }
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(); }
public Garage(Car car, int number) { MyAuto = car; NumberofGar = number; }
public Garage() { MyAuto = new Car(); NumberofGar = 1; }
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(); } }
private void btnRadio_Click(object sender, RoutedEventArgs e) { var viper = new Car(); viper.TurnOnRadio(false); }