In total 3 java files ItemInventory Customer and Tester 1 I

In total 3 java files --> ItemInventory, Customer and Tester

1) ItemInventory class

4 instance variables of type Arraylist:

                                Item Id,

                                Description,

                                Quantity and

                                Selling price  

addData(Item Id, description, quantity, selling price)                          

manageSells(Item id, quantity)

                                It will decrement quantity.

calculatePrice(Item Id, quantity)

It will return quantity * sellingPrice.

display()

2) Customer

3 instance variable of type Arraylist:

Customer Number

Name

Total Purchase

addData() same as above

addPurchase(cusNum, price)

Before you call this method, the is already being calculated using method of ItemInventory class.

Display()

3) Tester

Create one ItemInventory object. And add necessary information to it.
Create one customer object. And add information

------------------------------------------------------------------------------------------------------------------------------------------

First, ask for customer Number only and in next line ask for Item’s ID (for simplicity give only one item id here) and finally, ask for quantity.

Call manageSells (ID, Quantity)

Price = CalculatePrice (ID, Quantity)

Call addPurchase (CusNum, Price)

Repeat above steps (bold letters) one more time.

Solution

public void addEmployee(int input, String firstName, String lastName,
           char middleInitial, char gender, int employeeNum, boolean fulltime,
           double wage) {

       switch (input) {
       case 1: {
           HourlyEmployee employee = new HourlyEmployee(firstName, lastName,
                   middleInitial, gender, employeeNum, fulltime, wage);
           for (int i = 0; i < employees.length; i++) {
               if (employees[i].getEmployeeNumber() == employeeNum) {
                   System.out.println(\"Duplicate Not Added\");
                   return;

               }
           }
           if (currentEmployees == employeeMax) {
               System.out.println(\"Cannot add more Employees\");
               return;
           }
           employees[currentEmployees] = employee;
           currentEmployees++;
           break;
       }
       case 2: {
           SalaryEmployee employee = new SalaryEmployee(firstName, lastName,
                   middleInitial, gender, employeeNum, fulltime, wage);
           for (int i = 0; i < employees.length; i++) {
               if (employees[i].getEmployeeNumber() == employeeNum) {
                   System.out.println(\"Duplicate Not Added\");
                   return;

               }
           }
           if (currentEmployees == employeeMax) {
               System.out.println(\"Cannot add more Employees\");
               return;
           }
           employees[currentEmployees] = employee;
           currentEmployees++;
           break;
       }
       case 3: {
           CommissionEmployee employee = new CommissionEmployee(firstName,
                   lastName, middleInitial, gender, employeeNum, fulltime,
                   wage);
           for (int i = 0; i < employees.length; i++) {
               if (employees[i].getEmployeeNumber() == employeeNum) {
                   System.out.println(\"Duplicate Not Added\");
                   return;

               }
           }
           if (currentEmployees == employeeMax) {
               System.out.println(\"Cannot add more Employees\");
               return;
           }
           employees[currentEmployees] = employee;
           currentEmployees++;
           break;
       }
       default:
           System.out.println(\"Invalid Employee Type, None Added\");
           break;
       }

   }

   // Removes an Employee located at the given index from the Employee array.
   public void removeEmployee(int index) {
       employees[index] = null;

   }

   // Lists all the current Employees. Outputs there are none if there are
   // none.
   public void listAll() {
       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null)
                   System.out.println(employees[i].toString());
           }
       }

   }

   // Lists all the current HourlyEmployees. Outputs there are none if there
   // are none.
   public void listHourly() {

       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null) {
                   if (employees[i] instanceof HourlyEmployee)
                       System.out.println(employees[i].toString());
               }
           }
       }
   }

   // Lists all the current SalaryEmployees. Outputs there are none if there
   // are none.
   public void listSalary() {
       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null) {
                   if (employees[i] instanceof SalaryEmployee)
                       System.out.println(employees[i].toString());
               }
           }
       }
   }

   // Lists all the current CommissionEmployees. Outputs there are none if
   // there are none.
   public void listCommission() {
       if (currentEmployees == 0)
           System.out.println(\"none\");
       else {

           for (int i = 0; i < currentEmployees; i++) {
               if (employees[i] != null) {
                   if (employees[i] instanceof CommissionEmployee)
                       System.out.println(employees[i].toString());
               }
           }
       }
   }

   public void resetWeek() {
       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               employees[i].resetWeek();
           }
       }
   }

   public double calculatePayout() {

       double payOut = 0;
       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               payOut += employees[i].calculateWeeklyPay();
           }
       }

       return payOut;
   }

   public int getIndex(int employeeNum) {

       for (int i = 0; i < employees.length; i++) {
           if (employees[i].getEmployeeNumber() == employeeNum) {

               return i;

           }
       }
       return -1;
   }

   public void annualRaises() {

       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               employees[i].annualRaise();
           }
       }
   }

   public double holidayBonuses() {
       double holiBonus = 0;
       for (int i = 0; i < currentEmployees; i++) {
           if (employees[i] != null) {
               holiBonus += employees[i].holidayBonus();
           }
       }

       return holiBonus;
   }

   // Increase the hours worked of the Employee at the given index by the given
   // double amount.
   public void increaseHours(int index, double amount) {

       if (employees[index] != null
               && employees[index] instanceof HourlyEmployee) {
           HourlyEmployee employee = (HourlyEmployee) employees[index];
           employee.increaseHours(amount);
       }
   }

   // Increase the sales of the Employee at the given index by the given double
   // amount.
   public void increaseSales(int index, double amount) {

       if (employees[index] != null
               && employees[index] instanceof CommissionEmployee) {
           CommissionEmployee employee = (CommissionEmployee) employees[index];
           employee.increaseSales(amount);
       }

   }

}

In total 3 java files --> ItemInventory, Customer and Tester 1) ItemInventory class 4 instance variables of type Arraylist: Item Id, Description, Quantity an
In total 3 java files --> ItemInventory, Customer and Tester 1) ItemInventory class 4 instance variables of type Arraylist: Item Id, Description, Quantity an
In total 3 java files --> ItemInventory, Customer and Tester 1) ItemInventory class 4 instance variables of type Arraylist: Item Id, Description, Quantity an
In total 3 java files --> ItemInventory, Customer and Tester 1) ItemInventory class 4 instance variables of type Arraylist: Item Id, Description, Quantity an
In total 3 java files --> ItemInventory, Customer and Tester 1) ItemInventory class 4 instance variables of type Arraylist: Item Id, Description, Quantity an

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site