[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

Need help on coding a formula

I'm creating a console application consisting of a abstract class, a AutoSalesperson class and a interface called ISelling. I have one method in the interface called MakeSales which will accept an integer dollar value for the car that's added to the value of the AutoSalesperson's total value sold,which will compute thetotal commission earned. I'm having a hard time figureing out the formula for the MakeSales()method. This is what I have so far:

public class AutoSalesperson : ISelling
{
    private double totalValueNum = 0;
    private double commissionEarnedNum = 0;
    private double commissionRateNum;

    public AutoSalesperson(double commissionRateNum)
    {
        this.commissionRateNum = commissionRateNum;
    }
    public int MakeSales()
    {

     }
}
0
augie0216
Asked:
augie0216
1 Solution
 
Ready1Commented:
public class AutoSalesperson : ISelling
{
    private double totalValueNum = 0;
    private double commissionEarnedNum = 0;
    private double commissionRateNum;

    public AutoSalesperson(double commissionRateNum)
    {
        this.commissionRateNum = commissionRateNum;
    }
    public void MakeSales(double sale)
    {
        // increment the total sale for this salesman
        totalValueNum += sale;

        // calculate the sales persons commisions earned
        commissionEarnedNum = totalValueNum * commissionRateNum; // not sure if your commision rate is a percent?? you should know how to calculate this
     }

     // this is a read only accesor to retrieve the sales  persons total sales
     public double TotalSales
     {
          get{return totalValueNum;}
     }

     // this is a read only accesor to retrieve the sales  persons total commisions
     public double TotalCommision
     {
          get{return commissionEarnedNum ;}
     }
}

Regards,
Ready1
0
 
devsolnsCommented:
What is your thought process behind the ISelling interface?

Is that interface going to be used by other objects?  Who else can make a sale?  Also it sounds like there is only one possible "implementation" for MakeSales so why an interface which would allow multiple, different and potentially wrong implementations of that interface.

-gp
0
 
augie0216Author Commented:
I'm following the instructions from a book this project consists of a abstract class,2 child classes,and an interface. The book I'm usng is kind of lame at explaining things so I ask for hints to help me understand. Sometimes I don't explain everything I trying to understand piece by piece.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now