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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started