[Solved]Java Job Build Order Classes Two Vehicle Types Document Javadoc Write Test Classes Classes Q37125382
In Java Your job now is to build the order classes for the twovehicle types, document them with Javadoc and write test classesfor both classes you create.
CarOrder
In reality, not only the design process, but also the paymentprocess for each vehicle is different. The CarOrder class willinclude a method that will print monthly payments for the car basedon the price of the vehicle, the credit score of the customer andthe length of the loan they are willing to take.
The CarOrder class will also give a discount to the customerbased on the model year of the car and on whether they are areturning customer to PV.
With that in mind, here are the requirements your managercompiled for the CarOrder class:
- Variables
- model
- year
- price
- returningCustomer (boolean)
- creditScore
- loanLength
- discountPercent
- interestRate
- Methods
- getters and setters for each of the variables mentionedabove
- A constructor -> (model, year, price, returningCustomer,creditScore, loanLength)
- When the constructor is initiated, apart from setting thevariables’ values, it should call a method calculateInterestRate()- described next, and the method discountPercent() – describedbelow.
- calculateInterestRate() : this method will calculate theinterest rate for the loan for the car based on the credit score ofthe customer and the length of the loan they are willing to take.The rules are the following:
- If the length of the loan is less than 5 years, 1% is added tothe interestRate. If greater or equal to 5 years, 2% are added tothe interest rate.
- Credit Score
- If the customer’s credit score is greater than 700, 0.5% isadded to the interest rate
- if the customer’s credit score is between 500 – 700, 1.5% isadded to the interest rate
- if the customer’s credit score is lower than 500, 3% is addedto the interest rate
- discountPercent() : this method will calculate the discountpercentage (if any). The rules are the following.
- If the buyer is a returning customer, 5% initial discount isadded
- Based on the model year,
- if the model year is < 2010, additional 15% of discount isadded
- if the model year is between 2010 – 2016, additional 10% ofdiscount is added
- if the model year is greater than 2016, 0% of discount isadded
- Additional Methods
- printPaymentSchedule() : this method will print the paymentschedule. First, it will calculate the total price that needs to bepaid, that is: price x discountPercent. After that number is found,the interest amount needs to be applied. Use the formula describedhere (Links to an external site.)Links to an external site. tocalculate the interest amount on top of the principal payment(price of the car). Once you have a final number, print the paymentfor each month . Example:
Month 1 : $599
Month 2 : $599The value is going to be repetitive, but usually companies want tohave the month to month breakdown so that they can use it for theirbudget planning.
- printPaymentSchedule() : this method will print the paymentschedule. First, it will calculate the total price that needs to bepaid, that is: price x discountPercent. After that number is found,the interest amount needs to be applied. Use the formula describedhere (Links to an external site.)Links to an external site. tocalculate the interest amount on top of the principal payment(price of the car). Once you have a final number, print the paymentfor each month . Example:
BusOrder
As stated in the CarOrder requirements, thepayment process is different for different vehicles. The maindifference is that usually busses are bought by cities/companies inbulk, and cars are mostly bought in a one-car-per-customer fashion.The benefit of buying in bulk is that the buyer gets a discount onthe total price of the busses they buy, and the more busses theybuy, the bigger the discount.
Also, cities, counties and other government bodies usually getan extra discount on top of the first bulk discounted price.
For the calculations to be made, we first need an invoice, or anorder. The order method, which is the constructorin our case (described in detail below), will set some variables inthe instance of the BusOrder object, such as quantity, buyer,whether they are a government buyer or not, etc.. It will also callsome methods to set some variables based on calculations made forthe discount percentage and price per bus.
Once a bus order is made, Pretty Vehicles wants to be able toprint a schedule as to when the busses are going to be built andfinished, and how many per month they are going to build. The waythey decide the schedule is based on how many vehicles the buyer isbuying. A buyer that buys more vehicles is going to have morepriority, and by that we mean more buses per month will be builtfor them.
With all that in mind, here are the requirements your managercompiled:
- Variables
- quantity
- model
- model year
- buyerName
- governmentBody (boolean)
- loanLengthYears
- discountPercent
- pricePerBus
- Methods
- getters and setters for all the variables mentioned above.
- A constructor (quantity, model, year, buyerName,governmentBody, loanLengthYears);
- When the constructor is initiated, apart from setting thevariables’ values, it should call a methodcalculateDiscountPercent() – described next, and acalculatePricePerBus() method – described below. If the model nameis not one of the model names mentioned below, print a messagesaying “This model does not exist”
- calculateDiscountPercent() : this method will calculate thediscount percent and set the discountPercent variable in the classinstance. The discount is calculated this way:
- If a government body, an initial 5% discount automaticallyapplies, if not, no initial discount is applied
- If the model year of the busses in the order is less than 2016,then a 3% discount is added to the current discount percentage sum,else – no discount is added to the percentage sum
- Based on the quantity
- If less than 10 buses are ordered, no quantity discount isapplied
- if the quantity is between 10 and 50, a 5% discount is added tothe current discount percentage sum
- if the quantity is greater than 50, then a 10% discount isadded to the current discount percentage sum
- calculatePricePerBus() : this method calculates the price perbus for the order based on the model year and the model name. Thefollowing are the prices of the busses per model year bracket.
- Model “Mad Max”
- Model year 2016 – 2019 -> $80,000
- Model year 2013 – 2015 -> $60,000
- Model year 2010 – 2012 -> $45,000
- Model “Low Emission”
- Model year 2016 – 2019 -> $95,000
- Model year 2013 – 2015 -> $80,000
- Model year 2010 – 2012 -> $65,000
- Model “No Oil”
- Model year 2016 – 2019 -> $110,000
- Model year 2013 – 2015 -> $95,000
- Model year 2010 – 2012 -> $80,000
- Model “Mad Max”
- Additional Methods
- printBuildingSchedule() : this method will print the buildingschedule for each month of the building process. As brieflymentioned above, the schedule is based on the quantity of bussesordered. The rules are the following:
- If less than 10 busses are ordered, PV builds them with aregular schedule, and that is 4 per month.
- If 10 – 50 busses are ordered, PV builds 6 busses per month, orone bus every 5 days.
- If more than 50 busses are ordered, PV builds 8 busses permonth, or 2 busses per week.
Based on that, you should build this method so that it prints thenumber of busses for each month. For example, if 7 busses areordered:
Month 1 – 4 buses
Month 2 – 3 buses
- printPaymentSchedule() : this method will print the paymentschedule. First, it will calculate the total price that needs to bepaid, that is: quantity x pricePerBus x discountPercent. After thatnumber is found, the interest amount needs to be calculated. PV’srule is that government bodies don’t pay interest (0%), but privatecompanies need to pay 1% interest. Use the formula described here(Links to an external site.)Links to an external site. to calculatethe interest amount. Once you have a final number, print thepayment for each month . Example:
Month 1 : $599
Month 2 : $599The value is going to be repetitive, but usually companies want tohave the month to month breakdown so that they can use it for theirbudget planning.
- printBuildingSchedule() : this method will print the buildingschedule for each month of the building process. As brieflymentioned above, the schedule is based on the quantity of bussesordered. The rules are the following:
Expert Answer
Answer to In Java Your job now is to build the order classes for the two vehicle types, document them with Javadoc and write test … . . .
OR

