Question: Write the Java code for two classes (Customer and Order) as per the requirements below: 1. The Customer class has a name and an order

 Write the Java code for two classes (Customer and Order) as

Write the Java code for two classes (Customer and Order) as per the requirements below: 1. The Customer class has a name and an order as instance variables. The name is a variable of type String. The order is an object of type Order. 2. The Order class has an orderName and an order Number as instance variables. The orderName is a variable of type String and the orderNumber is a variable of type int. a) Implement both classes with the appropriate instance variables (5 points). b) Implement constructors for both classes. The constructors should set all instance variables appropriately (10 points) Hint: Remember that objects store memory addresses and any Customer that has the same Order object will reference the same existing object in memory. Make sure you accommodate for this issue in your constructor c) Implement an accessor method (getter) for the name of the customer in the Customer class (5 points) d) Implement a mutator method (setter) for the order Number in the Order class (5 points) e) Implement a method in the Order class called checkout. This method should output"CLOSED" to the console if the order Number is "9999 otherwise the method should output "OPENED" (5 points) f) Implement a toString() method for the Order class that outputs: "The order is named: Iname of the order] and the order number is (order number) (5 points)

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!