Kindly help me in writing these methods in classes.
The Customer class should be updated with:
- A new instance variable, which is a partially filled array of Orders, and stores only the 3 most recent orders. The size of the array must be 3, and you can define a constant for that similarly to what we have done earlier.
- Adjust the constructor to initialize the array of Orders. It should be empty at the beginning.
- An updateRecentOrders(Order) method which takes a new Order as a parameter and adds it to the array of most recent orders. The rank of the orders should always be preserved, in such a way that we can print them from most recent to oldest. When the array is already full, update the array so that the oldest order gets removed and the most recent one gets added in, conserving the full ordering. This method should be very short. If you do it in more than 4-5 lines of code, rethink your approach.
- A getStringRecentOrders() method which returns a String representation of the most recent orders, preceded by "Recent orders of customer [Customer name]". Follow the formatting shown in the example below exactly. The orders must be ordered from most recent to oldest.