Final answer:
Create a public class called Last4Ordered that has two public methods: add and last. The add method adds values to an array and the last method returns the last four values added. Use an array to store the last four values and update it accordingly.
Step-by-step explanation:
To implement the Last4Ordered class, you can use an array to store the last four values added. Create an instance variable last4 as an array of size 4, initialized with all zeros. The add method should take a value as a parameter and update the array by shifting values to the left and adding the new value at the end. The last method should simply return the last4 array.
Learn more about Last4Ordered class