Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SOLVE ONLY QUESTION (2) Using C# VISUAL STUDIO Question 1. Consider the following code for an abstract SalesPerson class that implements an interface called ISellable

SOLVE ONLY QUESTION (2) Using C# VISUAL STUDIO

Question 1. Consider the following code for an abstract SalesPerson class that implements an interface called ISellable and answer the questions that follow accordingly:

image text in transcribed

1.1 Create a child class of SalesPerson and call it RealEstateSalesPerson. It has three auto-implemented properties TotalValueSold, TotalCommissionEarned and CommissionRate. It also has a constructor that require passing the commission rate.

1.2 In RealEstateSalesPerson class, implement the inherited abstract methods SaleSpeech() and MakeSale(). SaleSpeech() displays a small message to start the sale while MakeSale() accepts an integer value for a house, add the value to the RealEstateSalesPersons total value sold, and compute the total commission earned. Hint: SaleSpeech() may display Hi, want to buy a house? Have a few minutes to chat?.

1.3 Assume another child class is create and called GirlScout as illustrated in the following figure.

image text in transcribed

Provide another implementation for SaleSpeech() and MakeSale(). SaleSpeech() displays another appropriate message while MakeSale() accepts an integer number of cookie boxes sold and subtracts it from NumberOfCookieBoxes. Hint: SaleSpeech() may display Hello, would you like to buy some cookies? Its for a good cause!

Question 2. Following up to question 1, assume a complete implementation for the SalesPerson class, along with its child classes.

2.1 Create a GUI application that contains a Label that tells the user to select a sales person type, and a ComboBox, from which the user can choose either Real Estate Agent or Girl Scout. When the user makes a selection, the corresponding SaleSpeech() method should be executed. Add another Label to display the output when the user makes a selection. Write the corresponding code and provide a screenshot of your GUI. Hint: SelectedIndex property for the combobox can be used returns the index of the selected item, value starts from 0.

abstract class Salesperson : Isellable { public string FirstName { get; set; } public string LastName { get; set; } public SalesPerson(string firstName, string lastName) { FirstName = firstName; LastName lastName; } public string GetSalespersonName(Salesperson salesPerson) { string name = FirstName + + LastName; return name; } public abstract string SaleSpeech(); public abstract double MakeSale(int SalesAmount); } public interface Isellable { string Salespeech(); double MakeSale(int SalesAmount); } class Girlscout : Salesperson { public int NumberOfCookieBoxes { get; set; } public Girlscout(string firstName, string LastName, int numofCookieBoxes) : base(firstName, LastName) { NumberOfCookieBoxes = numofCookieBoxes; } abstract class Salesperson : Isellable { public string FirstName { get; set; } public string LastName { get; set; } public SalesPerson(string firstName, string lastName) { FirstName = firstName; LastName lastName; } public string GetSalespersonName(Salesperson salesPerson) { string name = FirstName + + LastName; return name; } public abstract string SaleSpeech(); public abstract double MakeSale(int SalesAmount); } public interface Isellable { string Salespeech(); double MakeSale(int SalesAmount); } class Girlscout : Salesperson { public int NumberOfCookieBoxes { get; set; } public Girlscout(string firstName, string LastName, int numofCookieBoxes) : base(firstName, LastName) { NumberOfCookieBoxes = numofCookieBoxes; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions