First compilation error:
System.out.println ("Type: " + type + "\t" + "Make: " + make);
Product
doesn’t have the make
instance variable. Its subclass GolfHat
declares the variable . Subclass inherits non-private members of a superclass, it doesn’t work the other way round.
Logical error :
if (type=="Glove"){
}
This is an erroneous way of comparing String contents . Use equals()
method instead.
if ("Glove".equals(type)){
}