private void button1_Click(object sender, EventArgs e)
        {
            SalesTransaction s1 = new SalesTransaction(0.06);
            listBox1.Items.Add(s1.ToString());
            SalesTransaction s2 = new SalesTransaction("John Doe: ", 170000, 0.07); // 11900
           // s2.SalesAmount = 210000;
           //The commission should be automatically adjusted. 14700
            listBox1.Items.Add(s2.ToString());
            SalesTransaction s3 = new SalesTransaction("Jane Doe: ", 200000); // 0
            listBox1.Items.Add(s3.ToString());
            SalesTransaction s4 = new SalesTransaction("Tim Doe: "); // 0
            listBox1.Items.Add(s4.ToString());
            SalesTransaction s5 = s2 + s2;
            listBox1.Items.Add(s5.ToString());
        }
    }

    class SalesTransaction
    {
        private readonly double commissionRate; // page 386
        private decimal commission; // this is a calculated field
        public string Salesperson { get; set; } // auto-implemented property
        public decimal SalesAmount { get; set; }

        public double CommissionRate
        {
            get
            {
                return commissionRate;
            }
        }
        public decimal Commission
        {
            get
            {
                double salesNumber = Convert.ToDouble(SalesAmount);
                return commission = Convert.ToDecimal(salesNumber * commissionRate);
            }
        }
        public SalesTransaction(double rate)
        {
            commissionRate = rate;
        }
        public SalesTransaction(string disName, double Commie1, double rate)
        {
            commissionRate = rate;
            Salesperson = disName;
            SalesAmount = (decimal)Commie1;
        }
        (I have tried to finish this but im stuck here help me please)

When you are providing extra information for an existing question, it is better to reply to your original question, rather than creating a new question.

In general, a constructor should set all applicable data members, even if not provided in the constructor arguments. Before using a list box to display something, it might be a good idea to clear the list box of any previous strings.
listbox1.clear();

Edited 7 Months Ago by Nutster: Add comment about clearing the listbox.

This article has been dead for over six months. Start a new discussion instead.