A
Ah Ming
Hi!
I write the following code of java with the compilation error.
Would you mind helping to find the key problem? The error is shown as
following.
Shop.java:8: cannot resolve symbol
symbol : constructor Product (java.lang.String,double)
location: class Product
product[0]= new Product("Apple", 3.5);
Kai Ming
Product.java:
public class Product{
//Attribute
public String name;
public double price;
//Constructor
public void Product (String aName, double aPrice){
name = aName;
price = aPrice;
}
//getter/setter
void setProduct(){
Product("Apple", 3.5);
}
}
Shop.java:
public class Shop {
//attribute called product
public Product[] product=new Product[3];
//constructor
public Shop () {
product[0]= new Product("Apple", 3.5);
product[1]= new Product("Orange", 3);
product[2]= new Product("Pear", 2.5);
}
}
I write the following code of java with the compilation error.
Would you mind helping to find the key problem? The error is shown as
following.
Shop.java:8: cannot resolve symbol
symbol : constructor Product (java.lang.String,double)
location: class Product
product[0]= new Product("Apple", 3.5);
Kai Ming
Product.java:
public class Product{
//Attribute
public String name;
public double price;
//Constructor
public void Product (String aName, double aPrice){
name = aName;
price = aPrice;
}
//getter/setter
void setProduct(){
Product("Apple", 3.5);
}
}
Shop.java:
public class Shop {
//attribute called product
public Product[] product=new Product[3];
//constructor
public Shop () {
product[0]= new Product("Apple", 3.5);
product[1]= new Product("Orange", 3);
product[2]= new Product("Pear", 2.5);
}
}