7a. Create an abstract class named Salesperson. Fiels include first and last nams; the Salesperson constructor requires both these values. Include a get method that returns a string that holds the Salesperson's full name, which consists of the first and last name separated by a space. Save the file as Salesperson.cs

b.Create two child classes, RealEstateSalesperson and GirlScout. The RealEstateSalesPerson class contains a total value sold in dollars field and a total commission earned field (both of which are initialized to 0), and a commission rate field required by the class constructor. The GirlScout class includes a field to hold the number of boxes of cookies sold, which is initialized to 0. Include set methods for every field. Save the file as SalespersonSubclasses.

c.Create an interface named ISelling that contains two methods: SakesSpeech() and MakeSale(). In each class, implement SalesSpeech() to displat an appropriate one- or two-sentance sales speech that the object of the class could use. In the RealEstateSalesPerson class, implement the MakeSale() method to accept an integer dollar value for a house, add the value to the RealEstateSalesPeron's total value sold, and compute to the total commission earned. In the GirlScout class, implement the MakeSale() method to accept an integer representing number of boxes of cookies sold and add it to the total field. Save the file as ISelling.cs

d.Write a program that instantiates a RealEstateSalesPerson object and a GirlScout object. Demonstrate the SalesSpeech() method with each object, the use the MakeSales() method two or three times with each object. Display the final contents of each object's data fields. Save the file as SalespersonDemo.cs

I know its alot and i cant get any help from my instructor so your help would be greatly appreciated.

What do you have so far?

right now it on a diffrent computer. ill probably post it in about 10-11hrs.

What do you have so far?

right now it on a diffrent computer. ill probably post it in about 10-11hrs.

My Class

namespace SalesPersonDemo
{

    public interface ISell
   {
       string SalesSpeach();
       double MakeSale();

   }
    abstract class Salesperson
   {
       private string firstName;
       private string lastName;

       public Salesperson(string first, string last)
       {
           FirstName = first;
           LastName = last;
       }
       public string FirstName
       {
           get { return firstName; }
           set { firstName = value; }
       }

       public string LastName
       {
           get { return lastName; }
           set { lastName = value; }
       }

       public abstract string FullName();
   }
  class RealEstateSalesperson : Salesperson
  {
      private double houseVal;
      private double totalValDollars = 0;
      private double totalCommission = 0;
      public RealEstateSalesperson(double commissionRate)
      {
          CommissionRate = commissionRate;
      }

      public int TotalVal
      {
          get { return totalValDollars; }
          set { totalValDollars = value; }
      }
      public int TotalCommission
      {
          get { return totalCommission; }
          set { totalCommission = value; }
      }
      public int CommissionRate
      {
          get { return commissionRate; }
          set { commissionRate = value; }
      }
     
      public override string SalesSpeach()
      {
          return  "We must remind ourselves that value, not just price has to be a driving force behind our success. ";
      }
      public override double MakeSale()
      {
          double total;
          total = CommissionRate * TotalVal +TotalVal;
          return total;
      }
      public override double FullName()
      {
          return FirstName + " " + LastName;
      }
  }
  class GirlScout : Salesperson
  {
      private int numOfboxes = 0;

      public int NumOfBoxes
      {
          get { return numOfboxes; }
          set { numOfboxes = value; }
      }
      public override string SalesSpeach()
      {
          return "Selling Girl Scout Cookies is an important component of the Girl Scout Leadership Experience for girls.";
      }
      public override double FullName()
      {
          return FirstName + " " + LastName;
      }
  }
  
}

A few things to look at:

1) Since RealEstateSalesPerson and GirlScout are subclasses of SalesPerson, and SalesPerson takes two strings as parameters on the constructor, you may want a way to pass these two strings when you construct a RealEstateSalesPerson instance. Sure, you could leave it like you have it, but then you will have to do this:

RealEstateSalesPerson oRS = new RealEstateSalesPerson(7.0);
    oRS.FirstName = "Bob";
    oRS.LastName = "Smith";

Wouldn't it be nicer if you could just do:

RealEstateSalesPerson oRS = new RealEstateSalesPerson("Bob", "Smith", 7.0);

You can, if you do your constructor like this:

public RealEstateSalesPerson(string fName, string lName, double commissionRate) : base(fName, lName)

That way, the base class (SalesPerson) gets set up with the first name and last name, and the derived class gets the commission rate.

2) The "fullName" method in the SalesPerson class should be implemented there, not set up as "abstract". The derived classes will be able to call it. Remove the implementations of "fullName" from RealEstateSalesPerson and GirlScout. They wouldn't have worked anyway, because for some reason, they were set up with a return type of "double", but the method was actually returning a string.

3) You've defined the ISell interface, but you don't make your classes implement it. It needs to be specified on the "class" lines for the RealEstateSalesPerson and GirlScout classes. This can be seen in action in your current code, since the MakeSale method is not implemented in the GirlScout class. If the interface were specified on the class declaration properly, you'd get a build error stating that the method was not implemented.

4) The MakeSale method in the RealEstateSalesPerson class - what happens after you leave the method? Is the value being saved anywhere? It probably should be. Also, shouldn't MakeSale accept some sort of value (read the professor's note about the method) - also note that you will have to change the interface spec for this method as well.

Especially for the MakeSale method - make sure you read and understand what the professor wants you to do in each class. You appear to have the proper class variables defined - now use them as directed in the spec.

That should get you going. Good luck!

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.