Question: Purpose: This lab focuses on interface inheritance and the use of polymorphism to more easily control the construction of an object at runtime. Task: Create

 Purpose: This lab focuses on interface inheritance and the use of

polymorphism to more easily control the construction of an object at runtime.

Task: Create a project called Customers_FirstName_LastName or Lab5_FirstName_LastName. This project will consist

Purpose: This lab focuses on interface inheritance and the use of polymorphism to more easily control the construction of an object at runtime. Task: Create a project called Customers_FirstName_LastName or Lab5_FirstName_LastName. This project will consist of the following files: the Main class provided on Blackboard as well as the Customer, RegularCustomer, and Platinum Customer classes you will implement. Remember to include comments summarizing the various components of this lab. 1. Review the UML class diagram included with the directions for lab 5. Keep in mind the interface inheritance relationship between Customer and the other two classes: Regular Customer and Platinum Customer. Purpose: This lab focuses on interface inheritance and the use of polymorphism to more easily control the construction of an object at runtime. Task: Create a project called Customers_FirstName_LastName or Lab5_FirstName_LastName. This project will consist of the following files: the Main class provided on Blackboard as well as the Customer, RegularCustomer, and Platinum Customer classes you will implement. Remember to include comments summarizing the various components of this lab. 1. Review the UML class diagram included with the directions for lab 5. Keep in mind the interface inheritance relationship between Customer and the other two classes: RegularCustomer and Platinum Customer. 2. Write the code for the Customer interface with each of the four abstract methods specified in the UML class diagram: displayName, displayBalance, addToBalance, and make Transaction. 3. Write the code for the RegularCustomer with the two fields and four methods specified in the UML class diagram. Additionally, remember that RegularCustomer implements the Customer interface. The four methods should have the following behaviors: a. The displayName method returns the following String with replaced with the name field: "This regular customer is ." b. The displayBalance method returns the following String with replaced with the balance field formatted to two decimal places: "The balance for this regular customer is $." C. The addToBalance method adds the passed in deposit to the balance field. d. The make Transaction method subtracts the passed in cost from the balance field. 4. Write the code for the Platinum Customer with the two fields and four methods specified in the UML class diagram. Additionally, remember that Platinum Customer implements the Customer interface. The four methods should have the following behaviors: a. The displayName method returns the following String with replaced with the name field: "This platinum customer is ." b. The displayBalance method returns the following String with replaced with the balance field formatted to two decimal places: "The balance for this platinum customer is $." C. The addToBalance method adds the passed in deposit to the balance field. d. The make Transaction method subtracts the passed in cost from the balance field with a 10% reward deduction. For example, a transaction that normally costs $100 would instead be $90. Criteria: Comments summarizing the program are worth 5 points. The Customer interface is worth 20 points. The class headers for both RegularCustomer and Platinum Customer are worth 3 points each (6 points total). The fields for both RegularCustomer and Platinum Customer are worth 3 points each (12 points total). The displayName method for both classes is worth 8 points for each (16 points total). The displayBalance method for both classes is worth 10 points for each (20 points total). The addToBalance method for both classes is worth 5 points for each (10 points total). The make Transaction method is worth 5 points for the RegularCusomer class and 6 points for the Platinum Customer class. > Customer + displayName(): String + displayBalance(): String + addToBalance(deposit : double) : void + make Transaction(cost : double): void RegularCustomer name : String - balance : double + displayName(): String + displayBalance(): String + addToBalance(deposit : double) : void + make Transaction(cost : double): void Platinum Customer - name : String - balance : double + displayName(): String + displayBalance(): String + addToBalance(deposit : double): void + make Transaction(cost : double): void import java.util.Scanner; public class Main { public static void main(String args) { Scanner keyboard = new Scanner(System.in); Customer cust = null; String name = null; double balance = 0.0; String type = null; double deposit = 0.0; double cost = 0.0; System.out.print("What is the customer's name? "); name = keyboard.nextLine(); System.out.print("What is the customer's initial balance?"); balance = keyboard.nextDouble(); keyboard.nextLine(); System.out.print("What type of customer is this? "); type = keyboard.nextLine(); if (type.equals("regular")) cust = new RegularCustomer(name, balance); } else if (type.equals("platinum")) { cust = new Platinum Customer(name, balance); } System.out.println(cust.displayName()); System.out.println(cust.displayBalance()); System.out.print("How much is this customer adding to the balance? deposit = keyboard.nextDouble(); cust.addToBalance(deposit); System.out.println(cust.displayBalance()); System.out.print("How much did this customer's purchase cost? "); cost = keyboard.nextDouble(); 1/2 cust.make Transaction(cost); System.out.println(cust.displayBalance()); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!