/// <summary> /// Fill bike information in rent bike form when rent bike status is RENTING_BIKE /// </summary> /// <param name="bike">the rental bike information</param> public void FillRentingBikeForm(BaseBike bike) { this.bike = bike; this.StartTimer(); rentingBikePnl.Visible = true; DateTime begin = rentBikeController.GetBeginDate(this.bike.BikeId); rentingTimedRentValueLbl.Text = Utilities.SubtractDate(DateTime.Now, begin); rentingQrCodeTxt.Text = bike.QRCode; rentingAvatarPb.Image = Image.FromFile(bike.Images); if (bike is Bike) { rentingCategoryTxt.Text = "Xe đạp thường"; rentingRemainPowerValueLbl.Text = "Không có thông tin"; rentingLicenseTxt.Text = "Không có thông tin"; } else if (bike is ElectricBike) { ElectricBike electricBike = bike as ElectricBike; rentingCategoryTxt.Text = "Xe đạp điện"; rentingRemainPowerValueLbl.Text = $"{electricBike.Powers}%"; rentingLicenseTxt.Text = electricBike.LicensePlate; } else { rentingCategoryTxt.Text = "Xe đạp đôi"; rentingRemainPowerValueLbl.Text = "Không có thông tin"; rentingLicenseTxt.Text = "Không có thông tin"; } rentingManufactureTxt.Text = bike.Manufacturer; }
/// <summary> /// Fill bike information in rent bike form when rent bike status is RENTING_BIKE /// </summary> /// <param name="bikeId">The bike id of specified bike</param> public void FillRentingBikeForm() { BaseBike bike = Config.RENTAL_BIKE; rentingQrCodeTxt.Text = bike.QRCode; if (bike is Bike) { rentingCategoryTxt.Text = "Xe đạp thường"; rentingRemainPowerValueLbl.Text = "Không có thông tin"; rentingLicenseTxt.Text = "Không có thông tin"; } else if (bike is ElectricBike) { ElectricBike electricBike = bike as ElectricBike; rentingCategoryTxt.Text = "Xe đạp điện"; rentingRemainPowerValueLbl.Text = $"${electricBike.Powers}%"; rentingLicenseTxt.Text = electricBike.LicensePlate; } else { rentingCategoryTxt.Text = "Xe đạp đôi"; rentingRemainPowerValueLbl.Text = "Không có thông tin"; rentingLicenseTxt.Text = "Không có thông tin"; } rentingManufactureTxt.Text = bike.Manufacturer; }
public static Vehicle BuildVehicle(eVehicleType i_SelectedType) { Vehicle newVehicle = null; switch (i_SelectedType) { case eVehicleType.FuelTruck: newVehicle = new FuelTruck(); break; case eVehicleType.ElectricCar: newVehicle = new ElectricCar(); break; case eVehicleType.ElectricBike: newVehicle = new ElectricBike(); break; case eVehicleType.FuelBike: newVehicle = new FuelBike(); break; case eVehicleType.FuelCar: newVehicle = new FuelCar(); break; } return(newVehicle); }
/// <summary> /// Fill bike information in rent bike /// </summary> /// <param name="bike">The bike id of specified bike</param> public void FillRentElectricInfoForm(BaseBike bike) { FillInfo(bike); ElectricBike electricBike = bike as ElectricBike; rentBikeInfoCategoryTxt.Text = "Xe đạp điện"; rentBikeInfoLicenseTxt.Text = electricBike.LicensePlate; }
public void UpdateBikeTest() { UpdateBikeInfo update = new UpdateBikeInfo() { Manufacturer = "A" }; ElectricBike bike = electricBikeService.UpdateBike(1, update); Assert.IsTrue(bike.Manufacturer == "A"); }
static public void Run() { Console.WriteLine("------------TemplateMethod------------"); Car car = new Car(); car.Cycle(); ElectricBike electricBike = new ElectricBike(); electricBike.Cycle(); }
private static TwoWheeler BuildElectricBike() // test ElectricBike, selected whole options. { TwoWheelerBuilder builder = new ElectricBike(); TwoWheeler twoWheeler; builder.MakeFrame(); builder.AssembleFrontWheel(25.0); builder.AssembleRearWheel(25.0); builder.PutSaddle("Triangle"); twoWheeler = builder.Build(); return(builder.Build()); }
static void Main() { IMotorcycle motorBike = new Motorcycle(); //That is expected, as IMotorcycle can Accelerate. motorBike.Accelerate(); IBike newBike = new ElectricBike(); //That too is expected, as IBike can Pedal. newBike.Pedal(); //Now that´s something new, as IBike cannot Accelerate, //but the the ElectricBike adapter can, as it implements both interfaces. (newBike as IMotorcycle).Accelerate(); Console.Read(); }
static void Main(string[] args) { Vehicle _bike = new Bike(); Vehicle _truck = new Truck(); Bike _electricBike = new ElectricBike(); _bike.Go(); _truck.Go(); _electricBike.Go(); Console.WriteLine($"{_truck.a} {((Truck)_truck).a}"); _bike.Introduce(); _truck.Introduce(); _electricBike.Introduce(); Console.ReadKey(); }
/// <summary> /// Display bike information /// </summary> /// <param name="bike">The bike information</param> /// <param name="stationName">The station name contain this bike</param> /// <param name="stationAddress">The station address contain this bike</param> public void FillBikeInformation(BaseBike bike, string stationName, string stationAddress) { stationRtb.Text = $"{stationName}\n{stationAddress}"; qrCodeTxt.Text = bike.QRCode; manufactureTxt.Text = bike.Manufacturer; avatarPb.Image = Image.FromFile(bike.Images); if (bike.BikeStatus) { statusBikeLbl.Text = "Renting"; statusBikeLbl.BackColor = Color.Red; viewRentingBut.Visible = true; rentThisBikeBut.Visible = false; } else { statusBikeLbl.Text = "Available"; statusBikeLbl.BackColor = Color.Green; viewRentingBut.Visible = false; rentThisBikeBut.Visible = true; } if (bike.Category == "bike") { categoryBikeTxt.Text = "Xe đạp thường"; powerTxt.Text = "Không có thông tin"; licenceTxt.Text = "Không có thông tin"; this.category = BikeCategory.BIKE; } else if (bike.Category == "tandem") { categoryBikeTxt.Text = "Xe đạp đôi"; powerTxt.Text = "Không có thông tin"; licenceTxt.Text = "Không có thông tin"; this.category = BikeCategory.TANDEM; } else { ElectricBike electric = bike as ElectricBike; categoryBikeTxt.Text = "Xe đạp điện"; powerTxt.Text = $"{electric.Powers}%"; licenceTxt.Text = electric.LicensePlate; this.category = BikeCategory.ELECTRIC; } this.bike = bike; }
/// <summary>Get bike by QR code</summary> /// <param name="QRCode">QR Code you want to find</param> /// <returns>Return the bike with specified QR Code or null if not found</returns> public BaseBike GetBikeByQRCode(string QRCode) { BaseBike baseBike = connecter.SqlData.BaseBikes.SingleOrDefault(x => x.QRCode == QRCode); BaseBike result = null; if (baseBike.Category == "bike") { result = new Bike(baseBike); } else if (baseBike.Category == "tandem") { result = new Tandem(baseBike); } else if (baseBike.Category == "electric") { ElectricBikeTable electricBike = connecter.SqlData.ElectricBikes.Find(baseBike.BikeId); result = new ElectricBike(baseBike, electricBike); } return(result); }
/// <summary> /// Get bike by bike's id /// </summary> /// <param name="id">the bike's id you want to find</param> /// <returns>Return the bike with specified ID or null if not found</returns> public BaseBike GetBikeById(int id) { BaseBike baseBike = connecter.SqlData.BaseBikes.Find(id); BaseBike result = null; if (baseBike.Category == "bike") { result = new Bike(baseBike); } else if (baseBike.Category == "tandem") { result = new Tandem(baseBike); } else if (baseBike.Category == "electric") { ElectricBikeTable electricBike = connecter.SqlData.ElectricBikes.Find(baseBike.BikeId); result = new ElectricBike(baseBike, electricBike); } return(result); }
/// <summary> /// Display bike information /// </summary> /// <param name="bike">The bike information</param> /// <param name="stationName">The station name contain this bike</param> /// <param name="stationAddress">The station address contain this bike</param> public void FillBikeInformation(BaseBike bike, string stationName, string stationAddress) { stationRtb.Text = string.Format("{0}\n{1}", stationName, stationAddress); qrCodeTxt.Text = bike.QRCode; manufactureTxt.Text = bike.Manufacturer; if (bike.BikeStatus) { statusBikeLbl.Text = "Renting"; statusBikeLbl.BackColor = Color.Red; } else { statusBikeLbl.Text = "Availiable"; statusBikeLbl.BackColor = Color.Green; } if (bike is Bike) { categoryBikeTxt.Text = "Xe đạp thường"; powerTxt.Text = "Không có thông tin"; licenceTxt.Text = "Không có thông tin"; rentThisBikeBut.Tag = (bike.BikeId, Config.SQL.BikeCategory.BIKE); } else if (bike is Tandem) { categoryBikeTxt.Text = "Xe đạp đôi"; powerTxt.Text = "Không có thông tin"; licenceTxt.Text = "Không có thông tin"; rentThisBikeBut.Tag = (bike.BikeId, Config.SQL.BikeCategory.TANDEM); } else { ElectricBike electric = bike as ElectricBike; categoryBikeTxt.Text = "Xe đạp điện"; powerTxt.Text = $"{electric.Powers}%"; licenceTxt.Text = electric.LicensePlate; rentThisBikeBut.Tag = (bike.BikeId, Config.SQL.BikeCategory.ELECTRIC); } }
public void GetBikeByIdTest() { ElectricBike electricBike = electricBikeService.GetBikeById(1); Assert.IsTrue(electricBike is ElectricBike); }
public void GetBikeByNotExistQRcodeTest() { ElectricBike electricBike = electricBikeService.GetBikeByQRCode("200000000"); Assert.IsNull(electricBike); }
public void GetBikeByQRCodeTest() { ElectricBike electricBike = electricBikeService.GetBikeByQRCode("200000001"); Assert.IsTrue(electricBike is ElectricBike); }