I keep getting the error
constructor product in class product cannot be applied to given types
In the super(name, price, barcode)
section.
Here is my code :
Product class:
public class Product {
public String name;
public float price;
public int barCode;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public int getBarCode() {
return barCode;
}
public void setBarCode(int barCode) {
this.barCode = barCode;
}
public String tostring(){
return (" Name: " +name+ ", Price: " +price+ ", Barcode no: " +barCode);
}
}
Chocolate class:
public class Chocolate extends Product{
public Chocolate(String name, float price, int barcode) {
super(name, price, barcode);
}
@Override
public String toString() {
return "Decs : Name :"+super.getName()+", price :"+super.getPrice()+", barcode : "+super.getBarCode();
}
}
Whine class:
public class Whine extends Product {
public Whine(String name, float price, int barcode) {
super(name, price, barcode);
}
@Override
public String toString() {
return "Decs : Name :"+super.getName()+", price :"+super.getPrice()+", barcode : "+super.getBarCode();
}
}
Main method:
public static void main(String[] args) {
Chocolate c1 = new Chocolate("abcd1", "c1", 23.7d, 2.3d);
Chocolate c2 = new Chocolate("abcd2", "c2", 23d, 2.3d);
Chocolate c3 = new Chocolate("abcd3", "c3", 23.2d, 2.3d);
Chocolate c4 = new Chocolate("abcd4", "c4", 23.1d, 2.3d);
Whine w1 = new Whine("Whine1", "w1", 23.7d, 2.3d);
Whine w2 = new Whine("Whine2", "w2", 233.7d, 22.3d);
System.out.println("C1"+c1);
System.out.println("C2"+c2);
System.out.println("C3"+c3);
System.out.println("C4"+c4);
System.out.println("W1"+w1);
System.out.println("W2"+w2);
}
}