Hi guys I'm creating a program that is a shoping cart and I'm trying to create a toString() method.
This is my GolfHat class
package ShoppingCart;
public class GolfHat extends Product {
private String name;
private String colour;
private String make;
private double price;
public GolfHat(String type, String make, String name, String colour,double price) {
this.type = "hat";
name = name;
colour = colour;
make = make;
price = price;
}
and my product class is this
package ShoppingCart;
public class Product {
public String type ;
public String toString (){
if (type=="hat" ) {
System.out.println ("Type: " + type + "\t" + "Make: " + make);
return type;
}
if (type=="Glove"){
}
return "cant find";
}
it wont let me use the make variable, I think it wont let me do this cause my variables are private however for part of my assesment i need to show a example of encaspulation and im struggerling to see where else I'll be able to do it