Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q3: a- Write a class named Inventory that has fields (instance variable) for item description and a unit number. The class should have three constructors

image text in transcribed

Q3: a- Write a class named Inventory that has fields (instance variable) for item description and a unit number. The class should have three constructors and appropriate accessor and mutator methods. First constructor is no-argument constructor. The second constructor accepts a String argument which is assigned to the description field. The third constructor accepts a String argument which is assigned to the description field, and an int argument which is assigned to the unit's field Then write a program that creates four Inventory objects and stores them in an Array. Also, write getltemsInfo method which accepts an Inventory array as an argument. In this method the user enters data for each Inventory object. Use a loop to display the contents of each object in the Array b-In the main method, use the same class inventory form Q3 (a) to create three inventory objects. The first inventory object has 10 units, the second inventory object has 20 units and the third object has 30 units. Assign different string arguments to the description field of those three inventory objects. Write a method called totUnits which takes variable number arguments of Inventory objects and returns the total of their units.Call method totUnits with one argument, then with two arguments and finally with three arguments. Display the returned value after eaclh method call

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions