I've been trying to learn Java and I'm working on a project.
I have an abstract class called Card that I'm using as a template to make sub-classes.
It has a method to set the name field and color field of the card and a method to set the cost.
I have a subclass of Card called Workshop.
I'm trying to use the methods of Card in Workshop to set the name and color fields of Workshop.
To do so, I'm calling the methods super.setCardNameColor("Workshop", "Green")
and super.setCardCost(0,0,0,0,0,0,0,0);
However, in order to do this Eclipse in making me use (what appears to be) double curly braces in the class declaration.
I suspect this has something to do with Anonymous Inner Classes, perhaps from calling 'super' or something like that, but none of my Google searches are giving me the information I need. Can anyone shed some light on the subject here? I'm using sysout and getters to make sure that the values are being set correctly on an instance of Workshop, but I'm baffled by the double braces. Thank you ahead of time for your help!
Edit: here is the code
public abstract class Card
{
private String cardName = "";
private String cardColor = "";
private int coinCost = 0;
private int woodCost = 0;
private int brickCost = 0;
private int stoneCost = 0;
private int oreCost = 0;
private int glassCost = 0;
private int clothCost = 0;
private int paperCost = 0;
private int coinValue = 0;
private int pointValue = 0;
private int millitaryValue = 0;
private int woodValue = 0;
private int brickValue = 0;
private int stoneValue = 0;
private int oreValue = 0;
private int glassValue = 0;
private int clothValue = 0;
private int paperValue = 0;
private Card discountForCard;
private Card discountFromCard;
public void setCardNameColor(String cardName, String cardColor) {
this.cardName = cardName;
this.cardColor = cardColor;
}
public void setCardCost(int coinCost, int woodCost, int brickCost,
int stoneCost, int orecost, int glassCost, int clothCost,
int paperCost) {
this.coinCost = coinCost;
this.woodCost = woodCost;
this.brickCost = brickCost;
this.stoneCost = stoneCost;
this.oreCost = orecost;
this.glassCost = glassCost;
this.clothCost = clothCost;
this.paperCost = paperCost;
}
public void setCardValue(int coinValue, int millitaryValue, int pointValue,
int woodValue, int brickValue, int stoneValue, int oreValue,
int glassValue, int clothValue, int paperValue) {
this.coinValue = coinValue;
this.millitaryValue = millitaryValue;
this.pointValue = pointValue;
this.woodValue = woodValue;
this.brickValue = brickValue;
this.stoneValue = stoneValue;
this.oreValue = oreValue;
this.glassValue = glassValue;
this.clothValue = clothValue;
this.paperValue = paperValue;
}
public void getCardInfo() {
System.out.println(cardName + cardColor + coinCost + woodCost+brickCost+stoneCost+oreCost+glassCost+clothCost+paperCost);
}
public void setGivesDiscountTo(Card card) {
card = discountForCard;
}
public void setReceivesDiscountFrom(Card card) {
card = discountFromCard;
}
public String getCardName() {
return cardName;
}
}
public class Workshop extends Card
{
{
super.setCardNameColor("Workshop", "Green");
super.setCardCost(0, 0, 0, 0, 0, 1, 0, 0);
}
}