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)
Nestory 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.