Beispiel #1
0
        public object Clone()
        {
            Shirt s = (Shirt)this.MemberwiseClone();

            int[] newPrices = (int[])prices.Clone();
            s.prices = newPrices;
            return(s);
        }
Beispiel #2
0
        public int CompareTo(object obj)
        {
            Shirt s = (Shirt)obj;

            if ((float)this < (float)s)
            {
                return(-1);
            }
            else
            if ((float)this > (float)s)
            {
                return(1);
            }
            else
            {
                return(string.Compare(this.name, s.name));
            }
        }
Beispiel #3
0
        private void buttonConfirm_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {
                try
                {
                    int      code     = Convert.ToInt32(tbCode.Text);
                    char     size     = Convert.ToChar(cbSize.Text);
                    int      quantity = Convert.ToInt32(tbQuantity.Text);
                    string   name     = tbName.Text;
                    string[] priceS   = tbPrices.Text.Split(',');
                    int[]    prices   = new int[priceS.Length];
                    sumPrice = 0;

                    for (int i = 0; i < priceS.Length && i < quantity; i++)
                    {
                        prices[i] = Convert.ToInt32(priceS[i]);
                        sumPrice += prices[i];
                    }


                    //radio button for hoody or t-shirt
                    Hoody h = new Hoody(code, size, quantity, name, prices);
                    listHoody.Add(h);
                    MessageBox.Show(h.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    textBox1.Text = sumPrice.ToString();
                    textBox2.Text = (sumPrice * 0.1).ToString();
                    textBox3.Text = (sumPrice + (sumPrice * 0.1)).ToString();
                    listCommands.Add(sumPrice + (sumPrice * 0.1));
                    confirm_pressed = true;
                    tbCode.Clear();
                    cbSize.Text = "";
                    tbQuantity.Clear();
                    tbName.Clear();
                    tbPrices.Clear();
                }
            }
            else if (radioButton2.Checked == true)
            {
                try
                {
                    int    code     = Convert.ToInt32(tbCode.Text);
                    char   size     = Convert.ToChar(cbSize.Text);
                    int    quantity = Convert.ToInt32(tbQuantity.Text);
                    string name     = tbName.Text;
                    priceS   = tbPrices.Text.Split(',');
                    prices   = new int[priceS.Length];
                    sumPrice = 0;
                    for (int i = 0; i < priceS.Length && i < quantity; i++)
                    {
                        prices[i] = Convert.ToInt32(priceS[i]);
                        sumPrice += prices[i];
                    }

                    //radio button for hoody or t-shirt
                    Shirt s = new Shirt(code, size, quantity, name, prices);
                    listShirt.Add(s);
                    MessageBox.Show(s.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    textBox1.Text = sumPrice.ToString();
                    textBox2.Text = (sumPrice * 0.05).ToString();
                    textBox3.Text = (sumPrice + (sumPrice * 0.05)).ToString();
                    listCommands.Add(sumPrice + (sumPrice * 0.05));
                    confirm_pressed = true;
                    tbCode.Clear();
                    cbSize.Text = "";
                    tbQuantity.Clear();
                    tbName.Clear();
                    tbPrices.Clear();
                }
            }
            else
            {
                MessageBox.Show("Shorry you did not select the product type");
            }
        }