Question: JAVA Programming Create a program for managing inventory data. The class name should be InvTracker2, an underscore, and your NetID run together; for example, if
JAVA Programming
Create a program for managing inventory data. The class name should be InvTracker2, an underscore, and your NetID run together; for example, if your NetID is abcde6, your class name is InvTracker2_abcde6. For this assignment, we will add code to provide basic functions. The design requirements are:
1) InvTracker2 data members:
a) an array named items of type InvItem, with no specific size
b) an int named count for the InvItem array size
2) InvTracker2 methods:
a) inStock: takes a long as a parameter, returns a boolean. Returns true if an element in items has id equal to the parameter long and returns false otherwise.
b) stockAmount: takes a long as a parameter, returns an int. Returns the quantity attribute of the element in items with id equal to the parameter long and returns -1 otherwise.
c) add: takes a long and an int as parameters, returns void. If an element in items has id matching the parameter long, the parameter int will be added to its quantity attribute. Otherwise, a new InvItem will be created with the parameter long as its id and the parameter int as its quantity and count will be incremented.
d) remove: takes a long and an int as parameters, returns void. If an element in items has id matching the parameter long and has quantity equal to or greater than the parameter int, the parameter int will be subtracted from its quantity attribute.
e) delete: takes a long as a parameter, returns void. If an element in items has id matching the parameter long, that InvItem object will be deleted, any InvItems at subsequent indexes will be moved to one index lower, and count will be decremented.
f) search: takes a String as a parameter, returns an array of type InvItem. This method will create an InvItem array containing all InvItems from items whose name attributes contain the text of the parameter String. This does not require an exact match use Strings indexOf method.
g) a constructor method that takes no parameters, creates items as an array with size 1000, and sets count equal to zero.
h) a main method that creates a InvTracker2 object. If desired, you may also include a loop in the main method to accept and process user commands for testing your code. However, this is not required for the assignment.
3) The InvItem class should be placed after and outside the InvTracker class definition, as:
public class InvTracker { // code goes here} class InvItem {//more code goes here}
Note that only the InvTracker class should be public!
4) InvItem data members:
a) a long named id
b) a String named name
c) an int named quantity
5) InvItem methods:
a) get & set methods for id (resp. return or accept a long). Add code to read or write the id attribute.
b) get & set methods for name (resp. return or accept a String). Add code to read or write the name attribute.
c) get & set methods for quantity (resp. return or accept an int). Add code to read or write the quantity attribute.
d) a constructor method that takes a long as a parameter, creates an InvItem with id equal to the parameter long, name equal to an empty String, and quantity equal to 0.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
