Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
 public CarRecord(CarBrand brand, Person person, CarNumber number)
 {
     Brand  = brand;
     Person = person;
     Number = number;
 }
Ejemplo n.º 6
0
 public int CompareTo(CarNumber other)
 {
     return(this.ToString().CompareTo(other.ToString()));
 }