public CarRecord Find(CarNumber number) { CarRecord temp = new CarRecord(CarBrand.Acura, new Person("a", "a", "a"), number); int key = GetKey(temp); int index = IndexOf(key); return(index == -1 ? null : Table[index].record); }
private void btnShow_Click(object sender, EventArgs e) { if (!checkMtb()) { MessageBox.Show("Fill the gaps", "Status", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } resultNumber = new CarNumber(mtbCarNumber.Text); this.DialogResult = DialogResult.OK; this.Close(); }
private void btnDone_Click(object sender, EventArgs e) { if (!checkMtb() || (tbName.Text.Trim() == "") || (tbSurname.Text.Trim() == "") || (tbPatronymic.Text.Trim() == "")) { MessageBox.Show("Fill the gaps", "Status", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int selectedBrand = cbCarBrand.SelectedIndex + 1; CarBrand brand = CarBrandClass.CarBrandDict[selectedBrand]; Person person = new Person(tbName.Text.Trim(), tbSurname.Text.Trim(), tbPatronymic.Text.Trim()); CarNumber number = new CarNumber(mtbCarNumber.Text); this.record = new CarRecord(brand, person, number); this.DialogResult = DialogResult.OK; this.Close(); }
private static CarRecord RecordFromString(string str) { int space = str.IndexOf(' '); int semicolon = str.IndexOf(';'); string sBrand = str.Substring(0, space); CarBrand Brand = (CarBrand)Enum.Parse(typeof(CarBrand), sBrand); string sNumber = str.Substring(space + 1, semicolon - space); CarNumber Number = new CarNumber(sNumber); string sPerson = str.Substring(str.IndexOf(':') + 2); int firstSpace = sPerson.IndexOf(' '); int lastSpace = sPerson.LastIndexOf(' '); Person person = new Person(sPerson.Substring(0, firstSpace), sPerson.Substring(firstSpace + 1, lastSpace - firstSpace - 1), sPerson.Substring(lastSpace + 1, sPerson.Length - lastSpace - 2)); return(new CarRecord(Brand, person, Number)); }
public CarRecord(CarBrand brand, Person person, CarNumber number) { Brand = brand; Person = person; Number = number; }
public int CompareTo(CarNumber other) { return(this.ToString().CompareTo(other.ToString())); }