A InventoryOnShelf object will contain two private fields, itemOnShelflist, an array of (up to 5) ItemOnShelf objects, and size, an integer to keep track of the number of ItemonShelf objects held in the InventoryOnShelf object, and should contain the following methods: • public InventoryOnShelf() //constructor to create new empty InventoryOnShelf object (containing an empty array of ItemOnSelf[5] null objects & size = 0).

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 9E
icon
Related questions
Question

This is in Java. The assignement is to create a class.

I am confused on how to write de code for an array that is up to 5. Also I am confused regarding how to meet the requirements of the constructor. 

This is what I have.

public class InventoryOnShelf {

//fields

private int[] itemOnShelfList [];

private int size;

public InventoryOnShelf() {

}

 

A InventoryOnShelf object will contain two private fields, itemOnShelflist, an array of (up to 5) ItemOnShelf
objects, and size, an integer to keep track of the number of ItemonShelf objects held in the InventoryOnShelf
object, and should contain the following methods:
• public InventoryOnShelf()
//constructor to create new empty InventoryOnShelf object (containing an empty array of ItemOnSelf[5]
null objects & size = 0).
Transcribed Image Text:A InventoryOnShelf object will contain two private fields, itemOnShelflist, an array of (up to 5) ItemOnShelf objects, and size, an integer to keep track of the number of ItemonShelf objects held in the InventoryOnShelf object, and should contain the following methods: • public InventoryOnShelf() //constructor to create new empty InventoryOnShelf object (containing an empty array of ItemOnSelf[5] null objects & size = 0).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Passing Array as Argument
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT