INVENTORY CLASS You need to create an Inventory class containing the private data fields, as well as...

Free

80.2K

Verified Solution

Question

Programming

INVENTORY CLASS

You need to create an Inventory class containing the privatedata fields, as well as the methods for the Inventory class(object).

Be sure your Inventory class defines the private data fields, atleast one constructor, accessor and mutator methods, methodoverloading (to handle the data coming into the Inventory class aseither 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 inventoryproduct 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 thestatic data fields, as well as static methods to handle the logicin counting all of the objects processed (counter), as well astotals (accumulators) for the total product inventory and the totalproduct inventory dollar value.

Your Inventory class .java should also contain all of themethods in order to calculate the current product inventory and thedollar value of the inventory product, as well as handlinginventory product levels.

In order to calculate the current product inventory, the formulais inventory quantity on hand plus inventory quantity on orderminus inventory quantity sold. In order to calculate the dollarvalue of the inventory product, the formula is inventory productprice * (inventory quantity on hand + inventory quantity on order –inventory quantity sold).   

A message should be generated and displayed to the user when theinventory product should be ordered if the current productinventory is less than 50 products. For data type float, show theoutput precision to two decimal places.

The Inventory class should not contain any computerprogramming code related to inputting of the data or outputting ordisplaying of the information for this should be handled by the GUI(Graphical User Interface). No GUI programming code should becontained in the Inventory class (.java) file.

General Format of aUser-Defined Class

private data fields

final static constants (rates forexample)

static programmer-defined variablesfor counters/accumulators

one or more constructors (overloadedconstructors also)

mutator and accessor methods for theprivate data fields

overloaded mutators to handle datacoming into the class in a different data type

methods to calculate and any othermethods necessary

methods to add/return forcounter(s)

methods to add/return foraccumulator(s)

may also want to add the toString method to the Inventory classto show the objects contents.

The Inventory class (.java file) must be a separate .java filefrom 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 candesign more than one .java file but only one is required) tointerface with the Inventory .java class.

All of the Java statements must be written by the student. Inother words, students are NOT allowed to use an interface in an IDE(Interactive Development Environment) that generates the Java codeautomatically.

Also, students are NOT allowed to use the API(Application Programming Interface) classes Scanner or JOptionPanefor input. Students are permitted to use the JOptionPane class todisplay all of the inventory information. Students are to uselabels, 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 toaccept the data from the user’s screen and interface with theInventory class. The input data fields in the Inventory classinclude the inventory product number (int), inventory productdescription (String), inventory product price (float), inventoryquantity on hand (int), inventory quantity on order (int), andinventory quantity sold (int). All of these fields should bedefined as private in the Inventory class.

Include data validation programming techniques (using try andcatch statements, for example, to validate the numeric data fieldsvia NumberFormatException).

Make up test data when inputting the inventory data for eachobject.

OUTPUT DETAILED INFORMATION (for each inventory object)via the GUI

For each inventory object, the program should output thefollowing detailed information: inventory product number, inventoryproduct description, inventory product price, inventory quantity onhand, inventory quantity on order, inventory quantity sold, currentproduct inventory, as well as the dollar value of the inventoryproduct.

Students can use the JOptionPane class to display each inventoryproduct information.

Be sure to verify all of the information generated.

Your IIS should allow the user to continue to generateindividual inventory information for each inventory product untilthe user decides to stop the program (the user clicks the EXITbutton in the GUI, for example).

OUTPUT SUMMARY INFORMATION (Counter and Accumulators)via the GUI

When there are no more inventory product objects to process (theuser clicks the EXIT button in the GUI, for example), the IISprogram should output the following summary information.

Your program should display the number of objects processed(counter).

Your program should also display accumulators (totals) of thetotal product inventory of all of the inventory products, as wellas the total dollar value of all of the inventory products.

OTHER PROGRAMMING INFORMATION

You can use the internet and use a search engine such ashttp://www.google.com to help in resolving problems you mayencounter as you are working on your solution.

DOCUMENTATION VIA IDE

Students may want to generate documentation of the Inventoryclass 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 generateddocumentation 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, StringproductDescription,
           doubleproductPrice, int quantityOnHand, int quantityOnOrder,
           intquantitySold) {
       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(StringproductDescription) {
       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 inttotNoofProductsInInventory()
   {
       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=newInventory(1111,\"Laptops\",1200,340,100,200);
       Inventory i2=newInventory(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 ProductTypes in Inventory:\"+Inventory.totNoofProductsInInventory());
      
      
      

   }

}

Answer & Explanation Solved by verified expert
3.7 Ratings (702 Votes)


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());
      
      
      

   }

}


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students