Beispiel #1
0
        public override bool Equals(System.Object obj)
        {
            Lumber lumb = obj as Lumber;

            if ((object)lumb == null)
            {
                return(false);
            }
            return(base.Equals(obj) && (TypeOfWood == lumb.TypeOfWood && Price == lumb.Price));
        }
Beispiel #2
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            Lumber otherTemperature = obj as Lumber;

            if (otherTemperature != null)
            {
                return(this.PriceAmountOfWood().CompareTo(otherTemperature.PriceAmountOfWood()));
            }
            else
            {
                throw new ArgumentException("Ошибка типа");
            }
        }
        private void buttonAddWood_Click(object sender, EventArgs e)
        {
            try
            {
                int mark             = rand.Next(10000000, 100000000);
                int amountOfWood     = Convert.ToInt32(textBoxAmountOfWood.Text);
                int price            = Convert.ToInt32(comboBoxWood.Text.Substring(37, 2));
                int selectedWorkshop = listBoxWorkshop.SelectedIndex;

                if (selectedWorkshop == -1) // если не выбрана мастерская - выбрасываем исключение
                {
                    throw new MyExceptions(MyExceptionError);
                }

                int      day   = Convert.ToInt32(dateTimePicker1.Text.Substring(0, 2));
                int      month = Convert.ToInt32(dateTimePicker1.Text.Substring(3, 2));
                int      year  = Convert.ToInt32(dateTimePicker1.Text.Substring(6, 4));
                DateTime date1 = new DateTime(year, month, day, 12, 0, 0);

                SawingOptions so = SawingOptions.пусто;

                switch (comboBoxSavingOptions.SelectedIndex)
                {
                case 0: so = SawingOptions.брус; break;

                case 1: so = SawingOptions.доска_необрезанная; break;

                case 2: so = SawingOptions.доска_обрезанная; break;

                case 3: so = SawingOptions.рейка; break;
                }

                Lumber lm = new Lumber(comboBoxWood.Text.Substring(3, 10), comboBoxWood.Text.Substring(17, 4), comboBoxWood.Text.Substring(25, 8), amountOfWood, date1, so, mark, price);

                wShop[selectedWorkshop].AddLumber(lm);
                EnterLumber();
            }
            catch (MyExceptions ex)
            {
                show(ex.Message);
            }
        } // создание объекта "пилометириал"
 public void AddLumber(Lumber newLumber) // добавление объекта Lumber
 {
     lumberWorkshop.Add(newLumber);
 }
Beispiel #5
0
        public static Lumber operator +(Lumber obj1, Lumber obj2)
        {
            Lumber obj3 = new Lumber(obj1.TypeOfWood, obj1.Humidity, obj1.Density, obj1.GetAmountOfWood(), obj1.datetime, obj1.sawingOption, obj1.Marking, obj1.Price + obj2.Price);

            return(obj3);
        }
Beispiel #6
0
 public bool Equals(Lumber l)
 {
     return(base.Equals((Lumber)l) && (TypeOfWood == l.TypeOfWood && Price == l.Price));
 }