The Stockltem class is an abstract class and is intended to be accessed only through Inventory, so should have package scope.
Create an interface Identifiable for objects that have a unique identifier stored as a String. (Identifiable must define method getldentifier and method setldentifier) Each Stockltem must he an Identifiable object and also store the quantity in stock as an int and the unit price as a float.
The constructor of Inventory must have one argument that specifies the maximum number of stock items. The Inventory class must have at least the following public static methods and a main method to test them:
• public int add( String Id, int quantity, float price)
Adds a stock item. If an item with the specified ID already exists, the method display an error message on the message area (this area is a Text Area at your GUI used to display the messages and data on it). Otherwise, the method creates a new Stockltem object and adds it to the array. The return value is the number of items recorded in the array when the operation is complete.
• public int remove ( String Id)
Removes a stock item. If no items match the specified ID, the method displays an error message on the message area. The return value is the number of items recorded in the array when the operation is complete.
• public void setQuantity( String Id, int quantity)
Changes the recorded number in stock for the item that matches the specified ID. If no items match the specified ID, the method shows an error message on the message area. If the quantity is less than 0, the methods shows an error message as well.
• public int getQuantity( String id)
Returns the quantity for the item that matches the specified ID. If no items match the specified ID, the method shows an error message on the message area.
• public void setPrice( String id, float price)
Changes the recorded price for the item that matches the specified ID to the specified price. If no items match the specified ID, the method shows an error message. If the price is less than 0.0, the method shows and error message as well..
• public float getPrice( String Id )
Returns the price for the item that matches the specified ID. If no items match the specified ID, the method shows an error message.
• public void stockReport()
Prints an inventory report that states how many stock items the store has in inventory and then prints the ID, Category, quantity, and price of each item.
• public StockItem listItems(int category);
• public StockItem listItems(Date exp_date);
• public StockItem listItems(int style);
• public StockItem listItems(int Size);
• public StockItem listItems(int type);
The above overloaded methods return a sub list based on the user request.
The StockItem class is an abstract class implements comparable and Identifiable interfaces has the following attributes:
id : string
name: string (general name)
description: string (short description)
category: int (the value should one of the following Food, Electrical Device, and Dress) as described in the Inventory class above.
Since all the stock items should be categorized, then the class should not have a default constructor and should have a non-default constructor with the following signature
StockItem( int category); BUT why???, find the answer.
The class should have the set/get methods as well.
Stock items are the same if they have the same id, therefore you have to override the equals method inherited for Object class.
You should override the toString method to give a summary of the item.
Stock items are compared based on their prices. So the compreTo methods return 0 if two items have the same price, positive and negative value otherwise.
The Food is a concrete class item has an attributes that capture the food expire date of type date. The Electrical Item is a concrete class has the following additional attributes, model of type string, type which could be one of the following (computer, audio-video player, mobile phone, and other) these types could be constant class members.
The Dress item concrete class has the following additional attributes size of type integer, colour which could be one of the following (white, black, blue, yellow, green and read) these types could be constant class members, style attribute which could be one of the following (shirt, trouser, jacket, and shoe) these types could be constant class members.
You should develop the following GUI
The add Button open a Dialog shows the following panel to add an item its category is Dress.
In your GUI should allow the user to view an Item and update its details.
The Update Dialog should display the following Panel
Recently Asked Questions
- Able Corporation has Project A with the following cash flows and a 6.8% cost of money: Numbers in parentheses are outflows. Both Year 0 and Year 3 cash flows
- You have a blue gumball that weighs 4.289 g. You soak the gumball in exactly 10.17 mL of NANOpure™ water (ultrapure water) for 50 seconds at room temperature
- Which action is associated with risk acceptance? Abandon the activities that create the risk. Put controls in place to mitigate potential negative impact. Bind