// [HideInInspector] public GameObject car; // Use this for initialization void Awake() { secondCanvas = GameObject.Find("SecondCanvas"); fireBackground = GameObject.Find("FireBackground"); fireStart = GameObject.Find("FireStart"); garage = GameObject.FindObjectOfType<Garage>(); taskMenu = GameObject.FindObjectOfType<TaskMenu>(); kaController = GameObject.FindObjectOfType<KAController>(); waitBackground = GameObject.FindObjectOfType<WaitBackground>(); mainScreen = GameObject.FindObjectOfType<MainScreen>(); bg = GameObject.Find("BG"); carsInfo = GetComponent<CarsInfo>(); filling = GameObject.FindObjectOfType<Filling>(); carChanger = GameObject.FindObjectOfType<CarChanger>(); dustSmall = GameObject.Find("DustSmall"); windowWarning = GameObject.FindObjectOfType<WindowWarning>(); windowConfirmation = GameObject.FindObjectOfType<WindowConfirmation>(); mainBonus = GetComponent<MainBonus>(); dailyEvents = GetComponent<DailyEvents>(); moneyBar = GameObject.FindObjectOfType<MoneyBar>(); boosterMenu = GameObject.FindObjectOfType<BoosterMenu>(); dailyGiftMenu = GameObject.FindObjectOfType<DailyGiftMenu>(); backMenuButton = GameObject.FindObjectOfType<BackMenuButton>(); /* car = garage.transform.Find("Car").gameObject; if (car == null) CreateCar(); */ }
static void Main() { _garage = Configure.GarageWithRandomTime(); _parkingReceipts = new Dictionary<string, ParkingReceipt>(); while (true) { PrintUserChoices(); UserInput input = CaptureUserInput(); switch (input) { case UserInput.ParkCar: ParkCar(); break; case UserInput.ExitCar: ExitCar(); break; case UserInput.ViewCars: ViewCars(); break; case UserInput.Undefined: PrintUndefined(); break; case UserInput.ShutDown: ShutDown(); break; } } }
protected void Button1_Click(object sender, EventArgs e) { if (begin_time_list.SelectedIndex >= 0 && date_cal.SelectedDate != null && end_time_list.SelectedIndex >= 0 && textbox_location.Value != "" && textbox_description.Value != "") { try { string address = textbox_location.Value.ToString(); string description = textbox_description.Value.ToString(); DateTime begintime = date_cal.SelectedDate.Date + DateTime.Parse(begin_time_list.SelectedValue).TimeOfDay; DateTime endtime = date_cal.SelectedDate.Date + DateTime.Parse(end_time_list.SelectedValue).TimeOfDay; if (date_cal.SelectedDate.CompareTo(DateTime.Now) < 0) throw new InvalidDataException("You cannot create a garage sale in the past"); if (endtime.CompareTo(begintime) <= 0) throw new InvalidDataException("End Time is before start time"); MembershipUser user = Membership.GetUser(); Guid userId = (Guid)user.ProviderUserKey; Garage garageSale = new Garage(userId, begintime, endtime, address, description); if (imageUpload.HasFile) { int imageId = saveImageFile(); garageSale.imageId = imageId; } garageSale = GarageDataService.addGarageSale(garageSale); textbox_description.Value = ""; textbox_location.Value = ""; begin_time_list.SelectedIndex = 0; end_time_list.SelectedIndex = 0; date_cal.SelectedDate = DateTime.Now; creategarage_output.Text = "Garage Sale created successfully!"; creategarage_output.Style.Add("color", "#00ff00"); } catch (Exception ex) { creategarage_output.Text = ex.Message; } } else { bool b1 = begin_time_list.SelectedIndex > 0; bool b2 = (date_cal.SelectedDate != null); bool b3 = (end_time_list.SelectedIndex > 0); bool b4 = (textbox_location.Value != ""); bool b5 = (textbox_description.Value != ""); /* Please fill all fields */ creategarage_output.Text = "Please fill all of the fields."; creategarage_output.Style.Add("color", "#ff0000"); } }
static void Main(string[] args) { Garage cars = new Garage(); foreach (Car c in cars) { Console.WriteLine("{0} is going {1} MPH",c.name, c.speed); } }
static void Main(string[] args) { Garage cars = new Garage(); cars.Cars.Add(new Car("volvo", "240", 4, "Red", new Engine(4, 2300))); cars.Cars.Add(new Car("Buatti", "Veiron", 4, "Black", new Engine(16, 6036))); cars.Cars.Add(new Car("Audi", "A4", 4, "Silver", new Engine(5, 4500))); foreach(Car c in cars.Cars) { Console.WriteLine(c.GetDescription()); } Console.ReadLine(); }
public static Garage addGarageSale(Garage gs) { SqlConnection conn = DBConnector.getSqlConnection(); conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO GarageSale (UserID, DateBegin, DateEnd, Address, Description, Image) VALUES (@UserId, @DateBegin, @DateEnd, @Address, @Description, @Image); SELECT SCOPE_IDENTITY()", conn); cmd.Parameters.AddWithValue("@UserId", gs.userID); cmd.Parameters.AddWithValue("@DateBegin", gs.DateBegin); cmd.Parameters.AddWithValue("@DateEnd", gs.DateEnd); cmd.Parameters.AddWithValue("@Address", gs.Address); cmd.Parameters.AddWithValue("@Description", gs.Description); cmd.Parameters.AddWithValue("@Image", gs.imageId); int uid = Convert.ToInt32(cmd.ExecuteScalar()); conn.Close(); gs.GarageID = uid; return gs; }
public static IEstate CreateEstate(EstateType type) { IEstate estate = null; switch (type) { case EstateType.Apartment: estate = new Apartment(); break; case EstateType.Office: estate = new Office(); break; case EstateType.House: estate = new House(); break; case EstateType.Garage: estate = new Garage(); break; default: break; } return estate; }
public void CreateMessagePublishedEventOfRDWResponse() { var publisherMock = new Mock <IEventPublisher>(MockBehavior.Strict); publisherMock.Setup(pub => pub.Publish(It.IsAny <DomainEvent>())); var testEvent = new AutoKlaargemeldEvent() { VoertuigType = (int)VoertuigTypes.Personenauto, Kenteken = "AB-BA-22", KilometerStand = 1234, EigenaarNaam = "J. jansen", AutoId = 1, GUID = Guid.NewGuid().ToString(), RoutingKey = "", TimeStamp = DateTime.UtcNow }; Garage testGarage = new Garage() { GarageNaam = "Jomaya", PlaatsNaam = "Utrecht" }; using (var target = new RDWService(publisherMock.Object)) { target.Createmessage(testEvent, testGarage); Thread.Sleep(1000); publisherMock.Verify(pub => pub.Publish(It.IsAny <DomainEvent>()), Times.Once()); } }
public static IEstate CreateEstate(EstateType type) { Estate estate; switch (type) { case EstateType.Apartment: estate = new Apartment(); break; case EstateType.Garage: estate = new Garage(); break; case EstateType.House: estate = new House(); break; case EstateType.Office: estate = new Office(); break; default: throw new ArgumentException("Invalid type for estste."); } return estate; }
public async Task <IActionResult> Create([Bind("GarageId")] Garage garage) { if (ModelState.IsValid) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var client = _context.Clients.Where(c => c.IdentityUserId == userId).FirstOrDefault(); garage.ClientId = client.ClientId; garage.IdentityUserId = userId; var car = _context.Cars.Where(c => c.IdentityUserId == userId).FirstOrDefault(); if (car == null) { return(RedirectToAction("CreateCar")); } garage.CarId = car.CarId; _context.Add(garage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(garage)); }
public void Remove_At_Front_Success() { // Arrange var garage = new Garage <TestVehicle>(4); var car = new TestVehicle(); garage.Add(car); garage.Add(new TestVehicle()); garage.Add(new TestVehicle()); // Act bool success = garage.Remove(car); // Assert Assert.IsTrue(success); foreach (var item in garage) { Assert.AreNotSame(car, item); } Assert.AreEqual(2, garage.Count); Assert.AreEqual(2, garage.Count()); // Just to make sure the iterator agrees // (this actually caught a bug, see Garage.Remove(T vehicle)) }
/// <summary> /// Metoden tar bort ett parkerat fordon från garaget /// </summary> /// <param name="vehicle">Fordonet som skall tas bort från garaget</param> /// <returns>true om det gick radera fordonet. Annars returneras false</returns> /// <exception cref="System.ArgumentNullException">Kastas om referensen till vehicle är null</exception> public bool RemoveVehicle(ICanBeParkedInGarage vehicle) { if (vehicle == null) { throw new ArgumentNullException("ArgumentNullException. GarageHandler.RemoveVehicle(ICanBeParkedInGarage vehicle). Referensen till vehicle är null"); } var tmpVehicle = vehicle as IVehicle; string strRegistrationNumber = tmpVehicle?.RegistrationNumber; bool bRemovedVehicle = Garage.Remove(vehicle); if (bRemovedVehicle) { Ui.WriteLine($"Fordon {vehicle.GetType().Name} med registreringsnummer {strRegistrationNumber} har lämnat garaget"); } else { Ui.WriteLine($"Fordon {vehicle.GetType().Name} med registreringsnummer {strRegistrationNumber} kan inte lämna garaget. Bilen finns troligen inte i garaget"); } return(bRemovedVehicle); }
// GET: Garages/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Garage entity = db.Garages.Find(id); if (entity == null) { return(HttpNotFound()); } ViewBag.StateId = new SelectList(db.States, "Id", "StateName", entity.State); ViewBag.CityId = new SelectList(db.Cities.Where(b => b.StateID == entity.State), "Id", "CityName", entity.City); GarageViewModel model = new GarageViewModel(); model.GarageId = entity.GarageId; model.Garage_Name = entity.Garage_Name; model.Contact_Person = entity.Contact_Person; model.Email = entity.Email; model.Phone_Number = entity.Phone_Number; model.IsActive = entity.IsActive; model.Garage_Address = entity.Garage_Address; model.City = entity.City; model.State = entity.State; model.Pincode = entity.Pincode; model.OpenTime = entity.OpenTime; model.CloseTime = entity.CloseTime; model.ServiceDays = entity.ServiceDays.Split(','); model.AvailableServiceDays = ListHelper.GetDayNameList(); model.AvailableSubscriptionTypes = ListHelper.GetSubscriptionTypeList(); return(View(model)); }
public void shouldFuelAllCars() { // Tests FuelAllCars() method // Arrange var xxx = new Garage(); // Act int numCars = 4; int numCarsThatUsedFuel = 0; for (int i = 0; i < numCars; i++) { xxx.AddCar(); //add a car xxx.TheGarage[i].ToggleEngine(); //start the engine xxx.TheGarage[i].Accelerate(); //consume some fuel if (xxx.TheGarage[i].GetFuelLevel() != 100) { numCarsThatUsedFuel++; //make sure fuel was used } } if (numCars != numCarsThatUsedFuel) { Assert.Equal(numCars, numCarsThatUsedFuel); } else { xxx.FuelAllCars(); int totalFuel = 0; foreach (Car theCar in xxx.TheGarage) { totalFuel += theCar.GetFuelLevel(); } // Assert Assert.Equal(numCars * 100, totalFuel); } }
public static void LoadAllGarageFromDB() { Dictionary <string, string> parameters = new Dictionary <string, string>(); DataTable result = DatabaseHandler.ExecutePreparedStatement("SELECT * FROM garages", parameters); if (result.Rows.Count != 0) { foreach (DataRow row in result.Rows) { Garage garage = new Garage { Id = (int)row["Id"], Position = new Vector3((float)row["PosX"], (float)row["PosY"], (float)row["PosZ"]), PedRotation = (float)row["PedRotation"], Spawnpoints = JsonConvert.DeserializeObject <List <GarageSpawn> >((string)row["Spawnpoints"]), FactionType = (FactionType)row["FactionType"], Type = (GarageType)row["Type"] }; garage.Ped = API.shared.createPed(PedHash.Andreas, garage.Position, garage.PedRotation); if (garage.FactionType == FactionType.Citizen) { garage.MapMarker = API.shared.createBlip(garage.Position); garage.MapMarker.sprite = 50; garage.MapMarker.scale = 0.75f; garage.MapMarker.name = "Garage"; garage.MapMarker.shortRange = true; BlipService.BlipService.BlipList.Add(garage.MapMarker); } GarageList.Add(garage); } API.shared.consoleOutput(LogCat.Info, result.Rows.Count + " Garages Loaded.."); } else { API.shared.consoleOutput(LogCat.Info, "No Garages Loaded.."); } }
public IActionResult Delete(int id, string type) { _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; AutoGarage userGarage = getUserGarage(); int check = alreadyExist(id, type); if (type == "garage") { userGarage.AUTO.RemoveAt(check); } if (type == "compare") { userGarage.Compare.RemoveAt(check); } string xmlData = ConvertObjectToXMLString(userGarage); var modGarage = new Garage { UserOid = User.Claims.FirstOrDefault().Value.ToString(), UserGarage = xmlData }; _context.Update(modGarage); _context.SaveChanges(); var cacheItemPolicy = new CacheItemPolicy() { AbsoluteExpiration = DateTime.Now.AddDays(1) }; _cache.Set(User.Claims.FirstOrDefault().Value.ToString(), userGarage, cacheItemPolicy); return(RedirectToAction(nameof(Index))); }
private void garageUpdateBtn_Click(object sender, EventArgs e) { List <String> errorMessages = GarageFieldCheck(); if (errorMessages.Count == 0) { garageMsgLabel.Text = ""; Garage g = new Garage(); g.Address = garageAddressField.Text; if (bal.GetSpecifiedGarages(g).Count == 0) { garageMsgLabel.Text = "No garages with Address " + g.Address + " exists." + "Cannot update garage."; } else { g.Size = Int32.Parse(garageSizeField.Text); bal.UpdateGarage(g); garageMsgLabel.Text = "Garage with address " + g.Address + " was updated."; GarageSearch(g.Address); } } else { String errorMessage = "Could not update garage. The following values were invalid: "; foreach (String s in errorMessages) { errorMessage += "\n" + s; } MessageBox.Show(errorMessage); } }
private void garageAddBtn_Click(object sender, EventArgs e) { List <String> errorMessages = GarageFieldCheck(); if (errorMessages.Count == 0) { garageMsgLabel.Text = ""; Garage g = new Garage(); g.Address = garageAddressField.Text; if (bal.GetSpecifiedGarages(g).Count > 0) { garageMsgLabel.Text = "There already exist a garage at address " + g.Address + "\nPlease type another address"; } else { g.Size = Int32.Parse(garageSizeField.Text); bal.InsertGarage(g); garageMsgLabel.Text = "Garage with address " + g.Address + " was added."; LoadAllGarages(); } } else { String errorMessage = "Could not add garage. The following values were invalid: "; foreach (String s in errorMessages) { errorMessage += "\n" + s; } MessageBox.Show(errorMessage); } }
private void garageRemoveBtn_Click(object sender, EventArgs e) { garageMsgLabel.Text = ""; if (garageAddressField.Text == "") { garageMsgLabel.Text = "Please enter the address of the garage you want to remove"; } else { Garage g = new Garage(); g.Address = garageAddressField.Text; if (bal.GetSpecifiedGarages(g).Count == 0) { garageMsgLabel.Text = "No garages with Address " + g.Address + " exists." + "\nNo garage was removed."; } else { bal.DeleteGarage(g); garageMsgLabel.Text = "Garage with address " + g.Address + " was removed."; LoadAllGarages(); } } }
public static void ChangeVehicleStatus(Garage io_MyGarage) { bool enterLoop = true; string ownerLicenseNumber = null; GarageSlot.eGarageStatus newVehicleStatus = GarageSlot.eGarageStatus.BeingFixed; GarageSlot currentGarageSlot = null; Console.WriteLine("Please enter the vehicle license number"); ownerLicenseNumber = Console.ReadLine(); if (io_MyGarage.M_MyGarage.TryGetValue(ownerLicenseNumber, out currentGarageSlot) == false) { throw new ArgumentException("The vehicle with license number you entered does not exist in the garage ! ! !"); } else { Console.WriteLine("Choose one of the following vehicle's statuses:\n1.Being Fixed\n2.Ready\n3.Paid For"); while (enterLoop == true) { try { newVehicleStatus = GarageSlot.ToEGarageStatus(Console.ReadLine()); currentGarageSlot.UpdateVehicleStatus(newVehicleStatus); enterLoop = false; } catch (Exception exception) { Console.WriteLine(exception.Message); } } Console.WriteLine(string.Format("Success, vehicle license number {0} condition was updated to {1}.\n", ownerLicenseNumber, newVehicleStatus.ToString())); } }
public void GarageInsertAfterLoadTest() { string pathToFile = "./base.json"; var result = new int[] { 1, 2 }; var garage = new Garage(); var car = new Car() { Name = "One car", Number = "et2314fd", WheelCount = 4, MaxSpeed = 123, InstalledGas = false }; garage.Store(car); garage.Save(pathToFile); var newGarage = new Garage(pathToFile); var car2 = new Car() { Name = "Two car", Number = "wr6346fg", WheelCount = 3, MaxSpeed = 98, InstalledGas = false }; newGarage.Store(car2); var ids = newGarage.GetIds(); CollectionAssert.AreEqual(result, ids); }
public void Garage_Remove_Vehicle_At_Wrong_Index_Test() { // Assert.Pass(); // Arrange // expected Guid guid = Guid.NewGuid(); Garage <ICanBeParkedInGarage> garage = new Garage <ICanBeParkedInGarage>(guid, "Garage 1", 5); ICanBeParkedInGarage vehicle1 = new Car("AAA 111", "Röd", 4); garage.Add(vehicle1); // Act // actual // Assert Assert.Throws <ArgumentOutOfRangeException>(() => garage.Remove(-1)); Assert.Throws <ArgumentOutOfRangeException>(() => garage.Remove(5)); }
public static void SaveGarage(Garage garage) { if (garage == null) { return; } using (var dc = new DataContext(_connectionString)) { var table = dc.GetTable <Garage>(); var oldGarage = table.FirstOrDefault(a => a.ID == garage.ID); if (oldGarage == null) { table.InsertOnSubmit(garage); } else { garage.CopyTo(oldGarage); } dc.SubmitChanges(); } }
private static void changeVehicleStatus() { string licenseNumber = ConsoleUI.GetField("License Number: ", !v_LettersNumbersOnly, v_NumbersOnly); ConsoleUI.CreateEnumArray <eVehicleStatus>(); string newStatus = ConsoleUI.GetField("New Status: ", !v_LettersNumbersOnly, v_NumbersOnly); eVehicleStatus statusEnum = ConsoleUI.ParseEnum <eVehicleStatus>(newStatus); try { Garage.ChangeVehicleStatus(licenseNumber, statusEnum); ConsoleUI.PrintToScreen(string.Format("SUCCESS: Vehicle status was changed successfully{0}", Environment.NewLine)); } catch (ArgumentException ex) { ConsoleUI.PrintToScreen(string.Format("ERROR: {0}{1}Try again or press {2} to go back to the menu", ex.Message, Environment.NewLine, ConsoleUI.Quit)); changeVehicleStatus(); } catch { ConsoleUI.PrintToScreen(string.Format("ERROR: An error occured...{0}Try again or press {1} to go back to the menu", Environment.NewLine, ConsoleUI.Quit)); changeVehicleStatus(); } }
public void Start() { m_MyGarage = new Garage(); Menu UserMenu = new Menu(); int m_SecondMenuOption = 0; while (m_SelectedOption != k_Quit) { m_SelectedOption = PrintMainMenu(); switch (m_SelectedOption) { case 1: FirstOptionFromTheMainMenu(); switch (m_SelectedTypeVehicle) { case "1": TheChoiseOfUserIsFuelBike(); break; case "2": TheChoiseOfUserIsElectricBike(); break; case "3": TheChoiseOfUserIsAutomobile(); break; case "4": TheChoiceOfUserIsElectricAutomobile(); break; case "5": TheChoiseOfUserIsTruck(); break; default: Console.WriteLine("Wrong Option , try once again"); Console.ReadKey(); break; } break; case 2: Console.WriteLine(Menu.GetSecondOptionMenu()); m_SecondMenuOption = Convert.ToInt32(Console.ReadLine()); SecondOptionMenu(m_SecondMenuOption); break; case 3: int isVehicleInGarage = 0; isVehicleInGarage = ThirdOptionMenu(); if (!Convert.ToBoolean(isVehicleInGarage)) { int currentntOption = 0; while (currentntOption != k_QuirFromSubMenu) { Console.WriteLine(Menu.ImproveYourVehicle()); currentntOption = Convert.ToInt32(Console.ReadLine()); switch (currentntOption) { case 1: Console.Clear(); UserChooseUpdateHisVehicleStatus(); Console.Clear(); break; case 2: Console.Clear(); Console.WriteLine("Please enter the licence number"); m_MyGarage.InflateTheWhheels(Console.ReadLine()); Console.Clear(); break; case 3: UserChooseToFillFuel(); break; case 4: UserChooseChargeBaloons(); break; case 5: currentntOption = 5; Console.Clear(); break; default: Console.WriteLine("Wrong Option , try once again"); Console.ReadKey(); break; } } } break; case 4: Console.WriteLine("Thank you for visiting us , Bye Bye !!!"); Console.ReadLine(); m_SelectedOption = 4; break; } } }
public Manager(Garage <IVehicule> garage) { _garage = garage; }
public static void Main() { Car blueCar = new Car("blue", 2); Car redCar = new Car("red", 2); Person guy = new Person("Guy", "Fieri"); Person girl = new Person("Girl", "Chan"); Garage smallGarage = new Garage(2); smallGarage.ParkCar(blueCar, 0); smallGarage.ParkCar(redCar, 1); blueCar.EnterCar(girl, 0); redCar.EnterCar(guy, 0); Console.WriteLine("What would you like to do?"); Console.WriteLine("To see which spot a car is parked in and who is in which car, say 'Garage'"); Console.WriteLine("To move a Person to another Car, say 'Move Girl' or 'Move Guy'"); Console.WriteLine("Or say 'DONE' when you're finnished"); //'hello' below is for debugging //Console.WriteLine("hello!"); do { string read = Console.ReadLine().ToLower(); switch (read) { case "garage": Console.WriteLine("The " + Garage.cars[0].Color + " car is in spot 1"); if (blueCar.passengers[0] == null && blueCar.passengers[1] == null) { Console.WriteLine(redCar.passengers[0].FullName + " and"); Console.WriteLine(redCar.passengers[1].FullName + " are both in the red car"); Console.WriteLine("But no one is in the blue car."); } else if (blueCar.passengers[0] != null && blueCar.passengers[1] == null) { Console.WriteLine(blueCar.passengers[0].FullName + " is in the drivers seat."); } else if (blueCar.passengers[0] == null && blueCar.passengers[1] != null) { Console.WriteLine(blueCar.passengers[1].FullName + " is in the passengers seat."); } Console.WriteLine("The " + Garage.cars[1].Color + " car is in spot 2"); if (redCar.passengers[0] == null && redCar.passengers[1] == null) { Console.WriteLine(blueCar.passengers[0].FullName + " and"); Console.WriteLine(blueCar.passengers[1].FullName + " are both in the blue car"); Console.WriteLine("But no one is in the red car."); } else if (redCar.passengers[0] != null && redCar.passengers[1] == null) { Console.WriteLine(redCar.passengers[0].FullName + " is in the drivers seat."); } else if (redCar.passengers[0] == null && redCar.passengers[1] != null) { Console.WriteLine(redCar.passengers[1].FullName + " is in the passengers seat."); } continue; case "move girl": if (Array.Exists(blueCar.passengers, element => element == girl)) { // if girl Exists in blueCar, then ExitCar blueCar.ExitCar(null, (Array.IndexOf(blueCar.passengers, girl))); // Find a null in the redCar and EnterCar redCar.EnterCar(girl, Array.IndexOf(redCar.passengers, null)); Console.WriteLine("Girl Chan is now in seat " + Array.IndexOf(redCar.passengers, girl) + " of the red car!"); } else if (Array.Exists(redCar.passengers, element => element == girl)) { // if girl Exists in blueCar, then ExitCar redCar.ExitCar(null, (Array.IndexOf(redCar.passengers, girl))); // Find a null in the redCar and EnterCar blueCar.EnterCar(girl, Array.IndexOf(blueCar.passengers, null)); Console.WriteLine("Girl Chan is now in seat " + Array.IndexOf(blueCar.passengers, girl) + " of the blue car!"); } continue; case "move guy": if (Array.Exists(blueCar.passengers, element => element == guy)) { // if guy Exists in blueCar, then ExitCar blueCar.ExitCar(null, (Array.IndexOf(blueCar.passengers, guy))); // Find a null in the redCar and EnterCar redCar.EnterCar(guy, Array.IndexOf(redCar.passengers, null)); Console.WriteLine("Guy Fieri is now in seat " + Array.IndexOf(redCar.passengers, guy) + " of the red car!"); } else if (Array.Exists(redCar.passengers, element => element == guy)) { // if guy Exists in blueCar, then ExitCar redCar.ExitCar(null, (Array.IndexOf(redCar.passengers, guy))); // Find a null in the redCar and EnterCar blueCar.EnterCar(guy, Array.IndexOf(blueCar.passengers, null)); Console.WriteLine("Guy Fieri is now in seat " + Array.IndexOf(blueCar.passengers, guy) + " of the blue car!"); } continue; default: Console.WriteLine("If you meant 'Done', please say 'Done' again."); Console.WriteLine("Or a try a differnt command."); continue; } }while (Console.ReadLine().ToLower() != "done"); }
public ActionResult Create(GarageViewModel model) { model.Country = "US"; model.CreatedDt = DateTime.Now.Date; model.CreatedBy = "ADmin"; IGeocoder geocoder = new GoogleGeocoder() { ApiKey = "AIzaSyDfIuSL-y1mkKLD5pKFiMb6sT7ZP6MLTjs" }; IEnumerable <Address> addresses = geocoder.Geocode(model.Garage_Address); model.Latitute = addresses.First().Coordinates.Latitude; model.Longitude = addresses.First().Coordinates.Longitude; ModelState.Remove("State"); ModelState.Remove("City"); ModelState.Remove("Country"); if (ModelState.IsValid) { Garage entity = new Garage(); entity.Garage_Name = model.Garage_Name; entity.Contact_Person = model.Contact_Person; entity.Garage_Address = model.Garage_Address; entity.Phone_Number = model.Phone_Number; entity.Email = model.Email; entity.IsActive = model.IsActive.HasValue ? model.IsActive.Value : false; entity.Garage_Address = model.Garage_Address; entity.City = model.City; entity.State = model.State; entity.Pincode = model.Pincode; entity.OpenTime = model.OpenTime; entity.CloseTime = model.CloseTime; //entity.ServiceDays = model.ServiceDays; entity.ServiceDays = string.Join(",", model.ServiceDays); entity.Country = "US"; entity.CreatedDt = DateTime.Now.Date; entity.CreatedBy = "Admin"; entity.Latitute = model.Latitute; entity.Longitude = model.Longitude; try { db.Garages.Add(entity); db.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } AddNotification(Models.NotifyType.Success, "Records Successfully Saved.", true); return(RedirectToAction("Index")); } ViewBag.StateId = new SelectList(db.States, "Id", "StateName", model.State); ViewBag.CityId = new SelectList(db.Cities.Where(b => b.StateID == model.State), "Id", "CityName", model.City); model.AvailableServiceDays = ListHelper.GetDayNameList(); model.AvailableSubscriptionTypes = ListHelper.GetSubscriptionTypeList(); return(View(model)); }
public ActionResult Edit([Bind(Include = "Id,Name,NumberOfSlots")] Garage garage) { return(View(garage)); }
private void InitiliazeForm_Load(object sender, EventArgs e) { this.garages = Garage.GetAllGarages(this.connection); FillListViewGarage(); }
public CarManager() { cars = new Dictionary <int, Car>(); races = new Dictionary <int, Race>(); garage = new Garage(); }
public InitiliazeForm(Garage garage) { InitializeComponent(); this.garage = garage; }
public InitiliazeForm(Garage garage, NpgsqlConnection connection) { InitializeComponent(); this.garage = garage; this.connection = connection; }
public static Boolean updateGarageSale(String id, Garage newGarage) { SqlConnection conn = DBConnector.getSqlConnection(); conn.Open(); SqlCommand cmd = new SqlCommand("UPDATE GarageSale SET UserID = @userID, DateBegin = @DateBegin, DateEnd = @DateEnd, Address = @Address, Description = @Description, Image = @Image where GarageID = @GarageID", conn); cmd.Parameters.AddWithValue("@userID", newGarage.userID); cmd.Parameters.AddWithValue("@DateBegin", newGarage.DateBegin); cmd.Parameters.AddWithValue("@DateEnd", newGarage.DateEnd); cmd.Parameters.AddWithValue("@Address", newGarage.Address); cmd.Parameters.AddWithValue("@Description", newGarage.Description); cmd.Parameters.AddWithValue("@Image", newGarage.imageId); cmd.Parameters.AddWithValue("@GarageId", newGarage.GarageID); int rowsAffected = cmd.ExecuteNonQuery(); conn.Close(); return (rowsAffected > 0); }
private static Garage extractGS(SqlDataReader reader) { int uid = (int)reader[ColumnNames.GarageId]; Guid userId = (Guid)reader[ColumnNames.UserId]; DateTime dateb = (DateTime)reader[ColumnNames.DateBegin]; DateTime datee = (DateTime)reader[ColumnNames.DateEnd]; string address = (string)reader[ColumnNames.Address]; string description = (string)reader[ColumnNames.Description]; int imageid = (int)reader[ColumnNames.Image]; Garage garage = new Garage(uid, userId, dateb, datee, address, description); garage.imageId = imageid; return garage; }
public static void Version1() { Garage carLot = new Garage(); foreach (Car c in carLot) { Console.WriteLine("{0} is going {1} MPH", c.PetName, c.CurrentSpeed); } // manual way IEnumerator i = carLot.GetEnumerator(); i.MoveNext(); Car myCar = (Car) i.Current; Console.WriteLine("::=> {0} is going {1} MPH", myCar.PetName, myCar.CurrentSpeed); Console.WriteLine("Get the cars in reverse"); foreach (Car c in carLot.GetTheCars(true)) { Console.WriteLine("{0} is going {1} MPH", c.PetName, c.CurrentSpeed); } }
public CarManager() { this.cars = new Dictionary <int, Car>(); this.races = new Dictionary <int, Race>(); this.garage = new Garage(); }
public FormExistCustomer(Garage i_GarageManager) { InitializeComponent(); this.buttonFindCustomer.Click += ButtonFindCustomer_Click; r_GarageManager = i_GarageManager; }
void SelectUI() { if (!HasSelection()) { return; } SelectionData Single = CurrentSelectionObjects[0]; if (Single.IsWorker()) { if (_hit.transform.tag == TagLibrary.HQ_TAG) { //RadialMenuScript.instance.ShowToolOptions(Single._Worker, _hit.transform.position); if (_hit.transform.GetComponent <Tile>() != null || _hit.transform.GetComponent <HQTileTagScript>() != null) { ExecuteOrderOnAll(UnitTask.TaskType.Walk); } } else if (_hit.transform.tag == TagLibrary.VEHICLE_TAG) { if (!_hit.transform.GetComponent <Vehicle>().GetOccupied()) { RadialMenuScript.instance.ShowEmptyVehicleOptions(Single._Worker, _hit.transform.GetComponent <Vehicle>()); } } else if (_hit.transform.tag == TagLibrary.WORKER_TAG) { Worker worker = _hit.transform.gameObject.GetComponentInParent <Worker>(); List <Worker> workers = new List <Worker>(); for (int i = 0; i < CurrentSelectionObjects.Count; i++) { workers.Add(CurrentSelectionObjects[i]._Worker); } RadialMenuScript.instance.ShowWorkerOptions(workers, worker); } else { ExecuteOrderOnAll(UnitTask.TaskType.Walk); } } else { switch (_hit.transform.tag) { case TagLibrary.ROCK_TAG: RockScript rock = _hit.transform.gameObject.GetComponentInParent <RockScript>(); RadialMenuScript.instance.ShowRockOptions(rock); break; case TagLibrary.RUBBLE_TAG: RubbleScript rubble = _hit.transform.gameObject.GetComponentInParent <RubbleScript>(); RadialMenuScript.instance.ShowRubbleOptions(rubble); break; case TagLibrary.MONSTER_TAG: Monster monster = _hit.transform.GetComponentInParent <Monster>(); RadialMenuScript.instance.ShowEnemyOptions(monster); break; case TagLibrary.HQ_TAG: HQ hq = _hit.transform.GetComponentInParent <HQ>(); RadialMenuScript.instance.ShowHQOptions(hq); break; case TagLibrary.OUTPOST_TAG: Outpost outpost = _hit.transform.GetComponentInParent <Outpost>(); RadialMenuScript.instance.ShowOutpostOptions(outpost); break; case TagLibrary.GARAGE_TAG: Garage garage = _hit.transform.GetComponentInParent <Garage>(); RadialMenuScript.instance.ShowGarageOptions(garage); break; case TagLibrary.GEN_TAG: case TagLibrary.SKIP_TAG: case TagLibrary.BLOCK_TAG: case TagLibrary.TURRET_TAG: case TagLibrary.POWERGEN_TAG: Building building = _hit.transform.GetComponentInParent <Building>(); RadialMenuScript.instance.ShowBuildingOptions(building); break; case TagLibrary.ORE_TAG: Ore ore = _hit.transform.GetComponentInParent <Ore>(); RadialMenuScript.instance.ShowResourceOptionsOre(ore); break; case TagLibrary.ENERGYCRYSTAL_TAG: EnergyCrystal energyCrystal = _hit.transform.GetComponentInParent <EnergyCrystal>(); RadialMenuScript.instance.ShowResourceOptionsEnergyCrystal(energyCrystal); break; case TagLibrary.VEHICLE_TAG: Vehicle vehicle = _hit.transform.GetComponent <Vehicle>(); if (vehicle.GetOccupied()) { RadialMenuScript.instance.ShowVehicleOptions(_hit.transform.GetComponent <Vehicle>()); } else { RadialMenuScript.instance.ShowEmptyVehicleOptions(null, _hit.transform.GetComponent <Vehicle>()); } break; case TagLibrary.BURN_TAG: MushroomCluster mushroomCluster = _hit.transform.GetComponentInParent <MushroomCluster>(); RadialMenuScript.instance.ShowMushroomOptions(mushroomCluster); break; } } if (!Single.IsWorker()) { ClearSelectedObjects(false); } SetMode(CurrentSelectionMode.RadialMenu); }
public GarageDoorOpenCommand(Garage garage) { _garage = garage; }
public Controller() { this.garage = new Garage(); this.historyDatabase = new Dictionary <IProcedure, IRobot>(); }
public ActionResult Edit(GarageViewModel model) { bool findLatLong = false; Garage entity = db.Garages.Find(model.GarageId); if (entity == null) { return(HttpNotFound()); } ModelState.Remove("State"); ModelState.Remove("City"); ModelState.Remove("Country"); ViewBag.StateId = new SelectList(db.States, "Id", "StateName", model.State); ViewBag.CityId = new SelectList(db.Cities.Where(b => b.StateID == model.State), "Id", "CityName", model.City); try { IGeocoder geocoder = new GoogleGeocoder() { ApiKey = "AIzaSyA3CNMI-_JAV9-dWIctroZQTuUwjZygT3A" }; IEnumerable <Address> addresses = geocoder.Geocode(model.Garage_Address); model.Latitute = addresses.First().Coordinates.Latitude; model.Longitude = addresses.First().Coordinates.Longitude; findLatLong = true; } catch { findLatLong = false; } model.CreatedDt = DateTime.Now.Date; model.CreatedBy = User.Identity.Name; model.Country = "US"; if (ModelState.IsValid) { entity.Garage_Name = model.Garage_Name; entity.Contact_Person = model.Contact_Person; entity.Garage_Address = model.Garage_Address; entity.Phone_Number = model.Phone_Number; entity.Email = model.Email; entity.IsActive = model.IsActive.HasValue ? model.IsActive.Value : false; entity.Garage_Address = model.Garage_Address; entity.City = model.City; entity.State = model.State; entity.Pincode = model.Pincode; entity.OpenTime = model.OpenTime; entity.CloseTime = model.CloseTime; //entity.ServiceDays = model.ServiceDays; entity.ServiceDays = string.Join(",", model.ServiceDays); if (findLatLong) { entity.Latitute = model.Latitute; entity.Longitude = model.Longitude; } try { db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } AddNotification(Models.NotifyType.Success, "Records Successfully Updated.", true); return(RedirectToAction("Index")); } ViewBag.StateId = new SelectList(db.States, "Id", "StateName", model.State); ViewBag.CityId = new SelectList(db.Cities.Where(b => b.StateID == model.State), "Id", "CityName", model.City); model.AvailableServiceDays = ListHelper.GetDayNameList(); model.AvailableSubscriptionTypes = ListHelper.GetSubscriptionTypeList(); return(View(model)); }
public void SetUp() { var priceCalculator = new PriceCalculator(new List<IParkingPriceRule>()); _garage = new Garage(new CheckoutService(new DefaultTimeService(), priceCalculator)); }
private String createGarageDiv(Garage garage, Boolean updateAble) { string objectHTML = "</br></br><div class=\"garage_item_div\">"; objectHTML += "<div class=\"garage_item_img\"><img width=\"200px\" height=\"200px\" src=\"../../Helpers/GetImage.ashx?ID=" + garage.imageId + "\"></img></div>"; objectHTML += "<div class=\"garage_item_desc\"><div class=\"garage_item_user\">" + UserDataService.getUser(garage.userID).name + "</div>"; objectHTML += "<div class=\"garage_item_description\">" + garage.Description + "</div>"; objectHTML += "<div class=\"garage_item_datebegin\">From: " + garage.DateBegin + "</div>"; objectHTML += "<div class=\"garage_item_dateend\">To: " + garage.DateEnd + "</div>"; objectHTML += "<div class=\"garage_item_address\">Address: " + garage.Address + "</div>"; objectHTML += "<br/>"; objectHTML += "</div>"; if (updateAble) { objectHTML += "<button class=\"form_button\" onclick=\"editgarage('" + garage.GarageID + "', '');\">Update</button>"; } objectHTML += "</div></br></br>"; return objectHTML; }