Using Java: Create an application for managing inventory data, consisting of two classes: InvTracker and InvItem, both
Question:
Using Java:
Create an application for managing inventory data, consisting of two classes: InvTracker and InvItem, both contained in the InvTracker.java file. Submit your source code: the InvTracker.java file. The design requirements are:
1) InvTracker 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) InvTracker 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 String’s 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. Someone else will copy a standard script into the main method and use it to call the various methods & check their operation.
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: These are primarily methods for reading (getting) or writing (setting) data fields in InvItem. For example, a get method for id should be named getId, return a long (same type as id), and accept no parameters. The set method for id should be named setId, return void, and accept a parameter long (same type as id) which will be the new value for id.
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.
Additional Constraints
The program should be implemented as a single source code file. All data members should be declared as private; all methods (except the main method) should be declared without any visibility modifiers.