subclass arguments to superclass variables
Hi, I am making a chess piece like this:
Piece wKing = new King("King", 'w');
Piece is superclass to King. Piece has variables "String Name" and "char Color".
public String Name;
public char Color;
public Piece(String iName, char iColor)
Name = inName;
Color = inColor;
First, do I have to have the variables in Piece protected/public for this?
public class King extends Piece
public King(String iName, char iColor)
Second, why do I get "cannot reference Name before supertype constructor has been called" on both when I have them as protected in the superclass?
Re: subclass arguments to superclass variables
Ok I solved this just now by changing my King constructor to this:
using the same argument names as the names of the variables I want to assign them to.
public King(String Name, char Color)