Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this assignment is to use an ArrayList, inheritance, overridden methods, interfaces, and polymorphism. In addition you will use multiple packages. In this

The purpose of this assignment is to use an ArrayList, inheritance, overridden methods, interfaces, and polymorphism. In addition you will use multiple packages. In this application you will create n interface to describe things that are "payable". To use this interface you will create classes for two types of things that are paid - employees and bills. Employees will be modeled using a hierarchy of classes for different types of employees. There will be a single class for bills that are paid. The overall UML class diagram is shown below. Notice Payable is an interface and Employee is an abstract class.

ccinterface> Payable Employee Bill Manage HourlyEmployee SalesManager

The UML class diagram for each service class and interface is provided below.

These classes are all service classes. In addition you will need to creat an application class named ManagePayablesApplication. Objects of the service classes will be processed polymorphically in the ManagePayablesApplication class. Observe how you can store any of the service class objects in a properly created ArrayList. The detail requirements for each class are provided below.

Creat an Eclipse project named Payments. Use a package name of edu.arizonastate.payments Add one clas to this package. The class name is ManagePayablesApplication. This class will have the main method. More requirements for this class are listed below.

Creat a second package named edu.arizonastate.payable. Creat an interface in this package named Payable. Create one public abstract method in this interface named computeAmountToPay. This method should return a double and have no parameters.

Creat a third package named edu.arizonastate.bill. Add a class named Bill to this package. This class represents an amount we owe to some vendor. The following requirements apply to the Bill class.

Create three private variables. Use a String to represent the vendor name. Use a double to represent the amount owed. Use a LocalDate to represent the date when the amount is due.

The Bill class must implement the Payable interface. The computeAmountToPay method should return the amount owed. You will need to import the edu.arizonastate.payable package.

Create get and set methods for each private variable. Overload the set method for the due date. Per the UML class diagram, this overloaded method should have three integers that represent the year, month, and day of the date. Use this data to create the LocalDate object. Throw the DateTimeException if the LocalDate object cannot be created. Implement the following edits: the vendor name cannot be null nor can it have a length less than one; the amount owed must be greater than zero; the due date cannot be null. Throw an InvalidArgumentException if any of the values are invalid. Add this exception class to a new package named edu.arizonastate.exceptions.

public class InvalidArgumentException extends Exception {

public InvalidArgumentException(){

super("Invalid values sent to method");

}

public InvalidArgumentException(String msg){

super(msg);

Creat a constructor that has parameters for the vendor, amount, and due date. Call the set methods from the constructor to use these parameters to update the class variables so the edits only have to be coded once.

Creat a toString method that displays the class name and the values of each of the three instance variables.

Create fourth package named edu.arizonastate.employees. This package will contain the following classes: Employee, HourlyEmployee, Manager, and SalesManager.

The following requirements apply to the Employee class.

Create three private instance variables. Use a String to represent the employee's first name. Use a String to represent the employee's last name. Use an int to represent the employee's ID.

The Employee class must implement the Payable interface. Do NOT implement the computeAmountToPay method. This will make the Employee class an abstract class. You will still need to import the edu.arizonastate.payable package.

Create get and set methods for each private variable. Implement the following edits: the first name cannot be null nor can it have a length less than one; the last name cannot be null nor can it have a length less than one. the ID must be greater than zero; Throw an InvalidArgumentException if any of the values are invalid.

Create constructor that has parameters for the first name, last name, and ID. Call the set methods from the constructor to use these parameters to update the class variables so the edits only have to be coded once.

Create toString method that displays the class name and the values of each of the three instance variables.

The following requirements apply to the HourlyEmployee class.

Make the HourlyEmployee class a subclass of Employee.

Create two private instance variables. Use a double to represent the hours the employee worked. Use a double to represent the hourly pay rate.

The HourlyEmployee class must implement the Payable interface. The computeAmountToPay method should return the hours worked times the hourly pay rate. You will need to import the edu.arizonastate.payable package.

Create get and set methods for each private variable. Implement the following edits: the hours worked must be greater than zero; the hourly pay rate must be greater than zero. Throw an InvalidArgumentException if any of the values are invalid.

Creat a constructor that has parameters for the first name, last name, and ID, hours worked, and hourly rate. Call the superclass constructor passing the first name, last name, and ID. Call the set methods from the constructor to use the parameters to update the class variables so the edits only have to be coded once.

Create toString method that displays the data from the superclass and the class name and the values of each of the two instance variables in the HourlyEmployee class.

The following requirements apply to the Manager class.

Make the Manager class a subclass of Employee.

Create one private instance variable for the annual salary. Use a double to represent the annual salary.

The Manager class must implement the Payable interface. The computeAmountToPay method should return the annual salary divided by 12. You will need to import the edu.arizonastate.payable package.

Create get and set methods for the private variable. Implement the following edits: the annual salary must greater than zero. Throw an InvalidArgumentException if the annual salary value is invalid.

Creat a constructor that has parameters for the first name, last name, and ID, and annual salary. Call the superclass constructor passing the first name, last name, and ID. Call the set methods from the constructor to use the parameters to update the class variables so the edits only have to be coded once.

Create toString method that displays the data from the superclass and the class name and the annual salary value from the Manager class.

The following requirements apply to the SalesManager class.

Make the SalesManager class a subclass of Manager.

Create two private instance variables. Use a double to represent the sales amount. Use a double to represent the commission rate.

The SalesManager class must implement the Payable interface. The computeAmountToPay method should return the pay value from the super class plus the sales amount times the commission rate. You will need to import the edu.arizonastate.payable package.

Create get and set methods for the private variables. Implement the following edits in the set methods. The sales amount must be greater than or equal to zero. Throw an InvalidArgumentException if the sales amount value is invalid. The commission rate must be between 0 and 1 inclusive. Throw an InvalidArgumentException if the commission rate is invalid.

Createa constructor that has parameters for the first name, last name, and ID, annual salary, sales amount, and commission rate. Call the superclass constructor passing the first name, last name, ID, and annual salary. Call the set methods from the constructor to use the parameters to update the class variables so the edits only have to be coded once.

Create toString method that displays the data from the superclass, the class name, and the values of each of the two instance variables in the SalesManager class.

The following requirements apply to the ManagePayablesApplication class.

Import all the classes from the following packages: edu.arizonastate.payable, edu.arizonastate.employees, and edu.arizonastate.bill.

This class will have the main method. Create ArrayList to store Payable objects.

Display a menu that has choices for: 1 - Add hourly employee; 2 - Add manager; 3 - Add sales manager; 4 - Add bill; 5 - List all payables; 6 - Exit. Display an error message and repeat the menu if some other value is entered. This will require you to catch the appropriate exception if letters instead of numbers are entered.

When the user chooses menu option 1, prompt for an employee first name, an employee last name, an employee ID, hours worked, and pay rate. Edit these values such that: the first name cannot have a length less than one or be null; the last name cannot have a length less than one or be null; the ID must be > 0; the hours worked must be > 0; the pay rate must be > 0. If any one piece of data is invalid prompt the user to re-enter that data. If all the data is valid, creat a HourlyEmployee object and store it in the ArrayList. The HourlyEmployee class can throw an InvalidArgumentException so write code to catch that exception.

When the user chooses menu option 2, prompt for an employee first name, an employee last name, an employee ID, and annual salary. Edit these values such that: the first name cannot have a length less than one or be null; the last name cannot have a length less than one or be null; the ID must be > 0; the annual salary must be > 0. If any one piece of data is invalid, prompt the user to re-enter that data. If all the data is valid, creat a Manager object and store it in the ArrayList. The Manager class can throw an InvalidArgumentException so write code to catch that exception.

When the user chooses menu option 3, prompt for an employee first name, an employee last name, an employee ID, annual salary, sales amount, and commission rate. Edit these values such that: the first name cannot have a length less than one or be null; the last name cannot have a length less than one or be null; the ID must be > 0; the annual salary must be > 0; the sales amount must be > 0; the commission rate must be >= 0 and

When the user chooses menu option 4, prompt for an vendor name, an amount due, and a due date. Edit these values such that: the vendor name cannot have a length less than one or be null; the amount must be > 0; the due date must be valid. Catch the DateTimeParseException to determine if the date is invalid. If any one piece of data is invalid prompt the user to re-enter that data. If all the data is valid, creat a Bill object and store it in the ArrayList. The Bill class can throw an InvalidArgumentException so write code to catch that exception.

When the user chooses menu option 5, list all the objects contained in the ArrayList by calling their toString method. In addition, display the amount to be paid by calling their computeAmountToPay method. Format the amount to be paid as currency.

Display a closing message and end the application when the user chooses option 6.

Do not add a throws clause to the main method. In other words, use try, catch for any exceptions that make arise in the ManagePaymentsApplication class.

Use a Scanner object for all user input. Use System.out for all user output.

Add a comment to each source code file for your name and the date.

Here is a summary of the packages required in this assignment and what classes or interfaces should be in each package.

- edu.arizonastate.payments: ManagePayablesApplication

- edu.arizonastate.payable: Payable

- edu.arizonastate.bill: Bill

- edu.arizonastate.employees: Employee, HourlyEmployee, Manage, SalesManager

- edu.arizonastate.exceptions: InvalidArgumentException

image text in transcribed
ccinterfoce> > Employee Payable Bill Manager HourlyEmployee SalesManager The UML class diagram for each service class and interface is provided below

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

what are the implications of not paying an obligation?

Answered: 1 week ago