Example #1
0
 public void Update(Scooter entity)
 {
     using (var connection = new SqlConnection(_connectionString))
     {
         connection.Update(entity);
     }
 }
Example #2
0
 public void Insert(Scooter entity)
 {
     using (var connection = new SqlConnection(_connectionString))
     {
         connection.Insert(entity);
     }
 }
Example #3
0
    // Use this for initialization
    void Start()
    {
        gameManager             = GameManager.instance;
        this.scooter            = GameObject.FindGameObjectWithTag("Scooter").GetComponent <Scooter> ();
        this.playerCharacter    = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerCharacter> ();
        this.speedText          = GameObject.FindGameObjectWithTag("SpeedMonitor").GetComponent <Text> ();
        this.addressText        = GameObject.FindGameObjectWithTag("Address").GetComponent <Text> ();
        this.brakeText          = GameObject.FindGameObjectWithTag("BrakeMonitor").GetComponent <Text> ();
        this.noOfLivesText      = GameObject.FindGameObjectWithTag("Lives").GetComponent <Text> ();
        this.playAgain          = GameObject.FindGameObjectWithTag("PlayAgain");
        this.noOfLivesText.text = "Lifes :" + gameManager.getCurrentLives();

        enableGPSCamera();

        if (this.playAgain != null)
        {
            this.playAgain.SetActive(false);
        }

        this.GenerateAddress(area);
        if (this.address != null)
        {
            this.addressText.text = /*"Mr. John Smith \n" +*/ this.address.no + ", " + this.address.street + " - " + this.address.area;
            this.DrawGPSRoute(this.scooter.gameObject, this.destination);
        }
    }
Example #4
0
        private static void AddVehiclesTest()
        {
            using (var context = new BikeRentalContext())
            {
                var bike = new Bike
                {
                    BikeType = BikeType.City,
                    Color    = "red",
                    Number   = "B005"
                };

                var bike2 = new Bike
                {
                    BikeType = BikeType.Moutain,
                    Color    = "yellow",
                    Number   = "B006"
                };

                var scooter = new Scooter
                {
                    Color          = "yellow",
                    Number         = "S001",
                    EngineCapacity = 100
                };

                context.Vehicles.Add(bike);
                context.Vehicles.Add(bike2);
                context.Vehicles.Add(scooter);

                context.SaveChanges();
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            var jetSR = new Dimension()
            {
                Name = "JetSR", Power = 10.5, Price = 84000
            };
            IScooter scooter = new Scooter(jetSR);

            var BATTERY = new Dimension()
            {
                Name = "BATTERY", Power = 0.2, Price = 1200
            };

            scooter = new Component(scooter, BATTERY);
            var FRAME = new Dimension()
            {
                Name = "FRAME", Power = 0.2, Price = 1200
            };

            scooter = new Component(scooter, FRAME);
            var CARBURETOR = new Dimension()
            {
                Name = "CARBURETOR", Power = 0.2, Price = 1200
            };

            scooter = new Component(scooter, CARBURETOR);
            Console.WriteLine(scooter.GetPrice());
        }
        static void Main(string[] args)
        {
            Car auto1 = new Car(ManufacturersForTransmissionsAndVehicles.BMW,
                                new Engine(250, 2.5, EngineTypes.Petrol, 123),
                                new Chassis(4, 4000, 321),
                                new Transmission("2x2", 6, ManufacturersForTransmissionsAndVehicles.BMW),
                                4);
            Car auto2 = new Car(ManufacturersForTransmissionsAndVehicles.Mitsubishi,
                                new Engine(90, 1.1, EngineTypes.Hybrid, 123877),
                                new Chassis(4, 4000, 321),
                                new Transmission("2x2", 5, ManufacturersForTransmissionsAndVehicles.Mitsubishi),
                                4);
            Bus bus1 = new Bus(ManufacturersForTransmissionsAndVehicles.Mercedes,
                               new Engine(385, 6.2, EngineTypes.Diesel, 777),
                               new Chassis(6, 2000, 751),
                               new Transmission("2x4", 7, ManufacturersForTransmissionsAndVehicles.Mercedes),
                               48,
                               2);
            Lorry lorry1 = new Lorry(ManufacturersForTransmissionsAndVehicles.Citroen,
                                     new Engine(350, 5.45, EngineTypes.Diesel, 500500),
                                     new Chassis(4, 1200, 123789),
                                     new Transmission("2x2", 6, ManufacturersForTransmissionsAndVehicles.Kia),
                                     5000);
            Scooter scooter1 = new Scooter(ManufacturersForTransmissionsAndVehicles.Ducati,
                                           new Engine(290, 2.2, EngineTypes.Petrol, 222222),
                                           new Chassis(2, 250, 123784),
                                           new Transmission("1x1", 8, ManufacturersForTransmissionsAndVehicles.Ferrari),
                                           5000);

            Console.Write(auto1.GetInformation());
            Console.Write(auto2.GetInformation());
            Console.Write(bus1.GetInformation());
            Console.Write(lorry1.GetInformation());
            Console.Write(scooter1.GetInformation());
        }
Example #7
0
        private static void AddBikeTest()
        {
            var bike = new Bike
            {
                Number         = "R001",
                BikeType       = BikeType.Town,
                Color          = "Green",
                ProductionYear = 2016,
                Size           = "16",
                IsActive       = true
            };

            var scooter = new Scooter
            {
                Number         = "S001",
                ProductionYear = 2010,
                Capacity       = 250,
                IsActive       = true
            };

            using (var context = new RentalBikesContext())
            {
                context.Vehicles.Add(bike);
                context.Vehicles.Add(scooter);

                context.SaveChanges();
            }
        }
Example #8
0
        public void CorrectWeightSet_Test()
        {
            Scooter scooter = new Scooter("MegaScooter 3000", "SC000001");

            scooter.Weight = 63.5;
            Assert.AreEqual(63.5, scooter.Weight);
        }
Example #9
0
        public void CorrectMaxSpeedSet_Test()
        {
            Scooter scooter = new Scooter("MegaScooter 3000", "SC000001");

            scooter.MaxSpeed = 50;
            Assert.AreEqual(50, scooter.MaxSpeed);
        }
Example #10
0
        public ActionResult EditScooter(Scooter emp)
        {
            if (Session["User"] != null)
            {
                ViewBag.Nombre   = Session["FirstName"];
                ViewBag.Apellido = Session["LastName"];


                try
                {
                    if (ModelState.IsValid)
                    {
                        ViewBag.marca  = new SelectList(marcadao.ListarMarca(), "IdMarca", "descMarca", emp.codMarca);
                        ViewBag.imagen = new SelectList(db.TB_IMAGENES.ToList(), "cod_imagen", "descrp_imagen", emp.codImagen);


                        scooterdao.UpdateScooter(emp);

                        return(RedirectToAction("ListarScooter"));
                    }
                    else
                    {
                        return(RedirectToAction("ListarScooter"));
                    }
                }
                catch
                {
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("Login"));
            }
        }
Example #11
0
        public async Task DeleteScooter(int id)
        {
            Scooter scooter = await GetScooterById(id);

            _context.Scooter.Remove(scooter);
            await _context.SaveChangesAsync();
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Color,Number,ScooterModelId")] Scooter scooter)
        {
            if (id != scooter.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(scooter);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ScooterExists(scooter.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ScooterModelId"] = new SelectList(_context.Set <ScooterModel>(), "Id", "Id", scooter.ScooterModelId);
            return(View(scooter));
        }
    static void Main(string[] args)
    {
        Automovil protoAutomovilEstandarAzul = new
                                               AutomovilElectricidad();

        protoAutomovilEstandarAzul.modelo = "estándar";
        protoAutomovilEstandarAzul.color  = "azul";

        Scooter protoScooterClasicoRojo = new ScooterGasolina();

        protoScooterClasicoRojo.modelo = "clasico";
        protoScooterClasicoRojo.color  = "rojo";

        FabricaVehiculo fabrica = new FabricaVehiculo();

        fabrica.prototypeAutomovil =
            protoAutomovilEstandarAzul;
        fabrica.prototypeScooter = protoScooterClasicoRojo;

        Automovil auto = fabrica.creaAutomovil();

        auto.visualizaCaracteristicas();
        Scooter scooter = fabrica.creaScooter();

        scooter.visualizaCaracteristicas();
    }
        public void rentScooter(Rental renta1)
        {
            ICollection <Scooter> numeroScooters = renta1.OriginStation.Scooters;


            if (numeroScooters.Any <Scooter>() == false) //Comprobar si hay patinetes en la estacion
            {
                throw new ServiceException("No quedan patinetes en esa estacion");
            }

            for (int i = 0; i < renta1.User.Rentals.Count(); i++)
            {
                if (renta1.User.Rentals.ElementAt <Rental>(i).Scooter.State.Equals(ScooterState.inUse))
                {
                    throw new ServiceException("Devuelva un patín antes de alquilar otro");
                }
            }
            Scooter patin = renta1.Scooter;

            patin.State = ScooterState.inUse;
            Station estOrigen = renta1.OriginStation;

            estOrigen.removeScooter(patin);
            renta1.Scooter.Rentals.Add(renta1);
            dal.Insert <Rental>(renta1);
            dal.Commit();
        }
Example #15
0
        public void StartRide()
        {
            Scooter scooter = new Scooter("1", 0.2M);

            _service.StartRide(scooter);

            scooter.IsRented.Should().Be(true);
        }
Example #16
0
        public void AddScooterNotExistsData(string scooterId, decimal pricePerMinute)
        {
            _scooterService.AddScooter(scooterId, pricePerMinute);
            Scooter scooter = _scooterService.GetScooterById(scooterId);

            Assert.Equal(scooter.Id, scooterId);
            Assert.Equal(scooter.PricePerMinute, pricePerMinute);
        }
        public void Test_CalculateDeptCustomer()
        {
            Customer customer = new Customer("Nick");

            customer.Rentals.Add(new Rental(Scooter.BMW("RX250"), 4));
            customer.Rentals.Add(new Rental(Scooter.Honda("M80"), 3));
            Assert.AreEqual(customer.CalculateDept(), 12 * 4 + 7 * 3);
        }
        static void Main(string[] args)
        {
            Func <Vehicle, bool>        chooseMoreThan15      = x => x.VehicleEngine.Volume >= 1.5;
            Func <Vehicle, bool>        choose2x2Transmission = x => x.VehicleTransmission.TransmissionType == "2x2";
            Func <Vehicle, string>      transmissionComparer  = x => x.VehicleTransmission.TransmissionType;
            Func <Vehicle, bool>        chooseVehicleType     = x => x.GetType().Equals(typeof(Lorry)) || x.GetType().Equals(typeof(Bus));
            Func <Vehicle, SerialClass> proectionCondition    = x => new SerialClass(x.VehicleEngine.EngineType, x.VehicleEngine.SerialNumber, x.VehicleEngine.Power);

            string fileForVehiclesName = "Vehicles.xml";
            string fileForVehiclesWithEngineVolume15Name = "Vehicles15.xml";
            string fileLorryAndBusEngines              = "LorryAndBusEngines.xml";
            string fileVehiclesWith2x2Transmission     = "2x2VehicleTypes.xml";
            string fileForSortedByTransmissionVehicles = "SortedTransmissions.xml";

            Car auto1 = new Car(ManufacturersForTransmissionsAndVehicles.BMW,
                                new Engine(250, 2.5, EngineTypes.Petrol, 123),
                                new Chassis(4, 4000, 321),
                                new Transmission("2x2", 6, ManufacturersForTransmissionsAndVehicles.BMW),
                                4);
            Car auto2 = new Car(ManufacturersForTransmissionsAndVehicles.Mitsubishi,
                                new Engine(90, 1.1, EngineTypes.Hybrid, 123877),
                                new Chassis(4, 4000, 321),
                                new Transmission("2x2", 5, ManufacturersForTransmissionsAndVehicles.Mitsubishi),
                                4);
            Bus bus1 = new Bus(ManufacturersForTransmissionsAndVehicles.Mercedes,
                               new Engine(385, 6.2, EngineTypes.Diesel, 777),
                               new Chassis(6, 2000, 751),
                               new Transmission("2x4", 7, ManufacturersForTransmissionsAndVehicles.Mercedes),
                               48,
                               2);
            Lorry lorry1 = new Lorry(ManufacturersForTransmissionsAndVehicles.Citroen,
                                     new Engine(350, 5.45, EngineTypes.Diesel, 500500),
                                     new Chassis(4, 1200, 123789),
                                     new Transmission("2x2", 6, ManufacturersForTransmissionsAndVehicles.Kia),
                                     5000);
            Scooter scooter1 = new Scooter(ManufacturersForTransmissionsAndVehicles.Ducati,
                                           new Engine(290, 2.2, EngineTypes.Petrol, 222222),
                                           new Chassis(2, 250, 123784),
                                           new Transmission("1x1", 8, ManufacturersForTransmissionsAndVehicles.Ferrari),
                                           5000);

            List <Vehicle> vehicles = new List <Vehicle>()
            {
                auto1, bus1, lorry1, scooter1, auto2
            };
            CarPark carPark = new CarPark(vehicles);

            Console.Write(carPark.GetInformation());
            carPark.SaveToFile(fileForVehiclesName);
            carPark.SaveToFileWithCondition(fileForVehiclesWithEngineVolume15Name, chooseMoreThan15);
            carPark.SaveToFileProection(fileLorryAndBusEngines, chooseVehicleType, proectionCondition);
            carPark.SaveToFileWithCondition(fileVehiclesWith2x2Transmission, choose2x2Transmission);
            carPark.SaveToFileSort(fileForSortedByTransmissionVehicles, transmissionComparer);
            List <Vehicle>     vehiclesWithEngineVolume15FromFile = carPark.ReadFromFile <Vehicle>(fileForVehiclesWithEngineVolume15Name);
            List <SerialClass> enginesFromFile = carPark.ReadFromFile <SerialClass>(fileLorryAndBusEngines);
            List <Vehicle>     vehiclesChosenByTransmissionFromFile = carPark.ReadFromFile <Vehicle>(fileVehiclesWith2x2Transmission);
            List <Vehicle>     sortedVehiclesByTransmission         = carPark.ReadFromFile <Vehicle>(fileForSortedByTransmissionVehicles);
        }
Example #19
0
        public void Delete(int id)
        {
            var scooter = new Scooter
            {
                ScooterId = id
            };

            _rentalScooterContext.Entry(scooter).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
        }
        public void Test_SubstractionRentalDays()
        {
            Rental rental = new Rental(Scooter.Honda("RX80"), 9);

            rental.SubtractionDays(3);
            Assert.AreEqual(rental.CalculateDept(), 7 * 6);
            rental.SubtractionDays();
            Assert.AreEqual(rental.CalculateDept(), 7 * 5);
        }
Example #21
0
        public void EndRide_ScooterNotRented_ShouldThrowScooterNotRentedException()
        {
            var scooter = new Scooter("1", 0.2M);
            var ride    = new Ride(scooter, DateTime.Now);

            Action act = () => _service.EndRide(ride.Scooter.Id);

            act.Should().Throw <ScooterNotRentedException>();
        }
        public ActionResult CreateScooter([FromBody] Scooter scooter)
        {
            _scooterRepository.CreateScooter(scooter);

            return(CreatedAtRoute("GetScooter", new
            {
                ScooterId = scooter.ScooterId
            }, scooter));
        }
        public void Test_AddRentalDays()
        {
            Rental rental = new Rental(Scooter.Honda("RX80"), 3);

            rental.AddDays(3);
            Assert.AreEqual(rental.CalculateDept(), 7 * 6);
            rental.AddDays(2);
            Assert.AreEqual(rental.CalculateDept(), 7 * 8);
        }
        public void EndRentalByScooterId_ScooterNotRented_ThrowsInvalidScooterOperationException()
        {
            var scooter = new Scooter("id", 1);

            _scooterRepositoryMock.Setup(x => x.GetById("id")).Returns(scooter);

            _rentalService.Invoking(x => x.EndRentalByScooterId("id"))
            .Should().Throw <InvalidScooterOperationException>();
        }
Example #25
0
        public void RemoveScooter_ScooterNotRented_CallsRemove()
        {
            var scooter = new Scooter("id", 1);

            _scooterRepositoryMock.Setup(x => x.GetById("id")).Returns(scooter);

            _scooterService.RemoveScooter("id");

            _scooterRepositoryMock.Verify(x => x.Remove("id"));
        }
Example #26
0
        public void StartRent_ScooterAlreadyRented_ShouldThrowScooterRentalInProgressException()
        {
            Scooter scooter = new Scooter("1", 0.2M);

            _service.StartRide(scooter);

            Action act = () => _service.StartRide(scooter);

            act.Should().Throw <ScooterRentalInProgressException>();
        }
Example #27
0
        public static void SenderAndEventArgsExample()
        {
            var scooter = new Scooter()
            {
                Mileage = 2000
            };

            scooter.LowOilEvent     += (object sender, ScooterEventArgs e) => { };
            scooter.LowBatteryEvent += (Scooter sender, ScooterEventArgs args) => { };
        }
Example #28
0
        public void GetInfoNullEngine_Test()
        {
            Scooter scooter = new Scooter("MegaScooter 3000", "SC000001");

            scooter.Chassis      = new Chassis(2, 150, "CH000004");
            scooter.Transmission = new Transmission(TransmissionType.Mechanical, 6, "Disney");
            scooter.MaxSpeed     = 60;
            scooter.Weight       = 63;
            Assert.DoesNotThrow(() => scooter.GetInfo());
        }
Example #29
0
        public void GetInfoNullMaxSpeed_Test()
        {
            Scooter scooter = new Scooter("MegaScooter 3000", "SC000001");

            scooter.Engine       = new Engine(25.5, 0.8, EngineType.Electrical, "EN000004");
            scooter.Chassis      = new Chassis(2, 150, "CH000004");
            scooter.Transmission = new Transmission(TransmissionType.Mechanical, 6, "Disney");
            scooter.Weight       = 63;
            Assert.DoesNotThrow(() => scooter.GetInfo());
        }
        public void StartRentalByScooterId_RentalNotFinished_ThrowsScooterNotFoundException()
        {
            var scooter = new Scooter("id", 1);
            var rental  = new Rental();

            _scooterRepositoryMock.Setup(x => x.GetById("id")).Returns(scooter);
            _rentalRepositoryMock.Setup(x => x.GetLastRentalByScooterId("id")).Returns(rental);

            _rentalService.Invoking(x => x.StartRentalByScooterId("id"))
            .Should().Throw <InvalidScooterOperationException>();
        }
Example #31
0
 static void Main(string[] args)
 {
     FabricaVehiculo fabrica;
     Automovil[] autos = new Automovil[nAutos];
     Scooter[] scooters = new Scooter[nScooters];
     Console.WriteLine("Desea utilizar " +
       "vehículos eléctricos (1) o a gasolina (2):");
     string eleccion = Console.ReadLine();
     if (eleccion == "1")
     {
       fabrica = new FabricaVehiculoElectricidad();
     }
     else
     {
       fabrica = new FabricaVehiculoGasolina();
     }
     for (int index = 0; index < nAutos; index++)
       autos[index] = fabrica.creaAutomobile("estándar",
     "amarillo", 6+index, 3.2);
     for (int index = 0; index < nScooters; index++)
       scooters[index] = fabrica.creaScooter("clásico",
     "rojo", 2+index);
     foreach (Automovil auto in autos)
       auto.mostrarCaracteristicas();
     foreach (Scooter scooter in scooters)
       scooter.mostrarCaracteristicas();
 }
Example #32
0
 public VehiculoClient(VehiculoFactory factory, string type)
 {
     bici = factory.obtenerbici(type);
     Scooter = factory.GetScooter(type);
 }