Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an Eclipse project named ManageSales. Use a package name of my.fun.ManageSales. Add one class to this package. The class name is ManageSales. This class

Create an Eclipse project named ManageSales. Use a package name of my.fun.ManageSales. Add one class to this package. The class name is ManageSales. This class will have the main method. You will get more information within the following steps

Create a second package named my.fun.sold. Create an interface in this package named Sold. Create one public abstract method in this interface named getSellingAmount. This method should return a double and have no parameters.

Create a third package named my.fun.stick. Add a class named Stick to this package. This class represents a stick you could buy and sell again. The following requirements should apply to the Stick class.

Create the private instance variables as shown on the UML class diagram.

The Stick class must implement the Sold interface. The getSellingAmount method should return the number of shares times the price per share. You will need to import the my.fun.sold package.

Create get and set methods for each private variable. Implement the following edits: the certificate number cannot be null and must have a length greater than zero. The price per share must be greater than zero. The number of shares must be greater than zero. The purchased date cannot be null. Throw an IllegalStickArgumentException if any of the values are invalid. Pass a specific, descriptive error message to the IllegalStickArgumentException constructor.

Create a single constructor that has parameters for the certificate number, price per share, number of shares, purchase date, and sell date. Call the set methods from the constructor using these parameters to update the class variables so the edits only have to be coded once.

Create a toString method that displays the class name and the values of each instance variable.

Create the IllegalStickArgumentException per the UML class diagram. Place this class in the my.fun.stick package.

Create a fourth package named my.fun.car. This package will contain the following classes: Car, Motorcycle, Wheel, and IllegalCarArgumentException. These are described below.

The following requirements apply to the Car class.

Create the private instance variables as shown on the UML class diagram.

The Car class must implement the Sold interface. So make sure you do NOT implement the getSellingAmount method. This will make the Car class an abstract class. You will still need to import the my.fun.sold package.

Create a single constructor that has parameters for the class variables as shown in the UML class diagram. Call the set methods (described below) passing the parameters to update the class variables.

Create get and set methods for each private variable. Implement the following edits: the VIN, make, and model cannot be null nor a length less than one; the purchase price, mileage any model year must be greater than zero. Throw an IllegalCarArgumentException if any of the values are invalid.

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

The following requirements apply to the Motorcycle class.

Make the Motorcycle class a subclass of Car. This class doesn't need to implement the Sold interface since its superclass does.

Create the private instance variables as shown on the UML class diagram.

Create a single constructor that has parameters for the class variables as shown in the UML class diagram. Call the set methods (described below) passing the parameters to update the class variables.

Create get and set methods for each private variable. Implement the following edits: the cargo capacity must be greater than zero; the horsepower must be greater than 0; the number of axles must be greater than zero. Throw an IllegalCarArgumentException if any of the values are invalid.

Override (implement) the getSellingAmount. Calculate the sale amount as 90% of the original sales price if the motorcycle model year is the same or one year older than the current year. For each year after, reduce the original sales price by 4% to arrive at the sales price. For example, assume a 2014 Drof F100 motorcycle was originally purchased for $32,000. The sale amount if sold in 2014, 2015, 2016, or 2017 are shown below.

If sold in ... Sale Amount

2014 32,000.00 * . 9 = 28,800.00

2015 28,800.00 * .96 = 27,648.00

2016 27,648.00 * .96 = 26,542.08

2017 26,542.08 * .96 = 25,480.40

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

The following requirements apply to the Wheel class. This class doesn't need to implement the Sold interface since its superclass does.

Make the Wheel class a subclass of Car. This class doesn't need to implement the Sold interface since its superclass does.

Create the private instance variables as shown on the UML class diagram.

Create a single constructor that has parameters for the class variables as shown in the UML class diagram. Call the set methods (described below) passing the parameters to update the class variables.

Create get and set methods for each private variable. Implement the following edits: Throw an IllegalCarArgumentException if any of the values are invalid.

Override (implement) the getSellingAmount. Calculate the sale amount as 85% of the original sales price if the Wheel model year is the same or one year older than the current year. For each year after, reduce the original sales price by 9% to arrive at the sales price. For example, assume a 2013 Toyoda Corolla Wheel was originally purchased for $22,000. The sale amount if sold in 2013, 2014, 2015, 2016, or 2017 are shown below.

If sold in ... Sale Amount

2013 22,000.00 * .85 = 18,700.00

2014 18,700.00 * . 91 = 17,017.00

2015 17,017.00 * .91 = 15,485.47

2016 15,485.47 * .91 = 14,091.78

2017 14,091.78 * .91 = 12,823.52

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

Create the IllegalCarArgumentException per the UML class diagram. Place this class in the my.fun.car package.

The following requirements apply to the ManageSold application class. This class is in the my.fun.ManageSales package.

Import all the classes from the following packages: my.fun.car, my.fun.stick. Also import the my.fun.sold packagel.

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

Display a menu that has choices for: 1 - Add stick; 2 - Add motorcycle; 3 - Add Wheel; 4 - Display all sales; 5 - 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. The application must contimue to display the menu and process these options until the user enters a 5.

When the user chooses menu option 1, prompt for the user to enter the appropriate data. Read the data using a Scanner and System.in. Implement the following edits: the certificate number cannot be null and must have a length greater than zero. The price per share must be greater than zero. The number of shares must be greater than zero. The purchased date cannot be null or an invalid date. The sold date cannot be null or an invalid date. If any one piece of data is invalid prompt the user to re-enter that data. Continue to prompt the user until a valid value is entered. If all the data is valid, create a Stick object and store it in the ArrayList. Catch the IllegalStickArgumentException when calling the constructor.

When the user chooses menu option 2, prompt for the user to enter the appropriate data. Read the data using a Scanner and System.in. Implement the following edits: the cargo capacity must be greater than zero; the horsepower must be greater than 0; the number of axles must be greater than zero. If any one piece of data is invalid, prompt the user to re-enter that data. If all the data is valid, create a Motorcycle object and store it in the ArrayList. The Motorcycle class can throw an IllegalCarArgumentException so write code to catch that exception.

When the user chooses menu option 3,prompt for the user to enter the appropriate data. Read the data using a Scanner and System.in. Implement the following edits: If any one piece of data is invalid prompt the user to re-enter that data. If all the data is valid, create an Wheel object and store it in the ArrayList. The Wheel class can throw an IllegalCarArgumentException so write code to catch that exception.

When the user chooses menu option 4, list all the objects contained in the ArrayList by calling their toString method. In addition, display the sale amount by calling their getSellingAmount method. Format the sale amount as money.

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

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

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

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

- my.fun.ManageSales: ManageSales

- my.fun.sold: Sold

- my.fun.stick: Stick, IllegalStickArgumentException

- my.fun.car: Car, Motorcycle, Wheel, IllegalCarArgumentExceptionimage text in transcribed

Car vin String purchasePrice: double - make String - model: String modelYear. int - mileage: int +Carvin: String,purchasePrice: double, make: String model String, modelYear: int, mileage: int) +toString):String +getVin ): String + setVin (vin: String) void getPurchasePrice ( ) : double setPurchasePrice my.fun.sellable Sellable +getSaleAmount): double Stick -certificateNumber String - numberOfShares double- pricePerShare: double -datePurchased LocalDate - dateSold: LocalDate (price: double) : void +getMake():String +setMake (make: String) : void +getModel(): String +setModel (model: String): void + getModelYear (): int + setModelYear(modelYear int): void +getMileage():int +setMileage (mileage: int) void + Stick(certificateNumber: StringnumShares: double pricePerShare double,datePurchased: LocalDate, dateSold LocalDate) getSaleAmount () double toString() String getCertificateNumber): String +setCertificateNumber(certNumber String) void getNumberOtShares ( ) : double +setNumberOfShares (numShares: double) void +getPricePerShare ():double +setPricePerShare (price double): void getDatePurchased ( ) : LocalDate +setDatePurchased (datePurchased: LocalDate) void getDateSold () :LocalDate *setDateSold (dateSold LocalDate) void Motorcycle cargoCapacity: double horsePower double -numberOFAxles: int Wheel numberOfSeats int IllegalStickArgumentException +Motorcycle (vin: String, purchasePrice: double +llegalStickArgumentExceptionO + llegalStickArgumentException(message String) +Wheel (vin: String.purchasePrice: double mileage:int, seating: int) + getSaleAmount(): double +toString() String +getNumberOfSeats(): int + setNumberOfSeats (numSeats: double): void make String, model: String, modelYear int, mileage: int, int) +getSaleAnt): double +toString( ): String +getCargoCapacity): double +setCargoCapacity (capacity: double): void+ make: String, model: String, modelYear. int,cargoCapacity: double,horsepower. double, numOfAxles getHorsePower(): double IllegalCarArgumentException +IllegalCarArgumentException 0 +llegalCarArgumentException (message setHorsePower ( hp: double) void getNumberOfAxles (): int +setNumberOfAxles (axles: int) void String)

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

More Books

Students also viewed these Databases questions

Question

Be able to reproduce multiple copies of the system?

Answered: 1 week ago

Question

4 How can you create a better online image for yourself?

Answered: 1 week ago