Modify the Inventory Program:
Create a new method that calculates the value of the entire inventory.
Create another method that sorts all of the array items alphabetically (ascending order) by the product name.
o The application should declare and use an array to store 5 items. This array will represent your product’s inventory. Use the constructor in your Supplier class to create 3 new objects. Use the constructor in your Printer class to create 2 new objects. Note: You will provide the values for the constructor yourself. You will not prompt the user to enter this data. Add the objects created in step 2 to your array. Call your sortArray method to sort the array.
Display the following information for EACH item in your array:
o the product number;
o the name of the product,
o the number of units in stock,
o the price of each unit;
o and the value of the inventory (the number of units in stock multiplied by the price of each unit)
o Supplier Name *
o Restock Fee *
o Create a subclass of the selected inventory item. Recall that the extends keyword is used to create an inheritance relationship.
The subclass and existing class must past the is-a test.
The subclass must declare one applicable attribute along with the appropriate get and set methods.
The subclass must declare a method to calculate the restocking fee. The restocking fee should be calculated as 5% of the item’s price.
o The application’s output should display all of the items in the inventory sorted (use the new sort method) and include the item number, the name of the product, the number of units in stock, the price of each unit, the new attribute, the restock fee and the value of the inventory of that product. In addition, the output should display the value of the entire inventory (use the new method to achieve this). All dollar values should be displayed as currency (i.e. $D,DDD.CC). Note: You must use an Array to store your inventory items, the use of any other data structure will result in a significant point deduction.
I think the code I have written for the object is correct, Monitors.java, since it compiles, but I will include it as well. I am having trouble with the main programming to include the array and then it has to print the values and calculations and as such it is unfinished. If someone would be so kind as to point me in the right direction or offer advice, I'd be very much obliged. Thanks in advance.
// Monitors.java
// Inventories monitors by the item number, the name of the product,
// the number of units in stock, and the price of each unit for the
// selected product
// Stephanie Masech
// 3/4/2012
public class Monitors
{
private int idNumber;
private String productName;
private int productCount;
private double productPrice;
public String storeName;
public Monitors (int number, String name, int count, double price)
{
this.idNumber = number;
this.productName = name;
this.setProductCount(count);
this.setProductPrice(price);
}
public double calculateValue()
{
return productCount * productPrice;
}
public void setIdNumber (int number)
{
this.idNumber = idNumber;
}
public double getIdNumber()
{
return idNumber;
}
public void setProductName (String name)
{
this.productName = productName;
}
public String getProductName()
{
return productName;
}
public void setProductCount (int count)
{
this.productCount = count;
}
public double getProductCount()
{
return productCount;
}
public void setProductPrice (double price)
{
this.productPrice = price;
}
public double getProductPrice()
{
return productPrice;
}
}
class Store extends Monitors{
private String storeName;
public Store(int number, String name, int count, double price, String storeName)
{
super(number, name, count, price);
this.storeName = storeName;
Monitors example4 = new Monitors(8946, "Acer 19'' Plasma Flatpanel", 3, 124.79, "Walmart");
Monitors example5 = new Monitors(9406, "Samsung 20'' LCD Flatpanel", 8, 191.99, "Best Buy");
}
}
// InventoryPart1.java
// Inventories monitors by the item number, the name of the product,
// the number of units in stock, and the price of each unit for the
// selected product
// Stephanie Masech
// 3/4/2012
import java.util.Arrays;
public class InventoryPart2
{
double total;
public static void main( String[] args )
{
Monitors[] example = new Monitors[5];
Monitors example1 = new Monitors(8701, "Dell 22'' LCD Flatpanel", 6, 156.99);
Monitors example2 = new Monitors(9049, "HP 19'' CRT", 2, 120.99);
Monitors example3 = new Monitors(3952, "LG 21'' LED Superflat", 9, 225.99);
}
System.out.println( "Information on monitors." );
System.out.println();
System.out.printf( "%s %.0f\n", "Product ID number: ",
inventory.getIdNumber() );
System.out.printf( "%s %s\n", "Product name: ",
inventory[].getProductName() );
System.out.printf( "%s %.0f\n", "Total in stock: ",
inventory[].getProductCount() );
System.out.printf( "%s %$.2f\n", "Price per unit: ",
inventory[].getProductPrice() );
System.out.printf( "%s %$.2f\n", "Total price of stock: ",
inventory[].getTotalPrice() );
System.out.println();
}