Question: Hello I'm having difficulty understanding this problem with my study guide question for my Intermediate Java class with ArrayList. I cannot figure out how to

Hello I'm having difficulty understanding this problem with my study guide question for my Intermediate Java class with ArrayList. I cannot figure out how to use the ArrayList to maintain the orders. Any help will be greatly appreciated.

Modify the program so that when an order is added using the application that an ArrayList of Orders is maintained in the main class. Note that the list object will be accessed from the static methods of the main class and would need to be static (though it should still be private). Each time the addOrder method is called the new order object should be added to this collection.

Add option 3 which will show all of the orders that have been created since the program started running.

Using a HashSet, add option 4 which will show the distinct customers that have been added to the system. Loop through each order and add the Customer object to a HashSet collection.

To allow this collection of Customers to not have duplicates, you will need to implement the hashcode() and equals(Object e) methods. After adding all of the customers to the HashSet, loop through the HashSet and show each customer. You may need to do a bit of research to figure this out. A customer is deemed to be the same if they have the same name. Note that Netbeans has a good tool to generate the HashCode and equals methods.

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!