[Solved] Classes with object attributes
Okay, I have no idea what to call this problem, I am pretty new to Java and need some assistance.
I have an inventory program I am building for a school project and am running into an issue trying to provide data to objects. This program is supposed to use static data and output each item in a stock/inventory kind manner. I have three files, Main, Product, and CD. Essentially, the Product class is supposed to be movies, and the CD class is for CDs. At first I was supplying class variables in each class file and just using that data, but I am now trying to provide attributes to the objects in the Main file. Like this:
Code:
// create our inventory objects
private static Product items[] = {
new CD("Staind - The Illusion of Progress", 102, 6, 12.99, "Rock", "CD"),
new Product("Boondock Saints", 101, 4, 14.99, "DVD")
};
The problem is I am receiving a "cannot find symbol" error. Symbol: constructor Product(). This is occuring on the line indicated by the comment. I have done some debugging and found that if I remove the public Product() portion of code from my Product.java class then this error goes away. Why is this occuring?
Product.java
Code:
public class Product {
private String prodName;
private int itemNumber;
private double stock;
private double price;
private String prodType;
public Product(String name, int number, double inStock, double itemPrice, String type)
{
prodName = name;
itemNumber = number;
stock = inStock;
price = itemPrice;
prodType = type;
}
// methods here
}
CD.java
Code:
public class CD extends Product {
private String prodName;
private int itemNumber;
private double stock;
private double price;
private String genre;
private String prodType;
public CD(String name, int number, double inStock, double itemPrice, String itemGenre, String type)
{ // error is occurring on this line
prodName = name;
itemNumber = number;
stock = inStock;
price = itemPrice;
genre = itemGenre;
prodType = type;
}
// methods here
}