Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

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

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions

Question

3. What are potential solutions?

Answered: 1 week ago