コード例 #1
0
ファイル: Program.cs プロジェクト: adrianncovaci/tmps
        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());
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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();
        }
コード例 #6
0
 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));
 }
コード例 #7
0
        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);
        }
コード例 #9
0
        public void SedanMakesnoise()
        {
            //arrange
            Sedan sedan = new Sedan();
            //act
            bool output1 = sedan.MakesNoise;

            //assert
            Assert.True(output1);
        }
コード例 #10
0
        public void SedanIsReaL()
        {
            //arrange
            Sedan sedan = new Sedan();
            //act
            bool output = sedan.IsReal;

            //assert
            Assert.False(output);
        }
コード例 #11
0
        public void SedanPrice()
        {
            //arrange
            Sedan sedan = new Sedan();
            //act

            int output1 = sedan.Price;

            //assert
            Assert.Equal(1000, output1);
        }
コード例 #12
0
        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));
        }
コード例 #13
0
        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);
        }
コード例 #15
0
        public void SedanCanHonk()
        {
            //arrange
            Sedan sedan = new Sedan();
            //act
            string output = sedan.Honk();


            //assert
            Assert.Equal("BEEP BEEP", output);
        }
コード例 #16
0
        static void Main(string[] args)
        {
            CargoAuto cargoAuto = new Pickup();

            cargoAuto.transportCargo();

            PassangersAuto passangersAuto = new Sedan();

            passangersAuto.transportPassangers();

            Console.ReadKey();
        }
コード例 #17
0
        public void TheSedanCanreverse()
        {
            //arrange
            Sedan sedan = new Sedan();

            //act

            string output = sedan.Reverse();

            //assert
            Assert.Equal("The car Reverses", output);
        }
コード例 #18
0
ファイル: UnitTest1.cs プロジェクト: fabiandres2000/parcial2
        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);
        }
コード例 #19
0
ファイル: Mobil.cs プロジェクト: antoniofendy/Coding-C-
    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);
    }
コード例 #20
0
ファイル: Index.aspx.cs プロジェクト: efournier92/.NET-Demos
    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}";
    }
コード例 #21
0
        // 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));
        }
コード例 #22
0
        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);
        }
コード例 #23
0
        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();
        }
コード例 #24
0
ファイル: UnitTest1.cs プロジェクト: fabiandres2000/parcial2
        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);
        }
コード例 #25
0
    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());
    }
コード例 #26
0
ファイル: Program.cs プロジェクト: CarvellWakeman/Brobeans
        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
        }
コード例 #27
0
 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));
 }
コード例 #28
0
ファイル: Program.cs プロジェクト: victorhm2011/AutosPOO
        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());
        }
コード例 #29
0
    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);
    }
コード例 #30
0
    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;
            }
        }
    }
コード例 #31
0
ファイル: CarFactory.cs プロジェクト: InsideJC/TransportProj
        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;
        }