private List<string> FindUsersSeeingThisVehicle(Taxi.PositionBearing position) { return UserBounds.Where(b => b.Value.ZoomLevel > 10 && b.Value.Contains(position.Longitude, position.Latitude)) .Select(b => b.Key) .ToList(); }
static void Main() { Taxi t = new Taxi(); t.FareChangeEvent += new ValueChangeEventHandler(OnValueChange); t.SetFare(10); }
private async Task PositionChanged(Taxi.PositionBearing position) { var zoomedInUsers = FindUsersSeeingThisVehicle(position); await _chat.Clients.Clients(zoomedInUsers).positionChanged(position); //pipe the position to the aggregator _aggregator.Tell(position); }
public Taxi Create(Taxi taxi) { _unitOfWork.TaxiRepository.Insert(taxi); _unitOfWork.Save(); return(taxi); }
public void Delete(Taxi taxi) { _unitOfWork.TaxiRepository.Delete(taxi); _unitOfWork.Save(); }
public Taxi Update(Taxi taxi) { _unitOfWork.TaxiRepository.Update(taxi); _unitOfWork.Save(); return(taxi); }
static void Main(string[] args) { //First set of test code var tollCalc = new TollCalculator(); var car = new Car(); var taxi = new Taxi(); var bus = new Bus(); var truck = new DeliveryTruck(); Console.WriteLine($"The toll for a car is {tollCalc.CalculateToll(car)}"); Console.WriteLine($"The toll for a taxi is {tollCalc.CalculateToll(taxi)}"); Console.WriteLine($"The toll for a bus is {tollCalc.CalculateToll(bus)}"); Console.WriteLine($"The toll for a truck is {tollCalc.CalculateToll(truck)}"); try { tollCalc.CalculateToll("this will fail"); } catch (ArgumentException e) { Console.WriteLine("Caught an argument exception when using the wrong type"); } try { tollCalc.CalculateToll(null !); } catch (ArgumentNullException e) { Console.WriteLine("Caught an argument exception when using null"); } /* 2nd test (after adding for occupants) * var tollCalc = new TollCalculator(); * var soloDriver = new Car(); * var twoRideShare = new Car { Passengers = 1 }; * var threeRideShare = new Car { Passengers = 2 }; * var fullVan = new Car { Passengers = 5 }; * var emptyTaxi = new Taxi(); * var singleFare = new Taxi { Fares = 1 }; * var doubleFare = new Taxi { Fares = 2 }; * var fullVanPool = new Taxi { Fares = 5 }; * var lowOccupantBus = new Bus { Capacity = 90, Riders = 15 }; * var normalBus = new Bus { Capacity = 90, Riders = 75 }; * var fullBus = new Bus { Capacity = 90, Riders = 85 }; * var heavyTruck = new DeliveryTruck { GrossWeightClass = 7500 }; * var truck = new DeliveryTruck { GrossWeightClass = 4000 }; * var lightTruck = new DeliveryTruck { GrossWeightClass = 2500 }; * Console.WriteLine($"The toll for a solo driver is {tollCalc.CalculateToll(soloDriver)}"); * Console.WriteLine($"The toll for a two ride share is {tollCalc.CalculateToll(twoRideShare)}"); * Console.WriteLine($"The toll for a three ride share is {tollCalc.CalculateToll(threeRideShare)}"); * Console.WriteLine($"The toll for a fullVan is {tollCalc.CalculateToll(fullVan)}"); * Console.WriteLine($"The toll for an empty taxi is {tollCalc.CalculateToll(emptyTaxi)}"); * Console.WriteLine($"The toll for a single fare taxi is {tollCalc.CalculateToll(singleFare)}"); * Console.WriteLine($"The toll for a double fare taxi is {tollCalc.CalculateToll(doubleFare)}"); * Console.WriteLine($"The toll for a full van taxi is {tollCalc.CalculateToll(fullVanPool)}"); * Console.WriteLine($"The toll for a low-occupant bus is {tollCalc.CalculateToll(lowOccupantBus)}"); * Console.WriteLine($"The toll for a regular bus is {tollCalc.CalculateToll(normalBus)}"); * Console.WriteLine($"The toll for a bus is {tollCalc.CalculateToll(fullBus)}"); * Console.WriteLine($"The toll for a truck is {tollCalc.CalculateToll(heavyTruck)}"); * Console.WriteLine($"The toll for a truck is {tollCalc.CalculateToll(truck)}"); * Console.WriteLine($"The toll for a truck is {tollCalc.CalculateToll(lightTruck)}"); * try * { * tollCalc.CalculateToll("this will fail"); * } * catch (ArgumentException e) * { * Console.WriteLine("Caught an argument exception when using the wrong type"); * } * try * { * tollCalc.CalculateToll(null); * } * catch (ArgumentNullException e) * { * Console.WriteLine("Caught an argument exception when using null"); * } */ /* * Console.WriteLine("Testing the time premiums"); * var testTimes = new DateTime[] * { * new DateTime(2019, 3, 4, 8, 0, 0), // morning rush * new DateTime(2019, 3, 6, 11, 30, 0), // daytime * new DateTime(2019, 3, 7, 17, 15, 0), // evening rush * new DateTime(2019, 3, 14, 03, 30, 0), // overnight * new DateTime(2019, 3, 16, 8, 30, 0), // weekend morning rush * new DateTime(2019, 3, 17, 14, 30, 0), // weekend daytime * new DateTime(2019, 3, 17, 18, 05, 0), // weekend evening rush * new DateTime(2019, 3, 16, 01, 30, 0), // weekend overnight * }; * foreach (var time in testTimes) * { * Console.WriteLine($"Inbound premium at {time} is {tollCalc.PeakTimePremiumFull(time, true)}"); * Console.WriteLine($"Outbound premium at {time} is {tollCalc.PeakTimePremiumFull(time, false)}"); * } * Console.WriteLine("===================================================="); * foreach (var time in testTimes) * { * Console.WriteLine($"Inbound premium at {time} is {tollCalc.PeakTimePremium(time, true)}"); * Console.WriteLine($"Outbound premium at {time} is {tollCalc.PeakTimePremium(time, false)}"); * } */ }
static void Main(string[] args) { UnityBuilder builder = new UnityBuilder( new List <ICar>(), new List <ITaxi>()); Unity unity = builder.Build(); Console.WriteLine("Sum of car prices is more than 5000:" + Taxi.GetSumPrice(Taxi.Find(unity.TaxiCollection, "TaxiCity").Items, a => a.Price > 5000)); Console.WriteLine("Sum of car prices with fuel cost less than 8:" + Taxi.GetSumPrice(Taxi.Find(unity.TaxiCollection, 5814444).Items, (IOptionable b) => b.FuelCost < 8)); Console.WriteLine(Taxi.Find(unity.TaxiCollection, "TaxiCity").ToString()); IEnumerable <ICar> sortedCollectionCars = from car in Taxi.Find(unity.TaxiCollection, "TaxiCity").Items orderby(car as IOptionable).FuelCost select car; IEnumerable <ICar> selectedByMinSpeed = (Taxi.Find(unity.TaxiCollection, "TaxiCity") as Taxi).SelectBySpeed(170); IEnumerable <ICar> selectedByMinMaxSpeed = (Taxi.Find(unity.TaxiCollection, "TaxiCity") as Taxi).SelectBySpeed(170, 180); //Taxi sortedCarsTaxi = new Taxi(); //sortedCarsTaxi.Add ( sortedCollectionCars); //Console.WriteLine(sortedCarsTaxi.ToString()); }
private async Task statusChanged(Taxi.Status status) { await _chat.Clients.Group(status.Source).statusChanged(status); }
private void Start() { audio = GetComponent <AudioSource>(); taxi = FindObjectOfType <Taxi>(); }
private void OnClientEventTrigger(Client sender, string eventName, params object[] arguments) { if (eventName == "menu_handler_select_item") { // APPELER UN TAXI if ((int)arguments[0] == 101 && (int)arguments[1] == 0) { Taxi.CallTaxi(sender); } // CALL 911 if ((int)arguments[0] == 101 && (int)arguments[1] == 1) { API.shared.triggerClientEvent(sender, "get_user_input", 107, "", 144, null); } // URGENCES if ((int)arguments[0] == 101 && (int)arguments[1] == 2) { API.shared.triggerClientEvent(sender, "get_user_input", 108, "", 144, null); } // SMS if ((int)arguments[0] == 101 && (int)arguments[1] == 3) { var list = API.getAllPlayers(); List <String> Actions = new List <string>(); list.Remove(sender); API.setEntityData(sender, "list", list); foreach (Client player in list) { Actions.Add(API.getEntitySyncedData(player, "Nom_Prenom")); } API.triggerClientEvent(sender, "bettermenuManager", 106, API.getEntitySyncedData(sender, "Nom_Prenom"), "Envoyé un SMS au ~g~joueur:", false, Actions); } if ((int)arguments[0] == 106) { API.triggerClientEvent(sender, "get_user_input", 109, "", 64, (int)arguments[1]); } } else if (eventName == "menu_handler_user_input") { if ((int)arguments[0] == 109) { List <Client> list = API.getEntityData(sender, "list"); int index = (int)arguments[2]; Client recever = list[index]; String senderName = API.getEntitySyncedData(sender, "Nom_Prenom"); String message = (string)arguments[1]; API.sendNotificationToPlayer(recever, "~r~SMS reçu: ~s~'" + message + "' de: " + senderName); API.playSoundFrontEnd(recever, "Menu_Accept", "Phone_SoundSet_Default"); API.resetEntityData(sender, "list"); } // CALL 911 else if ((int)arguments[0] == 107) { var players = API.getAllPlayers(); foreach (var player in players) { if (API.getEntitySyncedData(player, "Police") == true) { API.triggerClientEvent(player, "display_subtitle", "~r~~h~[911 CALL] de " + sender.name + "~h~~y~ : " + (string)arguments[1] + "\n ~w~ Position transmise!", 13000); float posX = sender.position.X; float posY = sender.position.Y; API.sendNativeToPlayer(player, Hash.SET_NEW_WAYPOINT, posX, posY); } } } // CALL URGENCE else if ((int)arguments[0] == 108) { Faction.EMS.Hospital.CallMedic(sender, (string)arguments[1]); } } }
public ActionResult SaveOrder( long Voucher_ID, string Request, string Description, string Code, string Name, int NumberOfCustomers, decimal Price, string Phone, string Taxi_Description, OrderDetail[] order) { string result = "Error! Order Is Not Complete!"; var session = (UserLogin)Session[CommonConstants.USER_SESSION]; DailyList model = new DailyList(); model.Status = true; foreach (var item in order) { if (item.Room_ID == 0 || item.Ticket_ID == 0) { SetAlert("Lỗi khi tạo phòng và vé", "error"); return(RedirectToAction("Index")); } } if (Voucher_ID != 0) { model.Status = false; } model.Voucher_ID = Voucher_ID; var voucher = db.Vouchers.Find(Voucher_ID); if (Voucher_ID != 0 && Voucher_ID >= 100) { voucher.Status = false; db.SaveChanges(); } model.Request = Request; model.Description = Description; model.PricewithVoucher = 0; model.Total = 0; if (Price != 0) { model.Status = false; Taxi taxi = new Taxi(); taxi.Code = Code; taxi.Name = Name; taxi.NumberOfCustomers = NumberOfCustomers; taxi.Price = Price; taxi.Phone = Phone; taxi.Description = Taxi_Description; db.Taxis.Add(taxi); db.SaveChanges(); model.Taxi_ID = taxi.ID; } model.Department_ID = session.DepartmentID; model.CreatedDate = DateTime.Now; model.CreatedBy = session.UserName; db.DailyLists.Add(model); db.SaveChanges(); foreach (var item in order) { OrderDetail O = new OrderDetail(); O.Room_ID = item.Room_ID; var room = db.Rooms.Find(O.Room_ID); room.Status = false; db.SaveChanges(); O.Ticket_ID = item.Ticket_ID; var ticket = db.Tickets.Find(item.Ticket_ID); DateTime dt = DateTime.Today; string date = dt.ToString("yyyy-MM-dd"); if (db.OrderDetails.Where(x => DbFunctions.TruncateTime(x.TimeIn) == dt).Count() == 0) { O.No = date.Replace("-", "") + "-" + session.DepartmentID.ToString() + 1.ToString("D3"); } else { string Str = null; foreach (var temp in db.OrderDetails.Where(x => DbFunctions.TruncateTime(x.TimeIn) == dt).OrderByDescending(x => x.ID).Take(1)) { Str = temp.No; } string Str1 = Str.Substring(11); O.No = date.Replace("-", "") + "-" + session.DepartmentID.ToString() + (Int32.Parse(Str1) + 1).ToString("D3"); } string[] arrEmpId = string.Join(",", item.SelectedIDArray).Replace(" ", "").Split(','); O.empId = string.Join(",", item.SelectedIDArray); List <string> emplist = new List <string>(); foreach (var temp in arrEmpId) { int id = Convert.ToInt32(temp); var e = db.Employees.Find(id); e.OnAir = true; db.SaveChanges(); emplist.Add(e.Code); } O.Employee_ID = string.Join(",", emplist).Replace(" ", ""); if (model.Voucher_ID == 0) { O.Amount = ticket.Price; } else { O.Amount = ticket.Price * (1 - voucher.DiscountPercent / 100); } O.TimeIn = DateTime.Now; O.TimeOut = DateTime.Now.AddMinutes(ticket.TimeTotal); O.DailyList_ID = model.ID; model.PricewithVoucher = model.PricewithVoucher + O.Amount; db.OrderDetails.Add(O); db.SaveChanges(); foreach (var temp in arrEmpId) { DailyEmployee emp = new DailyEmployee(); emp.Order_ID = O.ID; emp.Employee_ID = long.Parse(temp); emp.Date = DateTime.Now.Date; emp.Clean = 0; emp.Tour = 0; emp.Tour = 0; db.DailyEmployees.Add(emp); db.SaveChanges(); } } model.Total = model.PricewithVoucher; db.SaveChanges(); result = "Success! Order Is Complete!"; return(Json(result, JsonRequestBehavior.AllowGet)); }
public List <Viaje> obtenerListaViaje() { Taxi taxi = (Taxi)Session["centralTaxi"]; return(taxi.ListViaje); }
private static bool IsBonus(Taxi car, int step) { return(RouteHelper.RouteDistance(car.CurrentCoords, car.CurrentRoute.StartPoint) + step <= car.CurrentRoute.StartTime); }
static void Main() { Taxi t = new Taxi(); Console.WriteLine(t.IsInitialized); }
/// <summary> /// main function /// </summary> /// <param name="args">args</param> static void Main(string[] args) { WriteLine("#########create bus#########"); Bus bus19E = new Bus("19e820"); WriteLine(bus19E); WriteLine($"Is can ride: {bus19E.IsCanRide}"); WriteLine(); WriteLine("#########add permanent driver in bus#########"); bus19E.BoardDriver("Vasiliy"); bus19E.BoardDriver("Petr"); WriteLine(bus19E); WriteLine($"Is can ride: {bus19E.IsCanRide}"); WriteLine(); WriteLine("#########board passengers in bus#########"); int queueCount = bus19E.BoardPassengers(15).Count; WriteLine(bus19E); WriteLine($"Is can ride: {bus19E.IsCanRide}"); WriteLine($"Last peoples in queue: {queueCount}"); queueCount = bus19E.BoardPassengers(25).Count; WriteLine(bus19E); WriteLine($"Is can ride: {bus19E.IsCanRide}"); WriteLine($"Last peoples in queue: {queueCount}"); WriteLine(); WriteLine("#########bus passengers#########"); foreach (var people in bus19E.Passengers) { WriteLine($"{people.GetType()}: {people.Name} - {(new Bus("")).Cost((people))} rub"); } WriteLine(); WriteLine(); WriteLine("#########create taxi#########"); Taxi taxiYa = new Taxi("7459356"); WriteLine(taxiYa); WriteLine($"Is can ride: {taxiYa.IsCanRide}"); WriteLine(); WriteLine("#########add permanent driver in taxi#########"); taxiYa.BoardDriver("Ignat"); taxiYa.BoardDriver("Aaron"); WriteLine(taxiYa); WriteLine($"Is can ride: {taxiYa.IsCanRide}"); WriteLine(); WriteLine("#########board passengers in taxi#########"); try { queueCount = taxiYa.BoardPassengers(2).Count; WriteLine($"Last peoples in queue: {queueCount}"); } catch (Exception e) { Console.WriteLine(e.Message); } WriteLine(taxiYa); WriteLine($"Is can ride: {taxiYa.IsCanRide}"); taxiYa.ChildChairsExisting = true; try { queueCount = taxiYa.BoardPassengers(5).Count; WriteLine($"Last peoples in queue: {queueCount}"); } catch (Exception e) { Console.WriteLine(e.Message); } WriteLine(taxiYa); WriteLine($"Is can ride: {taxiYa.IsCanRide}"); WriteLine(); WriteLine("#########taxi passengers#########"); foreach (var people in taxiYa.Passengers) { WriteLine($"{people.GetType()}: {people.Name} - {taxiYa.Cost((people))} rub"); } WriteLine(); }
//heelo static void Main(string[] args) { Command com = new Command(); while (true) { Console.WriteLine(" - - - ->>>>>>TAXI SERVICE: "); Console.WriteLine("______Choose an option_______: "); Console.WriteLine("1. Show available taxi"); Console.WriteLine("2. Show information of taxi drivers"); Console.WriteLine("3. Exit"); char user = '******'; try { user = Convert.ToChar(Console.ReadLine()); if (!char.IsDigit(user)) { throw new Exception("Not possible among options"); } } catch (Exception e) { log.Error($"Error: {e.Message}"); } if (user == '1') { com.Print(); Console.WriteLine("\n"); while (true) { Console.WriteLine("1 Add taxi cars \n"); Console.WriteLine("2 Add taxi buses\n"); Console.WriteLine("3 Exit\n\n"); char user2; user2 = Convert.ToChar(Console.ReadLine()); if (user2 == '1') { Console.WriteLine("Enter id,Make,number,color and max speed:\n"); int id = Convert.ToInt32(Console.ReadLine()); string make = Console.ReadLine(); int number = Convert.ToInt32(Console.ReadLine()); string color = Console.ReadLine(); int MaxSpeed = Convert.ToInt32(Console.ReadLine()); Taxi t = new Taxi(id, make, number, color, MaxSpeed); Console.WriteLine("Enter Driver name,rate and price:\n"); string name = Console.ReadLine(); int rate = Convert.ToInt32(Console.ReadLine()); int price = Convert.ToInt32(Console.ReadLine()); DriverCar d = new DriverCar(id, name, rate, price); com.AddTaxi(t); com.AddDriverCar(d); } else if (user2 == '2') { Console.WriteLine("Enter id Make,number,color and max speed:\n"); int id = Convert.ToInt32(Console.ReadLine()); string make = Console.ReadLine(); int number = Convert.ToInt32(Console.ReadLine()); string color = Console.ReadLine(); int MaxSpeed = Convert.ToInt32(Console.ReadLine()); Bus t = new Bus(id, make, number, color, MaxSpeed); Console.WriteLine("Enter Driver name,rate and price:\n"); string name = Console.ReadLine(); int rate = Convert.ToInt32(Console.ReadLine()); int price = Convert.ToInt32(Console.ReadLine()); DriverBus d = new DriverBus(id, name, rate, price); com.AddBus(t); com.AddDriverBus(d); } else { break; } } } else if (user == '2') { com.WriteAllDrivers(); Console.WriteLine("\n"); while (true) { Console.WriteLine("A-- Show driver with max rating \n"); Console.WriteLine("B--Change rating in a certain driver\n"); Console.WriteLine("C-- Exit\n\n"); char user2; user2 = Convert.ToChar(Console.ReadLine()); if (user2 == 'A') { Console.WriteLine(com.showRate()); } else if (user2 == 'B') { com.changeRate(); } else { break; } } } if (user == '3') { break; } } Console.ReadKey(); }
private void MainScreen_Load(object sender, EventArgs e) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); this.Size = this.MinimumSize; timer1.Interval = 1000; //1 sec timer1.Tick += new EventHandler(timer1_Tick); timer1.Start(); SetTime(); { StreamReader f = new StreamReader("Drivers.txt", Encoding.GetEncoding(1251)); string S; S = f.ReadLine(); while ((S = f.ReadLine()) != null) { Driver tmp = new Driver(S); Drivers.Add(tmp); } f.Close(); }//init Drivers { StreamReader f = new StreamReader("Taxies.txt", Encoding.GetEncoding(1251)); string S; S = f.ReadLine(); while ((S = f.ReadLine()) != null) { Taxi tmp = new Taxi(S); Taxis.Add(tmp); } f.Close(); }//init Taxis { StreamReader f = new StreamReader("Companies.txt", Encoding.GetEncoding(1251)); string S; S = f.ReadLine(); while ((S = f.ReadLine()) != null) { Company tmp = new Company(S); for (int i = 0; i < Taxis.Count(); ++i) { for (int j = 0; j < Taxis[i].companies.Count(); ++j) { if ((Taxis[i].companies[j] == tmp.name) && (Drivers[Taxis[i].driver_id].available)) { tmp.taxis.Add(Taxis[i]); } } } if (tmp.taxis.Count != 0) { Companies.Add(tmp); } } f.Close(); }//init Companies { StreamReader f = new StreamReader("Places.txt", Encoding.GetEncoding(1251)); string S; S = f.ReadLine(); while ((S = f.ReadLine()) != null) { string[] data = S.Split(','); Location tmp = new Location(); tmp.X = Convert.ToDouble(data[1]); tmp.Y = Convert.ToDouble(data[2]); Places.Add(data[0], tmp); } f.Close(); foreach (KeyValuePair <string, Location> elt in Places) { PlacesToGo.Items.Add(elt.Key); PlacesToGo2.Items.Add(elt.Key); } }//init Places AdaptiveDesign(); for (int i = 0; i < Companies.Count(); ++i) { double tmp = System.Math.Round(Companies[i].rating, 1); ServiseChooser.Items.Add(Companies[i].name + " / " + tmp.ToString()); } ClassChooser.Items.Add("Эконом"); ClassChooser.Items.Add("Комфорт"); ClassChooser.Items.Add("Бизнес"); }
private async Task positionChanged(Taxi.PositionBearing position) { await _chat.Clients.Group(position.Source).positionChanged(position); }
static void Main() { Taxi t = new Taxi(); //Create a new Taxi, therefore call the constructor Console.WriteLine(t.isInitialized); //Writes "true" on console. }
static void Main() { Taxi t = new Taxi(); Console.WriteLine(t.isInitialized); }
private Taxi CreateTaxi() { Taxi pz = new Taxi(); pz.ItemType = new List<music>(); if (radioButton1.Checked) pz.carType = CarType.taz; else pz.carType = CarType.netaz; if (checkBox1.Checked) pz.ItemType.Add(music.shanson); if (checkBox2.Checked) pz.ItemType.Add(music.classic); if (checkBox3.Checked) pz.ItemType.Add(music.rock); if (checkBox4.Checked) pz.ItemType.Add(music.pop); return pz; }