public void CreateTaxiDriver() { string fname; while (true) { fname = View.View.GetData("Enter first name"); if (model.ValidateField(fname, Human.nameValidation)) { break; } } string sname; while (true) { sname = View.View.GetData("Enter last name"); if (model.ValidateField(sname, Human.nameValidation)) { break; } } Human taxiDriver = new TaxiDriver(fname, sname); model.Write(taxiDriver.ToString()); }
public void Test_TaxiDriverPopertiesException() { TaxiDriver driver = new TaxiDriver(1, "Радомський", "Модест", 20, "BC1789AM", 5, 50, 189); //not valid age driver.Age = 17; }
public async Task <IActionResult> CreateNewDriver(TaxiDriver driver) { dbAccesed = db.Add(driver); await db.Save(); return(RedirectToAction("AddDriver")); }
public static void Main() { Passenger p1 = new Passenger("1"); Passenger p2 = new Passenger("2"); Passenger p3 = new Passenger("3"); Passenger p4 = new Passenger("4"); Passenger p5 = new Passenger("5"); Passenger p6 = new Passenger("6"); Passenger p7 = new Passenger("7"); Passenger p8 = new Passenger("8"); Passenger p9 = new Passenger("9"); Passenger p10 = new Passenger("10"); Passenger p11 = new Passenger("11"); Passenger p12 = new Passenger("12"); Passenger p13 = new Passenger("13"); Passenger p14 = new Passenger("14"); TaxiDriver taxiDriver = new TaxiDriver(); BusDriver busDriver = new BusDriver(); BoardBus bus = new BoardBus(); BoardTaxi taxi = new BoardTaxi(); taxi.boardDriver(taxiDriver); Console.WriteLine(taxi.isReady()); }
private void startWork_Click(object sender, RoutedEventArgs e) { using (UnitOfWork.UnitOfWork content = new UnitOfWork.UnitOfWork()) { currentDriver = content.Drivers.Get(s => s.Name == driverUserName.Text).FirstOrDefault(); if (currentDriver != null) { driverInfoSurnameNameDetails.Content = currentDriver.Surname + " " + currentDriver.Name; driverInfoAgeDetails.Content = currentDriver.Age; driverInfoCarDetails.Content = currentDriver.CarNumber; driverInfoExpDetails.Content = currentDriver.Experience; driverInfoCostDetails.Content = currentDriver.PayCheck + " грн"; driverInfoCostPerMinDetails.Content = currentDriver.CostPerMinute; var currentOrders = content.Orders.Get(s => s.Driver.DriverId == currentDriver.DriverId, includeProperties: "Client"); orders.Items.Clear(); foreach (var order in currentOrders) { orders.Items.Add(order); } } else { MessageBox.Show(String.Format("Водія {0} не знайдено!!!", driverUserName.Text)); } } }
public void UpdateDriver(TaxiDriver driverToUpdate) { for (int i = 0; i < allDrivers.Count; ++i) { if (allDrivers[i].Id == driverToUpdate.Id) { allDrivers[i] = driverToUpdate; break; } } }
public ActionResult Create(TaxiDriver taxiDriver) { if (ModelState.IsValid) { var owner = db.Owners.ToList().Find(x => x.Email == User.Identity.Name); taxiDriver.ownerID = owner.ownerID; txDriverLogic.Add(taxiDriver); return(RedirectToAction("Index")); } return(View("Index")); }
public void Test_TaxiDriverConstructorAndProperties() { TaxiDriver driver = new TaxiDriver(1, "Радомський", "Модест", 20, "BC1789AM", 5, 50, 189.75); Assert.AreEqual(driver.Surname, "Радомський"); Assert.AreEqual(driver.Name, "Модест"); Assert.AreEqual(driver.Age, Convert.ToUInt32(20)); Assert.AreEqual(driver.CarNumber, "BC1789AM"); Assert.AreEqual(driver.Experience, Convert.ToUInt32(5)); Assert.AreEqual(driver.CostPerMinute, Convert.ToUInt32(50)); Assert.AreEqual(driver.PayCheck, 189.75); }
public bool Delete(TaxiDriver taxiDriver) { try { db.TaxiDrivers.Remove(taxiDriver); db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public void Test_TaxiOrderConstructorAndProperties() { TaxiClient client = new TaxiClient(2, "Модест", "+380966784576"); TaxiDriver driver = new TaxiDriver(3, "Радомський", "Модест", 20, "BC1789AM", 5, 50, 189.75); TaxiOrder order = new TaxiOrder(1, client, driver, Convert.ToDateTime("2017-12-22 17:30"), "Шевченка,44", "Зелена,12", 123); Assert.AreEqual(order.Client.Id, client.Id); Assert.AreEqual(order.Driver.Id, driver.Id); Assert.AreEqual(order.ArriveTime, Convert.ToDateTime("2017-12-22 17:30")); Assert.AreEqual(order.Dispatch, "Шевченка,44"); Assert.AreEqual(order.Destination, "Зелена,12"); Assert.AreEqual(order.RoadTime, Convert.ToUInt32(123)); }
public bool Add(TaxiDriver taxiDriver) { try { db.TaxiDrivers.Add(taxiDriver); db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
private void startWork_Click(object sender, RoutedEventArgs e) { currentDriver = driversInfo.FindDriver(driverSurName.Text, driverUserName.Text); driverInfoSurnameNameDetails.Content = currentDriver.Surname + " " + currentDriver.Name; driverInfoAgeDetails.Content = currentDriver.Age; driverInfoCarDetails.Content = currentDriver.CarNumber; driverInfoExpDetails.Content = currentDriver.Experience; driverInfoCostDetails.Content = currentDriver.PayCheck + " грн"; driverInfoCostPerMinDetails.Content = currentDriver.CostPerMinute; ordersInfo = new OrdersDB("../../InputData/OrdersData.txt", clientsInfo, driversInfo); ordersInfo.ReadFromFile(); ShowOrdersInListView(); }
public TaxiDriver GetDriverById(uint driverId) { TaxiDriver searchResult = new TaxiDriver(); foreach (TaxiDriver driver in allDrivers) { if (driver.Id == driverId) { searchResult = driver; break; } } return(searchResult); }
public Taxi makeTaxi(Builder builder) { Driver driver = new TaxiDriver(); int capacity = 4; Passenger passenger = new TaxiPassenger(); List <Passenger> passengers = new List <Passenger>(capacity); passengers.Add(passenger); builder.setDriver(driver); builder.setPassengersCapacity(capacity); builder.setPassengers(passengers); return((Taxi)builder.getResult()); }
public TaxiDriver FindDriver(string surname, string name) { TaxiDriver searchResult = new TaxiDriver(); foreach (TaxiDriver driver in allDrivers) { if (driver.Surname == surname && driver.Name == name) { searchResult = driver; break; } } return(searchResult); }
private void AddDriversInfo() { using (var cont = new DriverContext()) { var anatolii = new TaxiDriver("Mykytyn", "Anatolii", 27, "BC1567AC", 5, 50, 29); var volodymyr = new TaxiDriver("Berkela", "Volodymyr", 19, "BC7898BM", 3, 75, 0); var lukyana = new TaxiDriver("Kiral", "Lukyana", 20, "BC8765", 3, 23, 0); var bogdan = new TaxiDriver("Shomko", "Bogdan", 12, "BC3456AM1", 3, 23, 50); cont.Drivers.Add(anatolii); cont.Drivers.Add(volodymyr); cont.Drivers.Add(lukyana); cont.Drivers.Add(bogdan); cont.SaveChanges(); } }
private TaxiDriver readTaxiDriver(string data) { TaxiDriver taxiDriver = new TaxiDriver(); foreach (string field in data.Split(',')) { string[] keyValue = field.Split(':'); string fieldName = Regex.Replace(keyValue[0], "\"|\\s", ""); string fieldValue = Regex.Replace(keyValue[1], "\"", ""); if (fieldName == "firstName") { taxiDriver.firstName = fieldValue; } if (fieldName == "lastName") { taxiDriver.lastName = fieldValue; } } return(taxiDriver); }
private void addDriver(Data data) { Console.Clear(); TaxiDriver taxiDriver = new TaxiDriver(); Console.Write("Введіть ім'я водія: "); taxiDriver.firstName = Console.ReadLine(); Console.Write("Введіть прізвище водія: "); taxiDriver.lastName = Console.ReadLine(); try { taxiDriver.validate(); data.addTaxiDriver(taxiDriver); } catch (Exception e) { Console.WriteLine(e.Message); Console.Write("Press Eneter key to continue.. "); Console.ReadLine(); } }
public void addTaxiDriver(TaxiDriver taxiDriver) { taxiDrivers[taxiDriverCount] = taxiDriver; taxiDriverCount++; }
static void parser(string object_info) { Regex r_type = new Regex(@"^\r?\n?\w*"); Match m_type = r_type.Match(object_info); Regex r_first_name = new Regex(@"(.first_name.:) +.(\w*)."); Match m_first_name = r_first_name.Match(object_info); Regex r_last_name = new Regex(@"(.last_name.:) +.(\w*)."); Match m_last_name = r_last_name.Match(object_info); Regex r_sex = new Regex(@"(.sex.:) +.(\w{1})."); Match m_sex = r_sex.Match(object_info); Regex r_residence_hostel = new Regex(@"(.residence.:) +.(\d{1}\.\d{1,3})."); Match m_residence_hostel = r_residence_hostel.Match(object_info); Regex r_residence_not_hostel = new Regex(@"(.residence.:) +.(\d{1,3} \w*, #\d{1,3})."); Match m_residence_not_hostel = r_residence_not_hostel.Match(object_info); if (m_type.Value == "Teacher" || m_type.Value == "\r\nTeacher") { Regex r_subject = new Regex(@"(.subject.:) +.(\w*)."); Match m_subject = r_subject.Match(object_info); teachers_amount++; Array.Resize(ref teachers, teachers_amount); Teacher teacher = new Teacher(); teacher.first_name = m_first_name.Groups[2].Value; teacher.last_name = m_last_name.Groups[2].Value; teacher.sex = (Sex)Enum.Parse(typeof(Sex), m_sex.Groups[2].Value); teacher.subject = m_subject.Groups[2].Value; if (m_residence_hostel.Value != "") { teacher.hostel = true; teacher.residence = m_residence_hostel.Groups[2].Value; } else if (m_residence_not_hostel.Value != "") { teacher.hostel = false; teacher.residence = m_residence_not_hostel.Groups[2].Value; } teachers[teachers_amount - 1] = teacher; } else if (m_type.Value == "Student" || m_type.Value == "\r\nStudent") { Regex r_course = new Regex(@"(.course.:) +.(\d{1})."); Match m_course = r_course.Match(object_info); Regex r_student_id = new Regex(@"(.student_id.:) +.(\w{2}\d{6})."); Match m_student_id = r_student_id.Match(object_info); students_amount++; Array.Resize(ref students, students_amount); Student student = new Student(); student.first_name = m_first_name.Groups[2].Value; student.last_name = m_last_name.Groups[2].Value; student.sex = (Sex)Enum.Parse(typeof(Sex), m_sex.Groups[2].Value); student.course = int.Parse(m_course.Groups[2].Value); student.student_id = m_student_id.Groups[2].Value; if (m_residence_hostel.Value != "") { student.hostel = true; student.residence = m_residence_hostel.Groups[2].Value; } else if (m_residence_not_hostel.Value != "") { student.hostel = false; student.residence = m_residence_not_hostel.Groups[2].Value; } //search if (student.sex == Sex.F && student.course == 1 && student.hostel) { result_amount++; Array.Resize(ref result, result_amount); result[result_amount - 1] = student; } students[students_amount - 1] = student; } else if (m_type.Value == "TaxiDriver" || m_type.Value == "\r\nTaxiDriver") { Regex r_registration_plate = new Regex(@"(.registration_plate.:) +.(\w{2}\d{4}\w{2})."); Match m_registration_plate = r_registration_plate.Match(object_info); taxiDrivers_amount++; Array.Resize(ref taxiDrivers, taxiDrivers_amount); TaxiDriver taxiDriver = new TaxiDriver(); taxiDriver.first_name = m_first_name.Groups[2].Value; taxiDriver.last_name = m_last_name.Groups[2].Value; taxiDriver.sex = (Sex)Enum.Parse(typeof(Sex), m_sex.Groups[2].Value); taxiDriver.registration_plate = m_registration_plate.Groups[2].Value; if (m_residence_hostel.Value != "") { taxiDriver.hostel = true; taxiDriver.residence = m_residence_hostel.Groups[2].Value; } else if (m_residence_not_hostel.Value != "") { taxiDriver.hostel = false; taxiDriver.residence = m_residence_not_hostel.Groups[2].Value; } taxiDrivers[taxiDrivers_amount - 1] = taxiDriver; } }
private void Registration_Click(object sender, RoutedEventArgs e) { try { if (FirstName.Text == "" && SecondName.Text == "" && LastName.Text == "" && Gender.Text == "" && Phone.Text == "" && Email.Text == "" && Password.Text == "") { MessageBox.Show("Вы не заполнили одно из полей", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning); } bool TrueEmail = false; for (int i = 0; i < Email.Text.Length; i++) { if (Email.Text[i] == '@') { TrueEmail = true; } } if (TrueEmail == false) { MessageBox.Show("Вы ввели некорректный Email", "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Warning); return; } int Symbol1 = 0; int Symbol2 = 0; int Symbol3 = 0; int Symbol4 = 0; int Number = 0; for (int i = 0; i < Password.Text.Length; i++) { if (Password.Text[i] == '!') { Symbol1++; } if (Password.Text[i] == '@') { Symbol2++; } if (Password.Text[i] == '?') { Symbol3++; } if (Password.Text[i] == '%') { Symbol4++; } if (Password.Text[i] >= 0 && Password.Text[i] <= 9) { Number++; } } if (Symbol1 < 1 && Symbol2 < 1 && Symbol3 < 1 && Symbol4 < 1 && Number < 1 && Password.Text.Length < 8) { MessageBox.Show("Вы ввели не корректный пароль", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning); return; } //конвертация изображения для бд byte[] imageData = null; //начало конвертации FileInfo fInfo = new FileInfo(iFile); long numBytes = fInfo.Length; FileStream fStream = new FileStream(iFile, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fStream); imageData = br.ReadBytes((int)numBytes); if (ClientChek.IsChecked == true) { Client NewClient = new Client { PhoneNumber = Phone.Text, FirstName = FirstName.Text, LastName = SecondName.Text, Photo = imageData, MiddleName = LastName.Text, Gender = Gender.Text, Email = Email.Text, Password = Password.Text }; entities.Clients.Add(NewClient); entities.SaveChanges(); } if (WorkerCheck.IsChecked == true) { TaxiDriver NewDriver = new TaxiDriver { PhoneNumber = Phone.Text, FirstName = FirstName.Text, LastName = SecondName.Text, Photo = imageData, MiddleName = LastName.Text, Gender = Gender.Text, Email = Email.Text, Password = Password.Text }; entities.TaxiDrivers.Add(NewDriver); entities.SaveChanges(); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private Card RandomCard(Vector2 position, bool front, int playerID) { Card c = null; if (Globals.r.Next(4) == 0) { int cardsCount = 31; int rn = Globals.r.Next(cardsCount); switch (rn) { case 0: c = new Actor(position, front, playerID); break; case 1: c = new Artist(position, front, playerID); break; case 2: c = new Astrophysicist(position, front, playerID); break; case 3: c = new Babysitter(position, front, playerID); break; case 4: c = new BabysitterU(position, front, playerID); break; case 5: c = new BusDriver(position, front, playerID); break; case 6: c = new Conman(position, front, playerID); break; case 7: c = new DeliveryPerson(position, front, playerID); break; case 8: c = new DrugDealer(position, front, playerID); break; case 9: c = new FastFoodEmployee(position, front, playerID); break; case 10: c = new Hacker(position, front, playerID); break; case 11: c = new Hitman(position, front, playerID); break; case 12: c = new HumanTrafficker(position, front, playerID); break; case 13: c = new IndieGameDev(position, front, playerID); break; case 14: c = new Influencer(position, front, playerID); break; case 15: c = new InstaModel(position, front, playerID); break; case 16: c = new InternDev(position, front, playerID); break; case 17: c = new JuniorDev(position, front, playerID); break; case 18: c = new Musician(position, front, playerID); break; case 19: c = new OnlyFans(position, front, playerID); break; case 20: c = new Referee(position, front, playerID); break; case 21: c = new RiceFarmer(position, front, playerID); break; case 22: c = new Santa(position, front, playerID); break; case 23: c = new Shelfstacker(position, front, playerID); break; case 24: c = new Shoplifter(position, front, playerID); break; case 25: c = new Sporter(position, front, playerID); break; case 27: c = new Streamer(position, front, playerID); break; case 28: c = new SugarDaddy(position, front, playerID); break; case 29: c = new TaxiDriver(position, front, playerID); break; case 30: c = new Writer(position, front, playerID); break; case 26: c = new YogaInstructor(position, front, playerID); break; } } else { int cardsCount = 12; int rn = Globals.r.Next(cardsCount); switch (rn) { case 0: c = new Alcohol(position, front, playerID); break; case 1: c = new Drugs(position, front, playerID); break; case 2: c = new EatingOut(position, front, playerID); break; case 3: c = new FastFood(position, front, playerID); break; case 4: c = new Gambling(position, front, playerID); break; case 5: c = new Gaming(position, front, playerID); break; case 6: c = new Joint(position, front, playerID); break; case 7: c = new PomXML(position, front, playerID); break; case 8: c = new Shopping(position, front, playerID); break; case 9: c = new Smoking(position, front, playerID); break; case 10: c = new SocialMedia(position, front, playerID); break; case 11: c = new Streaming(position, front, playerID); break; } } return(c); }
/// <summary> /// Driver instance /// </summary> /// <param name="name">name</param> /// <returns>instance</returns> public override Driver DriverInstance(string name = "") { return(Driver ?? (Driver = new TaxiDriver(name))); }
public List <IPerson> Read() { var data = new string[0]; try { data = File.ReadAllLines("data.txt"); } catch (FileNotFoundException e) { return(new List <IPerson>()); } var list = new List <IPerson>(data.Length / 2); for (int i = 0; i < data.Length - 1; i++) { var description = data[i]; var json = data[i + 1]; var type = new string(description.TakeWhile(x => x != ' ').ToArray()); var personModel = JsonConvert.DeserializeObject <PersonModel>(json); var firstName = new Name(personModel.firstName); var lastName = new Name(personModel.lastName); switch (type) { case "Student": { var student = new Student(firstName, lastName, new StudentTicket(personModel.studentId)); list.Add(student); break; } case "Teacher": { var teacher = new Teacher(firstName, lastName); list.Add(teacher); break; } case "TaxiDriver": { var taxiDriver = new TaxiDriver(firstName, lastName, new DriverLicense(personModel.driverLicenseCode)); list.Add(taxiDriver); break; } case "Pupil": { var pupil = new Pupil(firstName, lastName); list.Add(pupil); break; } case "Musician": { var musician = new Musician(firstName, lastName); list.Add(musician); break; } default: throw new ArgumentException("Unknown person type"); } } return(list); }
/// <summary> /// Driver instance /// </summary> /// <param name="driver">driver</param> /// <returns>instance</returns> public override Driver DriverInstance(Driver driver) { return(Driver ?? (Driver = new TaxiDriver(driver))); }