Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Department Store Inheritance is an important topic in OOPDA, that involves one class (the subclass or child class) acquiring and expanding upon the properties

The Department Store

Inheritance is an important topic in OOPDA, that involves one class (the subclass or child class) acquiring and expanding upon the properties (variables, methods, etc.) of another class (the superclass or parent class). In this assignment, we are going to be focusing on employees who will be instantiated for a particular day of operation. Some starter files have been created for you. Your objective is to:

  1. implement inheritance correctly by finishing the Employee, Cashier, and SalesAssociate classes
  2. complete the display method in the Driver

Here is some information about the classes.

Cashier: The Cashier has to keep track of the amount of money in their drawer. They can also complete transactions and returns.

SalesAssociate: The SalesAssociate must have a department that they are working in. Besides this, they must also keep track of the number of sales completed, as well as the amount of revenue made from overall sales. SalesAssociates can also make a sale.

EmployeeDriver: The driver will make two cashiers and one sales associate and add them into a polymorphic collection of Employees. Employees to populate the HashSet given to you, and display them all, with ALL information related to each one being shown. Its main method looks like this:

 makeEmployees(); employees.forEach(e -> simulateSalesDay(e)); displayEmployees();

The makeEmployees() method is complete, as is the simulateSalesDay() method. The displayEmployees method should iterate over the employees ArrayList and print out the following information.

Here are the employees: SalesAssociate Name: Will Martin ID: 166 Hourly Wage: 11.5 Productivity: 0.601205 Department: Shoes Number of Sales: 3 Amount of Revenue: 202.41 Cashier Name: Franny Wilkins ID: 100 Hourly Wage: 10.75 Productivity: 0.3 Drawer Amount: 1196.52 Cashier Name: Barbara Smith ID: 76 Hourly Wage: 11.0 Productivity: 1.2 Drawer Amount: 3026.73

You will notice that every employee has a productivity rating which is calculated as follows.

Cashiers will ringup sales at the register and complete returns. Each of these will count as a transaction. You need to keep track of the cashier transactions. The daily transaction target for all cashiers is 20. In the example above, Franny Wilkins only made 6 transactions, so her productivity is 30%.

Sales Associate productivity is calculated based on two metrics -- number of sales and amount of revenue. A sales associate has a daily target of 3 sales, and a target daily revenue of $1000. In the example above, Will Martin did make 3 sales, making the sales number metric 100%. However, he only brought in revenue of $202.40, making the revenue generated metric about 20%. When you average these two metrics, you can see that Will's final productivity is 60%.

package deptStore;

/** * A class to create a Cashier working at a store * * @author OOPDA Instructor * */ public class Cashier extends Employee {

public Cashier(String name, int employeeID, double hourlyWage, double drawerAmount) { }

public void ringup(double d) { // TODO Auto-generated method stub }

public void completeReturn(double d) { // TODO Auto-generated method stub } }

package deptStore;

/** * A class to create an Employee working at a store * * @author OOPDA Instructor * */ public abstract class Employee { /* the name of the Employee */ protected String name; /** * The no argument constructor */ public Employee() { }

public String getName() { return this.name; }

}

package deptStore;

import java.util.HashSet; import java.util.concurrent.ThreadLocalRandom;

/** * A Driver to display Employees created * * @author OOPDA Instructor * */ public class EmployeeDriver { private static HashSet employees = new HashSet<>(); public static void main(String[] args) { makeEmployees(); employees.forEach(e -> simulateSalesDay(e)); displayEmployees(); }

/** * This method creates an instance of all three types of * Employees and adds them to a HashSet */ private static void makeEmployees() { Cashier cashier1 = new Cashier("Franny Wilkins", 100, 10.75, 200); Cashier cashier2 = new Cashier("Barbara Smith", 76, 11.00, 100); SalesAssociate sa = new SalesAssociate("Will Martin", 166, 11.50, "Shoes"); employees.add(cashier1); employees.add(cashier2); employees.add(sa); } private static void simulateSalesDay(Employee emp) { if (emp instanceof Cashier) { makeTransactions((Cashier) emp); } else if (emp instanceof SalesAssociate) { makeSales((SalesAssociate) emp); } } private static void makeTransactions(Cashier emp) { // Set parameters for the simulation final int MIN_SALES = 4; final int MAX_SALES = 30; final int MIN_RETURNS = 0; final int MAX_RETURNS = 3;

int randomSales = ThreadLocalRandom.current().nextInt(MIN_SALES, MAX_SALES + 1); int randomReturns = ThreadLocalRandom.current().nextInt(MIN_RETURNS, MAX_RETURNS + 1); double randomAmount; // Simulate the sales for the day for (int i = 0; i < randomSales; i++) { randomAmount = (double) ThreadLocalRandom.current().nextInt(1000, 25000) / 100; emp.ringup(randomAmount); System.out.println(emp.getName() + " rang up $" + randomAmount); } // Simulate the returns for the day for (int i = 0; i < randomReturns; i++) { randomAmount = (double) ThreadLocalRandom.current().nextInt(1000, 25000) / 100; emp.completeReturn(randomAmount); System.out.println(emp.getName() + " processed return of $" + randomAmount); } }

private static void makeSales(SalesAssociate emp) { // Set parameters for the simulation final int MIN_SALES = 0; final int MAX_SALES = 5; int randomSales = ThreadLocalRandom.current().nextInt(MIN_SALES, MAX_SALES + 1); double randomAmount; for (int i = 0; i < randomSales; i++) { randomAmount = (double) ThreadLocalRandom.current().nextInt(1000, 25000) / 100; emp.makeSale(randomAmount); System.out.println(emp.getName() + " made sale of $ " + randomAmount); } }

/** * This method loops through the employees * and displays ALL information about each one */ private static void displayEmployees() { System.out.println(" Here are the employees: "); // TODO complete this method. }

}

package deptStore;

/** * A class to create a SalesAssociate working at a store * * @author OOPDA Instructor * */ public class SalesAssociate extends Employee {

public SalesAssociate(String name, int employeeID, double hourlyWage, String department) { // TODO Auto-generated constructor stub }

public void makeSale(double randomAmount) { // TODO Auto-generated method stub }

}

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

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

More Books

Students also viewed these Databases questions