Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solution this java project Clearlyyy Given uml and do the following: 1 - Create class / interface that implements the classes + interface displayed
Please solution this java project Clearlyyy Given uml and do the following: Create classinterface that implements the classes interface displayed in the UML displayed above exactly as specified same variable names, types, Make sure to include noarg all field constructors, setters getters, as well as toString methods in each of the classes created. Please note the following:a method calculatePaymentis implemented differently in each of the concrete classes as follows: in class Cash it is calculated as the payment amount entered minus the discountRate percentage eg if amount is and discountRate is then payment value is in class Check, payment is the same as the amount entered. in class CreditCard, payment is the amount plus the chargingFee.b method printPaymentInfo prints the properties and the calculated payment by calling both the toString as well as the calculatePayment methods. c class CustomerPayment is Comparable based on the value returned by the method calculatePaymentd Check class has a variable called type int which is set using one of three constant values that should be defined in the class CASHIER CERTIFIED PERSONALe classes Check and CreditCard implement interface Payable by implementing the method isAuthorized as follows: A Check payment is authorized if either the type of the check is CASHIER or if the amount of the payment is less than or equal to the accountBalance, otherwise it is not authorized. A CreditCard payment is authorized if its expiryDate is less than or equal to the current date. Create a Driver class that does the following: Creates an ArrayList of type CustomerPayment and adds different types of payments to it Cash Check, CreditCard Check or CreditCard payments should be checked if they are authorized before adding them to the list. If they are not authorized, they should not be added to the list. Make sure to deduct the amount of authorized Check payments CERTIFIED and PERSONAL only from the accountBalance before adding them to the list use the method deductAmountFromBalance Sorts the ArrayList created use Collections.sort in descending order based on the calculated payment. After sorting you should print the list to the screen using the printPaymentInfo method.Your all field constructors should use EXACTLY the following format and order:CustomerPayment customerName, customerId, amount Cash customerName, customerId, amount, discountRate Check customerName, customerId, amount, accountNumber, accountBalance, typeCreditCard customerName, customerId, amount, chargingFee, expiryDateSample Run:Assume you try to add the following payments to your list:new CheckRanaCheck.PERSONAL; new CashAhmad;new CheckSuhaCheck.CASHIER ; new CheckRaniaCheck.CERTIFIED; new CreditCardRanda new Date; new CreditCardHani new Date;Then the output of your program should be very similar to the following:Check accountNumber accountBalance type customerNameRania, customerId amount Payment CreditCard chargingFee expiryDateMon Jun :: IDT customerNameRanda, customerId amount Payment Cash discountRate customerNameAhmad, customerId amount Payment Check accountNumber accountBalance type customerNameSuha, customerId amount Payment Please note the following modification in the following statement in the project description:ACreditCardpayment is authorized if itsexpiryDateislessthan or equal to the current date.The wordlessabove should be replaced by the wordgreaterOther notes: You should use the Comparable interface already defined by java and not create your own. You Driver class should include only the main method and you should assume that if your Driver class is replaced by another Driver class that creates a list similar to the example then your program should work fine without any modifications. As explained in the description, a Check of type CASHIER does NOT subtract the amount from the account balance.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started