Question

In: Computer Science

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

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

   }

}

Solutions

Expert Solution


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

   }

}


Related Solutions

[20 marks] (TestRobot.java) Design a class named Robot. The Robot class has three private data fields:...
[20 marks] (TestRobot.java) Design a class named Robot. The Robot class has three private data fields: position x, position y, and the direction (east, south, west, and north). Assume that positive x points to the east and positive y points to the south, and initially x = 0, y = 0, direction = "east". Create a no-arg constructor and another constructor which sets the three data fields. Create the accessors and mutators for the three data fields. Create a method...
[20 marks] (TestRobot.java) Design a class named Robot. The Robot class has three private data fields:...
[20 marks] (TestRobot.java) Design a class named Robot. The Robot class has three private data fields: position x, position y, and the direction (east, south, west, and north). Assume that positive x points to the east and positive y points to the south, and initially x = 0, y = 0, direction = "east". Create a no-arg constructor and another constructor which sets the three data fields. Create the accessors and mutators for the three data fields. Create a method...
Design a class named Robot. The Robot class has three private data fields: position x, position...
Design a class named Robot. The Robot class has three private data fields: position x, position y, and the direction (east, south, west, and north). Assume that positive x points to the east and positive y points to the south, and initially x = 0, y = 0, direction = "east". Create a no-arg constructor and another constructor which sets the three data fields. Create the accessors and mutators for the three data fields. Create a method named forward that...
[20 marks] (TestRobot.java) Design a class named Robot. The Robot class has three private data fields:...
[20 marks] (TestRobot.java) Design a class named Robot. The Robot class has three private data fields: position x, position y, and the direction (east, south, west, and north). Assume that positive x points to the east and positive y points to the south, and initially x = 0, y = 0, direction = "east". Create a no-arg constructor and another constructor which sets the three data fields. Create the accessors and mutators for the three data fields. Create a method...
Create a Class with Data Fields and Methods in Java. Provide a Java coding solution for...
Create a Class with Data Fields and Methods in Java. Provide a Java coding solution for the following: 1. Name the class SalonServices 2. Add private data fields: a. salonServiceDescription – This field is a String type b. price - This field is a double type 3. Create two methods that will set the field values. a. The first method setSalonServiceDescription() accepts a String parameter defined as service and assigns it to the salonServiceDescription. The method is not static b....
Create a PHP class named "User" with the following private fields: name, birthdate in yyyy/mm/dd format,...
Create a PHP class named "User" with the following private fields: name, birthdate in yyyy/mm/dd format, age, and department. In the class, include getter and setter methods to get and set the values of those variables. Author a data entry webform using HTML text input boxes and a submit button. When the user clicks on the submit button, a "User" class is instantiated and the new User object's fields are populated. The HTML input boxes correspond to the field in...
Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a...
Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a doubleannual sales amount. Methods include a constructor that requires values for both data fields, as well as get and set methods for each of the data fields. Write an application named DemoSalesperson that declares an array of 10 Salesperson objects. Set each ID number to 9999 and each sales value to zero. Display the 10 Salesperson objects. public class DemoSalesperson { public static void...
Create a class named CollegeCourse that includes data fields that hold the department (for example, ENG),...
Create a class named CollegeCourse that includes data fields that hold the department (for example, ENG), the course number (for example, 101), the credits (for example, 3), and the fee for the course (for example, $360). All of the fields are required as arguments to the constructor, except for the fee, which is calculated at $120 per credit hour. Include a display() method that displays the course data. Create a subclass named LabCourse that adds $50 to the course fee....
Create a class named Horse that contains the following data fields: name - of type String...
Create a class named Horse that contains the following data fields: name - of type String color - of type String birthYear - of type int Include get and set methods for these fields. Next, create a subclass named RaceHorse, which contains an additional field, races (of type int), that holds the number of races in which the horse has competed and additional methods to get and set the new field. ------------------------------------ DemoHorses.java public class DemoHorses {     public static void...
Create a class named Sandwich that contains the following data fields: MainIngredient - of type String...
Create a class named Sandwich that contains the following data fields: MainIngredient - of type String Bread - of type String Price - of type Double Include get and set methods for these fields. The methods should be prefixed with 'get' or 'set' respectively, followed by the field name using camel case. For example, setMainIngredient. Use the application named TestSandwich that instantiates one Sandwich object and demonstrates the use of the set and get methods to test your class. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT