Question: In java create an Inventory class. It contains a 100 element Product array as a private instance variable. The Inventory class should also have a
In java create an Inventory class. It contains a 100 element Product array as a private instance variable. The Inventory class should also have a private instance variable that keeps track of how many Product objects you have in the array. That variable should have a 'get' method, but no 'set method. Give the array 'get' and 'set' methods as well -- so you can work with the elements in the array. The array's 'get' method takes an index number argument and returns the Product object from that position in the array. The array's 'set' method takes a Product object argument and assigns that object to the next available position in the Product array. Have another class with a main method that instantiates an Inventory object and loads several Product objects into the array. Then use a loop to traverse through the Inventory object's array and display the data in each element of the array that actually contains Product objects.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
