Hello guys. I have a school assignment and Im having a trouble doing it. I will ask for help.
I have a class Product and I need to make 2 subclasses Chocolate and Whine.
Each product has a name, barcode, price and tax.
Each product has a method for calculating the price.
Each product has an attribute wich defines the product weight.
In Chocolate and Whine class I need to create a constructor for object creation.
In each class I need to define a method ToString for object information.
Finally I need to creaty one of each object for every class wich shows product information.
Thanks in advance.
public class Product {
private String barcode;
private String name;
private double price;
private double tax;
public Product(String barcode, String name, double price
) {
this.barcode=barcode;
this.name=name;
this.price=price;
this.tax=tax;
}
@Override
public String toString() {
return name;
}
public String getBarcode() {
return barcode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public double getTax() {
return tax;
}
public String getInfo() {
return barcode+" "+name+" "+price;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
}