Inventory Program - Won't complie | Newbie | | Join Date: Mar 2008 Location: Dublin, Ca
Posts: 9
| |
I am having trouble figuring out my code and was hoping someone could point me in the right direction. Below is my code what I need to due is create a method to add and display the value of the entire inventory. I have what I think is the correct code but it's not working. Help is greatly appreciated -
class Inventory3
-
{
-
public static final int MAXIMUM_ITEMS = 4;
-
private static Product product[] = new Product[MAXIMUM_ITEMS];
-
-
public static void main(String args[])
-
{
-
buildInventory();
-
getInventory();
-
}
-
-
// Build the inventory, storing 10 different products.
-
public static void buildInventory()
-
{
-
product[0] = new Product(1001, "Megaforce", 10, 18.95);
-
product[1] = new Product(502, "Abyss", 25, 12.95);
-
product[2] = new Product(1003, "Deep Impact", 65, 21.95);
-
product[3] = new Product(750, "Forest Gump", 28, 7.95);
-
Arrays.sort(product);
-
}
-
-
public static void getInventory()
-
{
-
System.out.println(); // blank line
-
System.out.println("Welcome to DVD Inventory 1.0"); //display header
-
System.out.println();
-
for(int i = 0; i < product.length; i++)
-
{
-
System.out.println("Item Number: " + product[i].getItemNumber());
-
System.out.println("Item Name: " + product[i].getItemName());
-
//System.out.println("Director: " + product[i].getDirector());
-
System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
-
System.out.println("Item Price: $" + product[i].getItemPrice());
-
System.out.println("Value of Inventory: $" + product[i].getValue());
-
System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
-
System.out.println();
-
-
}
-
}
-
-
public double entireValue()
-
{
-
double value = 0;
-
for (int i = 0; i < Product; i++)
-
{
-
value = value + product[i].getValue();
-
}
-
return value;
-
}
-
-
public void display()
-
{
-
System.out.printf("Total Value is: $%.2f\n\n", entireValue());
-
}
-
-
-
} //end Class Inventory3
-
Below is the error I get when I try to complie this into my code
Inventory3.java:104: cannot find symbol
symbol : variable Product
location: class Inventory3
for (int i = 0; i < Product; i++)
^
1 error
here is my complete working code so far -
import java.util.Arrays;
-
-
class Product implements Comparable
-
{
-
private long itemNumber; // class variable that stores the item number
-
private String itemName; // class variable that stores the item name
-
private long invQuantity; // class variable that stores the quantity in stock
-
private double itemPrice; // class variable that stores the item price
-
-
public Product(long number, String name, long quantity, double price) // Constructor for the Supplies class
-
{
-
itemNumber = number;
-
itemName = name;
-
invQuantity = quantity;
-
itemPrice = price;
-
}
-
-
public long getItemNumber() { return itemNumber; } // Method to set item number
-
public String getItemName() { return itemName;} // Method to set the item name
-
public long getInvQuantity() { return invQuantity;} // Method to set the quantity in stock
-
public double getItemPrice() { return itemPrice;} // Method to get the item Price
-
-
public double getValue() { return (double) invQuantity * itemPrice; } // Method to calculate the valure of the inventory
-
-
public int compareTo(Object o)
-
{
-
Product p = null;
-
try
-
{
-
p = (Product) o;
-
}
-
-
catch (ClassCastException cE)
-
{
-
cE.printStackTrace();
-
}
-
return itemName.compareTo(p.getItemName());
-
}
-
} //end class Product
-
-
class DVD extends Product
-
{
-
public DVD(int itemNumber, String itemName, long invQuantity, double itemPrice)
-
{
-
super(itemNumber, itemName, invQuantity, itemPrice);
-
}
-
-
public double getValue()
-
{
-
double inventoryValue = super.getValue();
-
return (inventoryValue * 1.05);
-
}
-
}
-
-
class Inventory3
-
{
-
public static final int MAXIMUM_ITEMS = 4;
-
private static Product product[] = new Product[MAXIMUM_ITEMS];
-
-
public static void main(String args[])
-
{
-
buildInventory();
-
getInventory();
-
}
-
-
// Build the inventory, storing 10 different products.
-
public static void buildInventory()
-
{
-
product[0] = new Product(1001, "Megaforce", 10, 18.95);
-
product[1] = new Product(502, "Abyss", 25, 12.95);
-
product[2] = new Product(1003, "Deep Impact", 65, 21.95);
-
product[3] = new Product(750, "Forest Gump", 28, 7.95);
-
Arrays.sort(product);
-
}
-
-
public static void getInventory()
-
{
-
System.out.println(); // blank line
-
System.out.println("Welcome to DVD Inventory 1.0"); //display header
-
System.out.println();
-
for(int i = 0; i < product.length; i++)
-
{
-
System.out.println("Item Number: " + product[i].getItemNumber());
-
System.out.println("Item Name: " + product[i].getItemName());
-
System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
-
System.out.println("Item Price: $" + product[i].getItemPrice());
-
System.out.println("Value of Inventory: $" + product[i].getValue());
-
System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
-
System.out.println();
-
-
}
-
}
-
-
} //end Class Inventory3
-
| | Needs Regular Fix | | Join Date: Nov 2007 Location: Cebu City, Philippines
Posts: 510
| | | re: Inventory Program - Won't complie Quote:
Originally Posted by jcato77 I am having trouble figuring out my code and was hoping someone could point me in the right direction. Below is my code what I need to due is create a method to add and display the value of the entire inventory. I have what I think is the correct code but it's not working. Help is greatly appreciated -
class Inventory3
-
{
-
public static final int MAXIMUM_ITEMS = 4;
-
private static Product product[] = new Product[MAXIMUM_ITEMS];
-
-
public static void main(String args[])
-
{
-
buildInventory();
-
getInventory();
-
}
-
-
// Build the inventory, storing 10 different products.
-
public static void buildInventory()
-
{
-
product[0] = new Product(1001, "Megaforce", 10, 18.95);
-
product[1] = new Product(502, "Abyss", 25, 12.95);
-
product[2] = new Product(1003, "Deep Impact", 65, 21.95);
-
product[3] = new Product(750, "Forest Gump", 28, 7.95);
-
Arrays.sort(product);
-
}
-
-
public static void getInventory()
-
{
-
System.out.println(); // blank line
-
System.out.println("Welcome to DVD Inventory 1.0"); //display header
-
System.out.println();
-
for(int i = 0; i < product.length; i++)
-
{
-
System.out.println("Item Number: " + product[i].getItemNumber());
-
System.out.println("Item Name: " + product[i].getItemName());
-
//System.out.println("Director: " + product[i].getDirector());
-
System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
-
System.out.println("Item Price: $" + product[i].getItemPrice());
-
System.out.println("Value of Inventory: $" + product[i].getValue());
-
System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
-
System.out.println();
-
-
}
-
}
-
-
public double entireValue()
-
{
-
double value = 0;
-
for (int i = 0; i < Product; i++)
-
{
-
value = value + product[i].getValue();
-
}
-
return value;
-
}
-
-
public void display()
-
{
-
System.out.printf("Total Value is: $%.2f\n\n", entireValue());
-
}
-
-
-
} //end Class Inventory3
-
Below is the error I get when I try to complie this into my code
Inventory3.java:104: cannot find symbol
symbol : variable Product
location: class Inventory3
for (int i = 0; i < Product; i++)
^ You are comparing a variable with a Product class... Am i right? correct me if im wrong.
Can you show us the code of Product?
Maybe you can't compare them... Maybe the product's length that you have initialized will do...
Update us.
| | Newbie | | Join Date: Mar 2008 Location: Dublin, Ca
Posts: 9
| | | re: Inventory Program - Won't complie
So here is my complete updated code that i've been working on for several hours. I'm able to complie it now but it does not display "Total Value is " $"
Total value should be the inventoryValue of each dvd added up to create an entireValue. I have the code but i'm told I'm missing my call to display it. Everything I've tried doesn't work. any suggestions? -
import java.util.Arrays;
-
-
class Product implements Comparable
-
{
-
private long itemNumber; // class variable that stores the item number
-
private String itemName; // class variable that stores the item name
-
private long invQuantity; // class variable that stores the quantity in stock
-
private double itemPrice; // class variable that stores the item price
-
-
public Product(long number, String name, long quantity, double price) // Constructor for the Supplies class
-
{
-
itemNumber = number;
-
itemName = name;
-
invQuantity = quantity;
-
itemPrice = price;
-
}
-
-
public long getItemNumber() { return itemNumber; } // Method to set item number
-
public String getItemName() { return itemName;} // Method to set the item name
-
public long getInvQuantity() { return invQuantity;} // Method to set the quantity in stock
-
public double getItemPrice() { return itemPrice;} // Method to get the item Price
-
-
public double getValue() { return (double) invQuantity * itemPrice; } // Method to calculate the valure of the inventory
-
-
public int compareTo(Object o)
-
{
-
Product p = null;
-
try
-
{
-
p = (Product) o;
-
}
-
-
catch (ClassCastException cE)
-
{
-
cE.printStackTrace();
-
}
-
return itemName.compareTo(p.getItemName());
-
}
-
} //end class Product
-
-
class DVD extends Product
-
{
-
public DVD(int itemNumber, String itemName, long invQuantity, double itemPrice)
-
{
-
super(itemNumber, itemName, invQuantity, itemPrice);
-
}
-
-
public double getValue()
-
{
-
double inventoryValue = super.getValue();
-
return (inventoryValue * 1.05);
-
}
-
}
-
-
class Inventory3
-
{
-
public static final int MAXIMUM_ITEMS = 4;
-
private static Product product[] = new Product[MAXIMUM_ITEMS];
-
public static int sizeOfArray;
-
-
public static void main(String args[])
-
{
-
buildInventory();
-
getInventory();
-
}
-
-
// Build the inventory, storing 10 different products.
-
public static void buildInventory()
-
{
-
product[0] = new Product(1001, "Megaforce", 10, 18.95);
-
product[1] = new Product(502, "Abyss", 25, 12.95);
-
product[2] = new Product(1003, "Deep Impact", 65, 21.95);
-
product[3] = new Product(750, "Forest Gump", 28, 7.95);
-
sizeOfArray = 4;
-
Arrays.sort(product);
-
}
-
-
public static void getInventory()
-
{
-
System.out.println(); // blank line
-
System.out.println("Welcome to DVD Inventory 1.0"); //display header
-
System.out.println();
-
for(int i = 0; i < product.length; i++)
-
{
-
System.out.println("Item Number: " + product[i].getItemNumber());
-
System.out.println("Item Name: " + product[i].getItemName());
-
System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
-
System.out.println("Item Price: $" + product[i].getItemPrice());
-
System.out.println("Value of Inventory: $" + product[i].getValue());
-
System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
-
System.out.println();
-
-
}
-
}
-
-
double entireValue()
-
{
-
double value = 0;
-
for (int i = 0; i < sizeOfArray; i++)
-
{ value = value + product[i].getValue(); }
-
return value;
-
}
-
-
public void display()
-
{
-
System.out.printf("Total Value is: $%.2f", + entireValue());
-
}
-
-
} //end Class Inventory3
-
| | Needs Regular Fix | | Join Date: Nov 2007 Location: Cebu City, Philippines
Posts: 510
| | | re: Inventory Program - Won't complie
You forgot to call display() after showing the elements...
Since display() and entireValue() cannot be reference from a static context, make it a static method....
Hope it helps,
sukatoa
| | Newbie | | Join Date: Mar 2008 Location: Dublin, Ca
Posts: 9
| | | re: Inventory Program - Won't complie Quote:
Originally Posted by sukatoa You forgot to call display() after showing the elements...
Since display() and entireValue() cannot be reference from a static context, make it a static method....
Hope it helps,
sukatoa how? I'm confused at this point and am trying to understand it.
| | Needs Regular Fix | | Join Date: Nov 2007 Location: Cebu City, Philippines
Posts: 510
| | | re: Inventory Program - Won't complie Quote:
Originally Posted by jcato77 how? I'm confused at this point and am trying to understand it. After you print all necessary informations, then, that is the time you call that display method... It depends on your implementation... Would you like to display it before/after printing the said info by calling it in method main? or in getInventory() method? Depends upon you...
Just like i wrote, your display() and intireValue() were not static methods... And you have tried to print those info in the method main that was a static context, by calling getInventory() that was also a static method. you should also make both of them static. ( display and intireValue methods )...
You may read this if you have time...
sukatoa
| | Newbie | | Join Date: Mar 2008 Location: Dublin, Ca
Posts: 9
| | | re: Inventory Program - Won't complie
Let me ask you this I'm working on two different programs. below is code from my second program and I am trying to get the director to show. I have the code in correctly and it's appended the string but it's not pulling itemDirector and displaying it. Is my problem similar to my other one? -
class Product implements Comparable
-
{
-
private long itemNumber; // class variable that stores the item number
-
private String itemName; // class variable that stores the item name
-
private long invQuantity; // class variable that stores the quantity in stock
-
private double itemPrice; // class variable that stores the item price
-
-
public Product(long number, String name, long quantity, double price) // Constructor for the Supplies class
-
{
-
itemNumber = number;
-
itemName = name;
-
invQuantity = quantity;
-
itemPrice = price;
-
}
-
-
public long getItemNumber() { return itemNumber; } // Method to set item number
-
public String getItemName() { return itemName;} // Method to set the item name
-
public long getInvQuantity() { return invQuantity;} // Method to set the quantity in stock
-
public double getItemPrice() { return itemPrice;} // Method to get the item Price
-
-
public double calculateInventoryValue() { return itemPrice * invQuantity;}
-
-
public int compareTo(Object o)
-
{
-
Product p = null;
-
try
-
{
-
p = (Product) o;
-
}
-
-
catch (ClassCastException cE)
-
{
-
cE.printStackTrace();
-
}
-
-
return itemName.compareTo(p.getItemName());
-
}
-
-
public String toString()
-
{
-
return "Item #: " + itemNumber + "\nName: " + itemName + "\nQuantity: " + invQuantity + "\nPrice: $" + itemPrice + "\nValue: $" + calculateInventoryValue();
-
}
-
} //end class Product
-
-
class DVD extends Product
-
{
-
private String itemDirector;
-
-
public DVD(String itemDirector,int itemNumber, String itemName, long invQuantity, double itemPrice)
-
{
-
super(itemNumber, itemName, invQuantity, itemPrice);
-
//itemDirector = director;
-
}
-
-
public String toString()
-
{
-
String s = String.format("Director: \n", itemDirector);
-
s = s + super.toString();
-
return s;
-
}
-
-
}
-
-
public class Inventory2
-
-
{
-
Product[] supplies;
-
-
public static void main(String[] args)
-
{
-
Inventory2 inventory = new Inventory2();
-
inventory.addProduct(new DVD("John Cato", 1001, "Megaforce", 10, 18.95));
-
inventory.addProduct(new DVD("John Cato", 502, "Abyss", 25, 12.95));
-
inventory.addProduct(new DVD("John Cato", 1003, "Deep Impact", 65, 21.95));
-
inventory.addProduct(new DVD("John Cato", 750, "Forest Gump", 28, 7.95));
-
-
System.out.println(); // blank line
-
System.out.println("Welcome to DVD Inventory 1.0"); //display header
-
inventory.sortByName(); //sort list by name
-
System.out.println(); // blank line
-
inventory.showInventory(); //display inventory
-
-
double total = inventory.calculateTotalInventory();
-
System.out.println("Total Value is: $" + total);
-
-
}
-
-
public void sortByName()
-
{
-
for (int i = 1; i < supplies.length; i++)
-
{
-
int j;
-
Product val = supplies[i];
-
for (j = i - 1; j > -1; j--)
-
{
-
Product temp = supplies[j];
-
if (temp.compareTo(val) <= 0)
-
{
-
break;
-
}
-
supplies[j + 1] = temp;
-
}
-
supplies[j + 1] = val;
-
}
-
}
-
-
public String toString() //creates a String representation of the array of products
-
{
-
String s = "";
-
for (Product p : supplies)
-
{
-
s = s + p.toString();
-
s = s + "\n\n";
-
}
-
return s;
-
}
-
-
public void addProduct(Product p1) //Increases the size of the array
-
{
-
if (supplies == null)
-
{
-
supplies = new Product[0];
-
}
-
Product[] p = supplies; //Copy all products into p first
-
Product[] temp = new Product[p.length + 1]; //create bigger array
-
for (int i = 0; i < p.length; i++)
-
{
-
temp[i] = p[i];
-
}
-
temp[(temp.length - 1)] = p1; //add the new product at the last position
-
supplies = temp;
-
}
-
-
public double calculateTotalInventory() //sorting the array using Bubble Sort
-
{
-
double total = 0.0;
-
for (int i = 0; i < supplies.length; i++)
-
{
-
total = total + supplies[i].calculateInventoryValue();
-
}
-
return total;
-
}
-
-
public void showInventory()
-
{
-
System.out.println(toString()); //call our toString method
-
}
-
-
} //end Class Inventory2
-
| | Needs Regular Fix | | Join Date: Nov 2007 Location: Cebu City, Philippines
Posts: 510
| | | re: Inventory Program - Won't complie Quote:
Originally Posted by jcato77 Let me ask you this I'm working on two different programs. below is code from my second program and I am trying to get the director to show. I have the code in correctly and it's appended the string but it's not pulling itemDirector and displaying it. Is my problem similar to my other one? -
class Product implements Comparable
-
{
-
private long itemNumber; // class variable that stores the item number
-
private String itemName; // class variable that stores the item name
-
private long invQuantity; // class variable that stores the quantity in stock
-
private double itemPrice; // class variable that stores the item price
-
-
public Product(long number, String name, long quantity, double price) // Constructor for the Supplies class
-
{
-
itemNumber = number;
-
itemName = name;
-
invQuantity = quantity;
-
itemPrice = price;
-
}
-
-
-
-
class DVD extends Product
-
{
-
private String itemDirector;
-
public DVD(String itemDirector,int itemNumber, String itemName, long invQuantity, double itemPrice)
-
{
-
super(itemNumber, itemName, invQuantity, itemPrice);
-
//itemDirector = director;
-
}
you've send the values at DVD Constructor, John Cato was also carried to the DVD... BUT, when you pass it to the Product Constructor, no itemDirector was passed.... And you have no itemDirector variable initialized at global....
Set the itemDirector first.... after Passing DVD constructor....
Then use it for showing after a String Director:
Or just get the value of itemDirector @ DVD class....
i've test it....
You can do methods in just a class....
It is nice to use getter method....
Update us,
sukatoa
| | Needs Regular Fix | | Join Date: Nov 2007 Location: Cebu City, Philippines
Posts: 510
| | | re: Inventory Program - Won't complie
To avoid confusions, your problem is only at DVD constructor and the method toString() under it....
After receiving data from the DVD constructor, you forgot to initialize the itemDirector, and that parameter is also literally the same as your global variable in DVD class...You can change it... and assign that to itemDirector..
@ Your toString() method: in DVD class: Use concat method to emerge those strings....
And, "Director: \n" --- How would you print John Cato beside it, if you added newline on it, maybe after itemDirector....
I hope you got it now....
Update us
sukatoa
| | Newbie | | Join Date: Mar 2008 Location: Dublin, Ca
Posts: 9
| | | re: Inventory Program - Won't complie Quote:
Originally Posted by sukatoa To avoid confusions, your problem is only at DVD constructor and the method toString() under it....
After receiving data from the DVD constructor, you forgot to initialize the itemDirector, and that parameter is also literally the same as your global variable in DVD class...You can change it... and assign that to itemDirector..
@ Your toString() method: in DVD class: Use concat method to emerge those strings....
And, "Director: \n" --- How would you print John Cato beside it, if you added newline on it, maybe after itemDirector....
I hope you got it now....
Update us
sukatoa Sukatoa,
I know you are helping me and I thank you but I"m still a little lost, I've done what I think you are talking about and I get an error, below is my code and the error. -
class DVD extends Product
-
{
-
private String itemDirector;
-
-
public DVD(String itemDirector,int itemNumber, String itemName, long invQuantity, double itemPrice)
-
{
-
super(itemNumber, itemName, invQuantity, itemPrice);
-
itemDirector = itemDirector;
-
}
-
-
public String getItemDirector() { return itemDirector; } // Method to set item number
-
-
public String toString()
-
{
-
String s = String.format("Director: " + itemDirector());
-
s = s + super.toString();
-
return s;
-
}
-
-
}
-
Error
Inventory2.java:64: cannot find symbol
symbol : method itemDirector()
location: class DVD
String s = String.format("Director: " + itemDirector());
^
1 error
| | Newbie | | Join Date: Mar 2008 Location: Dublin, Ca
Posts: 9
| | | re: Inventory Program - Won't complie
Alright I think i'm getting closer now if someone could point out why i'm getting a null value I think I have this part solved.. -
class DVD extends Product
-
{
-
public String itemDirector;
-
-
public DVD(String itemDirector,int itemNumber, String itemName, long invQuantity, double itemPrice)
-
{
-
super(itemNumber, itemName, invQuantity, itemPrice);
-
itemDirector = itemDirector;
-
//itemNumber = number;
-
//itemName = name;
-
//invQuantity = quantity;
-
//itemPrice = price;
-
}
-
private String getItemDirector() { return itemDirector; } // Method to set item number
-
-
public String toString()
-
{
-
String s = String.format("Director: " + getItemDirector());
-
s = s + super.toString();
-
return s;
-
}
-
-
}
-
Display:
Welcome to DVD Inventory 1.0
Director: null
Item #: 502
Name: Abyss
Quantity: 25
Price: $12.95
Value: $323.75
Director: null
Item #: 1003
Name: Deep Impact
Quantity: 65
Price: $21.95
Value: $1426.75
Director: null
Item #: 750
Name: Forest Gump
Quantity: 28
Price: $7.95
Value: $222.6
Director: null
Item #: 1001
Name: Megaforce
Quantity: 10
Price: $18.95
Value: $189.5
Total Value is: $2162.6
| | Needs Regular Fix | | Join Date: Nov 2007 Location: Cebu City, Philippines
Posts: 510
| | | re: Inventory Program - Won't complie Quote:
Originally Posted by jcato77 Alright I think i'm getting closer now if someone could point out why i'm getting a null value I think I have this part solved.. -
class DVD extends Product
-
{
-
public String itemDirector;
-
-
public DVD(String itemDirector,int itemNumber, String itemName, long invQuantity, double itemPrice)
-
{
-
super(itemNumber, itemName, invQuantity, itemPrice);
-
itemDirector = itemDirector;
-
//itemNumber = number;
-
//itemName = name;
-
//invQuantity = quantity;
-
//itemPrice = price;
-
}
-
private String getItemDirector() { return itemDirector; } // Method to set item number
-
-
public String toString()
-
{
-
String s = String.format("Director: " + getItemDirector());
-
s = s + super.toString();
-
return s;
-
}
-
-
}
-
Display:
Welcome to DVD Inventory 1.0
Director: null
Item #: 502
Name: Abyss
Quantity: 25
Price: $12.95
Value: $323.75
Director: null
Item #: 1003
Name: Deep Impact
Quantity: 65
Price: $21.95
Value: $1426.75
Director: null
Item #: 750
Name: Forest Gump
Quantity: 28
Price: $7.95
Value: $222.6
Director: null
Item #: 1001
Name: Megaforce
Quantity: 10
Price: $18.95
Value: $189.5
Total Value is: $2162.6 It is better to use a unique variable for storing itemDirector value....
itemDirector = tempitemDirector;
I don't know if JVM will absolutely pass the value from the parameter itemDirector to your global variable itemDirector... They are the same...
Maybe the JVM will assign like this,
itemDirector in global = itemDirector in global
That is why you got a null value...
try to have an experiment on it, try to initialize your global itemDirector any value... "I am null"....
What will happen?!! the output i mean!!....
Update us,
sukatoa
| | Newbie | | Join Date: Mar 2008 Location: Dublin, Ca
Posts: 9
| | | re: Inventory Program - Won't complie Quote:
Originally Posted by sukatoa It is better to use a unique variable for storing itemDirector value....
itemDirector = tempitemDirector;
I don't know if JVM will absolutely pass the value from the parameter itemDirector to your global variable itemDirector... They are the same...
Maybe the JVM will assign like this,
itemDirector in global = itemDirector in global
That is why you got a null value...
try to have an experiment on it, try to initialize your global itemDirector any value... "I am null"....
What will happen?!! the output i mean!!....
Update us,
sukatoa i've tried itemDirector = getItemDirector; and even putting hard values in there and I error out, i can remark the line out and it still complies and gives me a null value. I know i'm missing the return value to carry it over to Inventory3 I just don't know what I'm missing.
| | Newbie | | Join Date: Mar 2008 Location: Dublin, Ca
Posts: 9
| | | re: Inventory Program - Won't complie
So I finally got it working !!! -
class DVD extends Product
-
{
-
private String itemDirector;
-
-
public DVD(int itemNumber, String itemName, String itemDirector,
-
long invQuantity, double itemPrice) {
-
super(itemNumber, itemName, invQuantity, itemPrice);
-
this.itemDirector = itemDirector;
-
}
-
-
public String getItemDirector() {
-
return itemDirector;
-
}
-
}
-
And here is the line I added to my Inventory3 class -
System.out.println("Item Director: " + ((DVD) product[i]).getItemDirector());
-
It's taken me all weekend but you guy's did help me out
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,449 network members.
|