This problem set covers Chapter 7.
Item Sales (1 Point)
This is the same class you developed for Problem Set 7.
Include this class in the com.sales package
Sales Person (10 points)
Design and develop a class that represents a sales person. This class should have the following attributes:
-
DEFAULT_ITEM_COUNT - A private constant integer set to 50
-
NO_NAME - A private constant String set to "No Name"
-
name - A private String containing the name of the sales person
-
itemSales - a private array of ItemSales objects.
-
itemCount - a private int indicating the number of ItemSales objects in the itemSales array
initialized to zero.
-
currentItem - a private int indicating the index of the current item.
Your class should have the following public methods and constructors:
-
SalesPerson() - Initializes the name to NO_NAME and initializes the itemSales array to
DEFAULT_ITEM_COUNT size.
-
SalesPerson(String newName) - Initializes the name to newName and initializes the itemSales
array to DEFAULT_ITEM_COUNT size.
-
SalesPerson(String newName, int maxItemCount) - Initializes the name to newName and initializes
the itemSales array to maxItemCount size.
-
addItem(ItemSales item) - This method adds the given item to the itemSales array and updates the
itemCount. This method needs to expand the array if the array is not big enough.
-
addItems(ItemSales[] items) - This method adds the ItemSales items contained in the items
array to the itemSales array and updates the itemCount. This method needs to expand the
array if the array is not big enough.
-
isFull() - Returns true if the itemSales sales array is full, false otherwise.
-
isEmpty() - Returns true if the itemSales sales array is empty, false otherwise.
-
getFirstItem() - This method returns the first ItemSales item from the itemSales array
and initizes the currentItem counter. If the array is empty, this method returns a null.
-
getNextItem() - This method returns the next ItemSales item from the itemSales array
and updates the currentItem counter. If the there are no more ItemSales items in the array,
this method returns a null.
-
getAllItems() - This method returns a copy of the itemSales array.
-
getTotalSales() - This method returns the total sales for this sales person.
-
getTotalDiscounts() - This method returns the total discounts that this sales person provided to their
customers.
-
getName() & setName(String newName) methods for the name attribute.
Name this class SalesPerson and include it in the com.sales package
Sales Force (10 points)
Design and develop a class that represents a sales force. This class should have the following attributes:
-
DEFAULT_SALES_FORCE_SIZE - A private constant integer set to 10
-
salesPeople - a private array of SalesPerson objects.
-
salesPeopleCount - a private int indicating the number of SalesPerson objects in the
salesPeople array initialized to zero.
-
currentSalesPerson - a private int indicating the index of the current sales person.
Your class should have the following public methods and constructors:
-
SalesForce() - Initializes the salesForce array to DEFAULT_SALES_FORCE_SIZE size.
-
SalesForce(int maxSalesPeople) - Initializes the salesPeople array to maxSalesPeople size.
-
addSalesPerson(SalesPerson person) - This method adds the given person to the salesPeople array
and updates the salesPeopleCount. This method needs to expand the array if the array is not big
enough.
-
addSalesPeople(SalesPerson[] people) - This method adds the SalesPerson people contained in the
people array to the salesPeople array and updates the salesPeopleCount. This method
needs to expand the array if the array is not big enough.
-
isFull() - Returns true if the salesPeople sales array is full, false otherwise.
-
isEmpty() - Returns true if the salesPeople sales array is empty, false otherwise.
-
getFirstSalesPerson() - This method returns the first SalesPerson from the salesPeople
array and initizes the currentSalesPerson counter. If the array is empty, this method returns a
null.
-
getNextSalesPerson() - This method returns the next SalesPerson from the salesPeople array
and updates the currentSalesPerson counter. If the there are no more SalesPerson items in
the array, this method returns a null. This method should also return null if the
getFirstSalesPerson() method has not been called.
-
getAllSalesPeople() - This method returns a copy of the salesPeople array.
-
getAverageSales() - Calculate and return the average sales figure for all sales people.
-
getAverageDiscounts() - Calculate and return the average sales figure for all sales people.
-
getTotalSales() - Calculate and return the total sales figure for all sales people.
-
displayAllSales() - This method will display the name of each SalesPerson in the sales force,
followed by their total sales, total discounts, and whether they are above/below or average in their total
sales.
Name this class SalesForce and include it in the com.sales package.
Sales Force Demo (10 points)
This class will be used to test the functionality of all the classes in the com.sales package. Your test
should perform the following tests:
-
Create intances of SalesPerson and populate each one with multiple instances of SalesItem. You
should make sure you are testing your SalesPerson class' ability to expand the underlying array of
SalesItems.
-
Create an instance of SalesForce and populate it with the instances of SalesPerson that you
create. You should be sure to test your SalesForce class' ability to expand the underlying array of
SalesPerson.
-
Make use of the getFirstItem() and getNextItem() in a loop for both SalesPerson and
SalesForce.
-
Make use of the isEmpty() and isFull() methods for both SalesPerson and
SalesForce.
-
Make sure you test all the other methods that your classes have available.
Name this class SalesForceDemo and include it in the com.sales package.