I feel as if I have gone over this code until my eyes are bleeding. I am missing something, and I cannot seem to locate my problem. I am supposed to use an array to store my items, my output should display my items one at a time, and should also display the value of the entire inventory. I have managed to eliminate all of my compiler errors, but my modifications are not showing in the output. Any assistance is greatly appreciated. Thank you!
// This Inventory program is an application that is designed to store and maintain a
// media collection. Inventory houses an array of DVDs, along with attributes of those DVDs.
// These attributes are, item number, item title, stock available, item price, and total value
// of each. Inventory information is then displayed for the user.
public class Invent2 // declare class inventory, which houses arrays
{
public static void main(String args [])
{
DVD dvd;
// declare and initializes array elements. declare structure of attributes for constructor.
dvd = new DVD(1, "Pulp Fiction", 8, 12.99);
System.out.println(dvd);
dvd = new DVD(2, "Resevoir Dogs", 9, 12.99);
System.out.println(dvd);
dvd = new DVD(3, "Four Rooms", 4, 10.99);
System.out.println(dvd);
dvd = new DVD(4, "Kill Bill Vol. One", 5, 15.99);
System.out.println(dvd);
dvd = new DVD(5, "Kill Bill Vol. Two", 5, 17.99);
System.out.println(dvd);
dvd = new DVD(6, "Drugstore Cowboy", 2, 10.99);
System.out.println(dvd);
dvd = new DVD(7, "Tool - Live Aenima", 4, 19.99);
System.out.println(dvd);
dvd = new DVD(8, "How The West Was Won", 6, 23.95);
System.out.println(dvd);
dvd = new DVD(9, "Concert for Antigua", 9, 20.00);
System.out.println(dvd);
dvd = new DVD(10, "Delta Blues: E-chord", 2, 24.99);
System.out.println(dvd);
} //end main
} // end class Inventory2
class DVD // declare clas DVD
{
private int dvdItem; // declare variables
private String dvdTitle;
private int dvdStock;
private double dvdPrice;
public DVD(int item, String title, int stock, double price) // declare constructor of four arguments
{
dvdItem = item; // initialize constructor arguments
dvdTitle = title;
dvdStock = stock;
dvdPrice = price;
} //end four-argument constructor
// set DVD Item
public void setDvdItem(int item)
{
dvdItem = item;
} //end method set Dvd Item
//return DVD Item
public int getDvdItem()
{
return dvdItem;
} //end method get Dvd Item
//set DVD Title
public void setDvdTitle(String title)
{
dvdTitle = title;
} //end method set Dvd Title
//return Dvd Title
public String getDvdTitle()
{
return dvdTitle;
} //end method get Dvd Title
public void setDvdStock(int stock)
{
dvdStock = stock;
} //end method set Dvd Stock
//return dvd Stock
public int getDvdStock()
{
return dvdStock;
} //end method get Dvd Stock
public void setDvdPrice(double price)
{
dvdPrice = price;
} //end method setdvdPrice
//return DVD Price
public double getDvdPrice()
{
return dvdPrice;
} //end method get Dvd Price
//calculate inventory value
public double value()
{
return dvdPrice * dvdStock;
} //end method value
public String toString()
{
return String.format("item=%3d title=%-20s units=%d price=%.2f value=%.2f",
dvdItem, dvdTitle, dvdStock, dvdPrice, value());
}
} //end class DVD
class Inventory
{
DVD discs[] = new DVD[50];
public void addToInventory( DVD discs ) // add to inventory
{
}
public double getInventoryValue() // get total value of inventory
{
Inventory myInventory = new Inventory();
myInventory.addToInventory( new DVD(1, "The Wall", 9, 9.95));
// print out total inventory value
System.out.println( "Total value of the inventory is: " + myInventory.getInventoryValue());
return myInventory.getInventoryValue();
}
}