In: Computer Science
INVENTORY CLASS
You need to create an Inventory class containing the private data fields, as well as the methods for the Inventory class (object).
Be sure your Inventory class defines the private data fields, at least one constructor, accessor and mutator methods, method overloading (to handle the data coming into the Inventory class as either a String and/or int/float), as well as all of the methods (methods to calculate) to manipulate the Inventory class (object).
The data fields in the Inventory class include the inventory product number (int), inventory product description (String), inventory product price (float), inventory quantity on hand (int), inventory quantity on order (int), and inventory quantity sold (int).
The Inventory class (.java file) should also contain all of the static data fields, as well as static methods to handle the logic in counting all of the objects processed (counter), as well as totals (accumulators) for the total product inventory and the total product inventory dollar value.
Your Inventory class .java should also contain all of the methods in order to calculate the current product inventory and the dollar value of the inventory product, as well as handling inventory product levels.
In order to calculate the current product inventory, the formula is inventory quantity on hand plus inventory quantity on order minus inventory quantity sold. In order to calculate the dollar value of the inventory product, the formula is inventory product price * (inventory quantity on hand + inventory quantity on order – inventory quantity sold).
A message should be generated and displayed to the user when the inventory product should be ordered if the current product inventory is less than 50 products. For data type float, show the output precision to two decimal places.
The Inventory class should not contain any computer programming code related to inputting of the data or outputting or displaying of the information for this should be handled by the GUI (Graphical User Interface). No GUI programming code should be contained in the Inventory class (.java) file.
General Format of a User-Defined Class
private data fields
final static constants (rates for example)
static programmer-defined variables for counters/accumulators
one or more constructors (overloaded constructors also)
mutator and accessor methods for the private data fields
overloaded mutators to handle data coming into the class in a different data type
methods to calculate and any other methods necessary
methods to add/return for counter(s)
methods to add/return for accumulator(s)
may also want to add the toString method to the Inventory class to show the objects contents.
The Inventory class (.java file) must be a separate .java file from the GUI .java file(s).
GRAPHICAL USER INTERFACE(S)
Students are to create GUI (Graphical User Interface) programming techniques via a separate class (.java file) (you can design more than one .java file but only one is required) to interface with the Inventory .java class.
All of the Java statements must be written by the student. In other words, students are NOT allowed to use an interface in an IDE (Interactive Development Environment) that generates the Java code automatically.
Also, students are NOT allowed to use the API (Application Programming Interface) classes Scanner or JOptionPane for input. Students are permitted to use the JOptionPane class to display all of the inventory information. Students are to use labels, button(s), radio button(s), check box(es), menus, sliders, etc., to create the GUI.
INPUT DATA via GUI
For each inventory product object, your GUI must be able to accept the data from the user’s screen and interface with the Inventory class. The input data fields in the Inventory class include the inventory product number (int), inventory product description (String), inventory product price (float), inventory quantity on hand (int), inventory quantity on order (int), and inventory quantity sold (int). All of these fields should be defined as private in the Inventory class.
Include data validation programming techniques (using try and catch statements, for example, to validate the numeric data fields via NumberFormatException).
Make up test data when inputting the inventory data for each object.
OUTPUT DETAILED INFORMATION (for each inventory object) via the GUI
For each inventory object, the program should output the following detailed information: inventory product number, inventory product description, inventory product price, inventory quantity on hand, inventory quantity on order, inventory quantity sold, current product inventory, as well as the dollar value of the inventory product.
Students can use the JOptionPane class to display each inventory product information.
Be sure to verify all of the information generated.
Your IIS should allow the user to continue to generate individual inventory information for each inventory product until the user decides to stop the program (the user clicks the EXIT button in the GUI, for example).
OUTPUT SUMMARY INFORMATION (Counter and Accumulators) via the GUI
When there are no more inventory product objects to process (the user clicks the EXIT button in the GUI, for example), the IIS program should output the following summary information.
Your program should display the number of objects processed (counter).
Your program should also display accumulators (totals) of the total product inventory of all of the inventory products, as well as the total dollar value of all of the inventory products.
OTHER PROGRAMMING INFORMATION
You can use the internet and use a search engine such as http://www.google.com to help in resolving problems you may encounter as you are working on your solution.
DOCUMENTATION VIA IDE
Students may want to generate documentation of the Inventory class file contents via the IDE (for example, in jGRASP, use File, Generate Documentation and in NetBeans, use Run, Generate JavaDoc) for their reference only. You do not have to submit the generated documentation with this assignment.
started code below
// Inventory.java
public class Inventory {
private int productNumber;
private String productDescription;
private double productPrice;
private int quantityOnHand;
private int quantityOnOrder;
private int quantitySold;
private static int counter;
/**
* @param productNumber
* @param productDescription
* @param productPrice
* @param quantityOnHand
* @param quantityOnOrder
* @param quantitySold
*/
public Inventory(int productNumber, String
productDescription,
double
productPrice, int quantityOnHand, int quantityOnOrder,
int
quantitySold) {
this.productNumber =
productNumber;
this.productDescription =
productDescription;
this.productPrice =
productPrice;
this.quantityOnHand =
quantityOnHand;
this.quantityOnOrder =
quantityOnOrder;
this.quantitySold =
quantitySold;
counter++;
}
/**
* @return the productNumber
*/
public int getProductNumber() {
return productNumber;
}
/**
* @param productNumber
* the productNumber to set
*/
public void setProductNumber(int productNumber)
{
this.productNumber =
productNumber;
}
/**
* @return the productDescription
*/
public String getProductDescription() {
return productDescription;
}
/**
* @param productDescription
* the productDescription to set
*/
public void setProductDescription(String
productDescription) {
this.productDescription =
productDescription;
}
/**
* @return the productPrice
*/
public double getProductPrice() {
return productPrice;
}
/**
* @param productPrice
* the productPrice to set
*/
public void setProductPrice(double productPrice)
{
this.productPrice =
productPrice;
}
/**
* @return the quantityOnHand
*/
public int getQuantityOnHand() {
return quantityOnHand;
}
/**
* @param quantityOnHand
* the quantityOnHand to set
*/
public void setQuantityOnHand(int quantityOnHand)
{
this.quantityOnHand =
quantityOnHand;
}
/**
* @return the quantityOnOrder
*/
public int getQuantityOnOrder() {
return quantityOnOrder;
}
/**
* @param quantityOnOrder
* the quantityOnOrder to set
*/
public void setQuantityOnOrder(int quantityOnOrder)
{
this.quantityOnOrder =
quantityOnOrder;
}
/**
* @return the quantitySold
*/
public int getQuantitySold() {
return quantitySold;
}
/**
* @param quantitySold
* the quantitySold to set
*/
public void setQuantitySold(int quantitySold) {
this.quantitySold =
quantitySold;
}
public int currentProductInventory() {
return (quantityOnHand +
quantityOnOrder) - quantitySold;
}
public static int
totNoofProductsInInventory()
{
return counter;
}
public double currentProductInventoryValue() {
return ((quantityOnHand +
quantityOnOrder) - quantitySold)
* productPrice;
}
public void CheckToOrderInventory()
{
if(currentProductInventory()<50)
{
System.out.println("You have to Order Inventory");
}
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Inventory [productNumber="
+ productNumber
+ ", productDescription=" +
productDescription
+ ", productPrice=" + productPrice + ",
quantityOnHand="
+ quantityOnHand + ", quantityOnOrder=" +
quantityOnOrder
+ ", quantitySold=" + quantitySold + "]";
}
}
===================================
public class Test {
public static void main(String[] args)
{
Inventory i1=new
Inventory(1111,"Laptops",1200,340,100,200);
Inventory i2=new
Inventory(1213,"Mobile",350,100,50,30);
System.out.println("No of
"+i1.getProductDescription()+" in Inventory
:"+i1.currentProductInventory());
System.out.println("Total Cost of
"+i1.getProductDescription()+" in Inventory
:"+i1.currentProductInventoryValue());
System.out.println("No of
"+i2.getProductDescription()+" in Inventory
:"+i2.currentProductInventory());
System.out.println("Total Cost of
"+i2.getProductDescription()+" in Inventory
:"+i2.currentProductInventoryValue());
System.out.println("No of Product
Types in Inventory
:"+Inventory.totNoofProductsInInventory());
}
}
public class Test {
public static void main(String[] args) {
Inventory i1=new
Inventory(1111,"Laptops",1200,340,100,200);
Inventory i2=new
Inventory(1213,"Mobile",350,100,50,30);
System.out.println("No of
"+i1.getProductDescription()+" in Inventory
:"+i1.currentProductInventory());
System.out.println("Total Cost of
"+i1.getProductDescription()+" in Inventory
:"+i1.currentProductInventoryValue());
System.out.println("No of
"+i2.getProductDescription()+" in Inventory
:"+i2.currentProductInventory());
System.out.println("Total Cost of
"+i2.getProductDescription()+" in Inventory
:"+i2.currentProductInventoryValue());
System.out.println("No of Product
Types in Inventory
:"+Inventory.totNoofProductsInInventory());
}
}