Question

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

in jGRASP

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).

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

}

}


/**
* @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 + "]";
}
  
}

Homework Answers

Answer #1
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());
      
      
      

   }

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please solve this problem in java. import java.util.Arrays; public class PriorityQueue { /* This class is...
Please solve this problem in java. import java.util.Arrays; public class PriorityQueue { /* This class is finished for you. */ private static class Customer implements Comparable { private double donation; public Customer(double donation) { this.donation = donation; } public double getDonation() { return donation; } public void donate(double amount) { donation += amount; } public int compareTo(Customer other) { double diff = donation - other.donation; if (diff < 0) { return -1; } else if (diff > 0) { return...
In Java Let’s say we’re designing a Student class that has two data fields. One data...
In Java Let’s say we’re designing a Student class that has two data fields. One data field, called id, is for storing each student’s ID number. Another data field, called numStudents, keeps track of how many Student objects have been created. For each of the blanks, indicate the appropriate choice. id should be   public/private   and   static/not static . numStudents should be   public/private   and   static/not static . The next three questions use the following class: class Counter {     private int...
Which method is correct to access the value of count? public class Person { private String...
Which method is correct to access the value of count? public class Person { private String name; private int age; private static int count = 0; } A. private int getCount() {return (static)count;} B. public static int getCount() {return count;} C. public int getCount() {return static count;} D. private static int getCount() {return count;} How can you print the value of count? public class Person { private String name; private int age; private static int count=0; public Person(String a, int...
I am a beginner when it comes to java codeing. Is there anyway this code can...
I am a beginner when it comes to java codeing. Is there anyway this code can be simplified for someone who isn't as advanced in coding? public class Stock { //fields private String name; private String symbol; private double price; //3 args constructor public Stock(String name, String symbol, double price) { this.name = name; this.symbol = symbol; setPrice(price); } //all getters and setters /** * * @return stock name */ public String getName() { return name; } /** * set...
<<<<<<<< I need only the UML diagram for ALL classes.Java???????????? public class House {    private...
<<<<<<<< I need only the UML diagram for ALL classes.Java???????????? public class House {    private int houseNumber;    private int bedrooms;    private int sqFeet;    private int year;    private int cost;    public House(int houseNumber,int bedrooms,int sqFeet, int year, int cost)    {        this.houseNumber = houseNumber;        this.bedrooms = bedrooms;        this.sqFeet = sqFeet;        this.year = year;        this.cost = cost;    }    public int getHouseNumber()    {        return houseNumber;    }   ...
Complete the // TODO sections in the EasyRental class. Create a method that implements an iterative...
Complete the // TODO sections in the EasyRental class. Create a method that implements an iterative sort that sorts the vehicle rentals by color in ascending order (smallest to largest) Create a method to binary search for a vehicle based on a color, that should return the index where the vehicle was found or -1 You are comparing Strings in an object not integers. Ex. If the input is: brown red white blue black -1 the output is: Enter the...
JAVA public class Purchase { private String name; private int groupCount; //Part of price, like the...
JAVA public class Purchase { private String name; private int groupCount; //Part of price, like the 2 in 2 for $1.99. private double groupPrice; //Part of price, like the $1.99 in 2 for $1.99. private int numberBought; //Total number being purchased. public Purchase () { name = "no name"; groupCount = 0; groupPrice = 0; numberBought = 0; } public Purchase (String name, int groupCount, double groupPrice, int numberBought) { this.name = name; this.groupCount = groupCount; this.groupPrice = groupPrice; this.numberBought...
public class Date {    private int month;    private int day;    private int year;...
public class Date {    private int month;    private int day;    private int year;    public Date( int monthValue, int dayValue, int yearValue )    {       month = monthValue;       day = dayValue;       year = yearValue;    }    public void setMonth( int monthValue )    {       month = monthValue;    }    public int getMonth()    {       return month;    }    public void setDay( int dayValue )    {       day =...
Modify the Employee9C superclass so that is an abstract superclass with a constructor to set its...
Modify the Employee9C superclass so that is an abstract superclass with a constructor to set its variables (firstName and lastName). It should contain an abstract method called payPrint. Below is the source code for the Employee9C superclass: public class Employee9C {    //declaring instance variables private String firstName; private String lastName; //declaring & initializing static int variable to keep running total of the number of paychecks calculated static int counter = 0;    //constructor to set instance variables public Employee9C(String...
Hello. I have an assignment that is completed minus one thing, I can't get the resize...
Hello. I have an assignment that is completed minus one thing, I can't get the resize method in Circle class to actually resize the circle in my TestCircle claass. Can someone look and fix it? I would appreciate it! If you dont mind leaving acomment either in the answer or just // in the code on what I'm doing wrong to cause it to not work. That's all I've got. Just a simple revision and edit to make the resize...