static void Main(string[] args) { var sedan = new Sedan(1); var hatchback = new Hatchback(2); var teslaHQ = new TeslaHq(); teslaHQ.Attach(sedan); teslaHQ.Attach(hatchback); //2.0.0 teslaHQ.MajorUpgrade(); teslaHQ.NotifySoftwareUpdate(); teslaHQ.Detach(hatchback); //2.0.1 teslaHQ.PatchUpdate(); teslaHQ.NotifySoftwareUpdate(); System.Console.WriteLine(sedan.SoftwareVersion); System.Console.WriteLine(hatchback.SoftwareVersion); var cars = new CarsCollection(); cars.AddCar(sedan); cars.AddCar(hatchback); foreach (var car in cars) { System.Console.WriteLine(car.ToString()); } }
private static void DemonstrateExceptionSourceStateCapture() { Vehicle vehicle = new Sedan(200) { Brand = "Audi", Model = "A4 Quattro", Type = Sedan.SedanType.PassengerCar, }; try { vehicle.Start(); } catch (System.Exception ex) { // capture state of vehicle instance: var state = RollbarAssistant.CaptureState(vehicle, "StartedVehicle"); // also, capture state of the Game static type: RollbarAssistant.CaptureState(typeof(Game), state); // report the captured states along with the caught exception: RollbarLocator.RollbarInstance .AsBlockingLogger(TimeSpan.FromMilliseconds(10000)) .Error(new ApplicationException("Application exception with a state capture.", ex), state); } }
public ActionResult DeleteConfirmed(int id) { Sedan sedan = db.Sedans.Find(id); db.Sedans.Remove(sedan); db.SaveChanges(); return(RedirectToAction("Index")); }
public static void A_PropertyOfGenericClassParameter() { var expectedTransmission = new AutomaticTransmission(); var sedanWithAutomaticTransmission = new Sedan <AutomaticTransmission>(200, expectedTransmission); sedanWithAutomaticTransmission.Transmission .Should() .Be(expectedTransmission); }
public static void ArrayCovariance() { Sedan[] sedans = new Sedan[1]; sedans[0] = new Sedan(); Auto[] autos = sedans; autos[0] = new Roadster(); }
public ActionResult Edit([Bind(Include = "ID,Model,MSRP,Horsepower,MPG")] Sedan sedan) { if (ModelState.IsValid) { db.Entry(sedan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sedan)); }
public void SedanCanTurnOn() { //arrange Sedan sedan = new Sedan(); //act string var = sedan.TurnOn(); //assert Assert.Equal("The sedan has turned on", var); }
public static void A_ConstructСlosedTypesBasedOnDerivedGenericClass() { var sedanWithAutomaticTransmission = new Sedan <AutomaticTransmission>(200); var sedanWithManualTransmission = new Sedan <ManualTransmission>(240); sedanWithManualTransmission.GetType() .BaseType .Should() .Be(sedanWithAutomaticTransmission.GetType().BaseType); }
public void SedanMakesnoise() { //arrange Sedan sedan = new Sedan(); //act bool output1 = sedan.MakesNoise; //assert Assert.True(output1); }
public void SedanIsReaL() { //arrange Sedan sedan = new Sedan(); //act bool output = sedan.IsReal; //assert Assert.False(output); }
public void SedanPrice() { //arrange Sedan sedan = new Sedan(); //act int output1 = sedan.Price; //assert Assert.Equal(1000, output1); }
public ActionResult Create([Bind(Include = "ID,Model,MSRP,Horsepower,MPG")] Sedan sedan) { if (ModelState.IsValid) { db.Sedans.Add(sedan); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sedan)); }
public void SedanCanDrive() { //arrange Sedan sedan = new Sedan(); //act string output = sedan.DriveForward(); //assert Assert.Equal("The car drives forward", output); }
public static void B_MethodWithGenericClassParameter() { var expectedTransmission = new AutomaticTransmission(); var sedanWithAutomaticTransmission = new Sedan <AutomaticTransmission>(200); sedanWithAutomaticTransmission.ChangeTransmission(expectedTransmission); sedanWithAutomaticTransmission.Transmission .Should() .Be(expectedTransmission); }
public void SedanCanHonk() { //arrange Sedan sedan = new Sedan(); //act string output = sedan.Honk(); //assert Assert.Equal("BEEP BEEP", output); }
static void Main(string[] args) { CargoAuto cargoAuto = new Pickup(); cargoAuto.transportCargo(); PassangersAuto passangersAuto = new Sedan(); passangersAuto.transportPassangers(); Console.ReadKey(); }
public void TheSedanCanreverse() { //arrange Sedan sedan = new Sedan(); //act string output = sedan.Reverse(); //assert Assert.Equal("The car Reverses", output); }
public void autosindecorar() { Automovil monovolumen = new Monovolumen(); Automovil sedan = new Sedan(); Assert.AreEqual(monovolumen.Descripcion(), "Monovolumen"); Assert.AreEqual(sedan.Descripcion(), "Sedan"); Assert.AreEqual(monovolumen.Consumo(), 7.5); Assert.AreEqual(sedan.Consumo(), 6.2); Assert.AreEqual(monovolumen.VelocidadMaxima(), 160); Assert.AreEqual(sedan.VelocidadMaxima(), 180); }
static void Main(string[] args) { Sedan mobilku; mobilku = new Sedan("red", "sedan"); mobilku.gas(10); mobilku.gas(20); mobilku.gas(70); mobilku.brake(50); mobilku.brake(50); }
protected void GetMakeButton_Click(object sender, EventArgs e) { var sedanMakeModel = SedanTextBox.Text.Split(new char[] { ',' }); var truckMakeModel = TruckTextBox.Text.Split(new char[] { ',' }); var trk = new Truck(truckMakeModel[0], truckMakeModel[1]); var sed = new Sedan(sedanMakeModel[0], sedanMakeModel[1]); SedanLabel.Text = $"Sedan Make: {sed.make}"; SedanLabel.Text += $"<br>Sedan Model: {sed.model}<br>"; TruckLabel.Text = $"Truck Make: {trk.make}"; TruckLabel.Text += $"<br>Truck Model: {trk.model}"; }
// GET: Sedans/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Sedan sedan = db.Sedans.Find(id); if (sedan == null) { return(HttpNotFound()); } return(View(sedan)); }
public List <Vehicle> GetVehiclesFromDatabase() { List <Vehicle> importedVehicles = new List <Vehicle>(); string sqlQuery = "SELECT id, type, name, fuel_percentage, damage_percentage FROM vehicles"; SqlCommand sqlCommand = new SqlCommand(sqlQuery, sqlConnection); try { sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { short vehicleID = sqlDataReader.GetInt16(sqlDataReader.GetOrdinal("id")); string vehicleType = sqlDataReader["type"].ToString(); string vehicleName = sqlDataReader["name"].ToString(); short vehicleFuelPercentage = sqlDataReader.GetInt16(sqlDataReader.GetOrdinal("fuel_percentage")); short vehicleDamagePercentage = sqlDataReader.GetInt16(sqlDataReader.GetOrdinal("damage_percentage")); if (vehicleType == "Sedan") { Sedan sedan = new Sedan(vehicleID, vehicleName, vehicleFuelPercentage, vehicleDamagePercentage); importedVehicles.Add(sedan); } if (vehicleType == "Minivan") { Minivan minivan = new Minivan(vehicleID, vehicleName, vehicleFuelPercentage, vehicleDamagePercentage); importedVehicles.Add(minivan); } } sqlDataReader.Close(); } catch (Exception exception) { Console.WriteLine(exception.Message); } finally { sqlConnection.Close(); } return(importedVehicles); }
static void Main(string[] args) { Car car = new Sedan(); Console.WriteLine(car.Info()); Car sport = new SportSedan(new Sedan()); Console.WriteLine(sport.Info()); Car armoured = new ArmoredSedan(new SportSedan(new Sedan())); Console.WriteLine(armoured.Info()); Console.ReadKey(); }
public void autodecorado() { Automovil monovolumen = new Monovolumen(); Automovil sedan = new Sedan(); //decoro los autos monovolumen = new GasolinaDecorador(monovolumen); sedan = new ElectricoDecorador(sedan); Assert.AreEqual(monovolumen.Descripcion(), "Monovolumen Gasolina"); Assert.AreEqual(sedan.Descripcion(), "Sedan Electrico"); Assert.AreEqual(monovolumen.Consumo(), 8.5); Assert.AreEqual(sedan.Consumo(), 5.2); Assert.AreEqual(monovolumen.VelocidadMaxima(), 240); Assert.AreEqual(sedan.VelocidadMaxima(), 200); }
static void Main(string[] args) { Sedan s = new Sedan(60); // Call SpeedUp() here Console.WriteLine(s.Describe()); Truck t = new Truck(45, 500); // Call SpeedUp() here Console.WriteLine(t.Describe()); Bicycle b = new Bicycle(10); // Call SpeedUp() here Console.WriteLine(b.Describe()); }
static void Main(string[] args) { #region Exceptions try { //throw new Exception("OH NO, IT BROKE"); Sedan nullSedan = null; nullSedan.Start(); } catch (Exception e) { } #endregion #region Read/write console //Console.WriteLine("What is your name? "); //var name = Console.ReadLine(); //Console.WriteLine($"Hello {name}!"); #endregion #region Environment variables Console.WriteLine(Environment.GetEnvironmentVariable("MY_VAR")); #endregion #region OOP var myCar = new Sedan(2, 5); Console.WriteLine(myCar.Wheels); // 0 when Wheels is not set var myTruck = new Pickup(6, new TruckNuts()); if (myTruck.TruckNuts != null) { Console.WriteLine("My Truck Has Nuts: yes"); } else { Console.WriteLine("My Truck Has Nuts: no"); } // Move the car Console.WriteLine($"The Sedan moved {myCar.Move(true)} spaces"); #endregion }
public ActionResult Edit(int id, Sedan editedSedan, IFormCollection collection) { if (!ModelState.IsValid) { return(View(editedSedan)); } try { _sedanRepo.EditCar(editedSedan); return(RedirectToAction(nameof(Index))); } catch { //todo log exception } return(View(editedSedan)); }
static void Main(string[] args) { // aqui se crea un auto pero de tipo sedan Sedan corolla = new Sedan("corolla"); Suv rav4 = new Suv("rav4"); corolla.Transport("Cochabamba", "La Paz"); corolla.Recharge(100); //De acuerdo a que tipo de auto es mostrara el tamaño de la bateria Console.WriteLine("Size of corolla"); Console.WriteLine(corolla.SizeofBattery()); Console.WriteLine("Size of rav4"); Console.WriteLine(rav4.SizeofBattery()); }
static public ICarType getCarTypeObj(string carType) { ICarType objCarType = null; if (carType.ToLower() == "sedan") { objCarType = new Sedan(); } else if (carType.ToLower() == "racecar") { objCarType = new Racecar(); } else { objCarType = new InvalidCarType(); } return(objCarType); }
static void Main(string[] args) { User me = new User("Hovo", 200); Bus b = new Bus(20, 50, 10, "Hundai", 50, 0.01); Truck t = new Truck(50, 50, 10, "Furz", 50, 0.01); Sedan s = new Sedan(50, 50, 10, "Ferrari", 50, 0.01); Shop sh = new Shop(20); sh.Add(b, 50); sh.Add(t, 60); sh.Add(s, 100); sh.Add(b, 50); sh.Add(t, 60); sh.Add(s, 100); sh.Add(b, 50); sh.Add(t, 60); sh.Add(s, 100); while (true) { Console.Clear(); Console.WriteLine("Where do you want to go ? \n Shop ? Garage ? Exit ?"); string ans = Console.ReadLine(); Console.Clear(); if (ans.ToUpper() == "SHOP") { sh.Trade(me); } else if (ans.ToUpper() == "GARAGE") { me.DisplayCars(); Console.ReadKey(); } else if (ans.ToUpper() == "EXIT") { break; } } }
public Car Create(CarType type, int xPos, int yPos, City city, Passenger passenger) { Car car; switch (type) { case CarType.Sedan: car = new Sedan(xPos, yPos, city, passenger); break; case CarType.RaceCar: car = new RaceCar(xPos, yPos, city, passenger); break; case CarType.Motorcycle: car = new Motorcycle(xPos, yPos, city, passenger); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } return car; }