I have two constructors that are pretty much exactly the same except that one also takes in a boolean value. I want the constructor with four parameters to the call the other one in order to get the the first three. Here is what I have so far.
public Tree(String species, String autumnColor, int price) {
if (species == "") {
throw new IllegalArgumentException("Please enter a tree species.");
}
if (!autumnColor.equals("red") && !autumnColor.equals("orange") && !autumnColor.equals("yellow")) {
throw new IllegalArgumentException("Please enter the tree's Autumn color as yellow, orange, or red.");
}
if (autumnColor.equals("red")) {
fallColor = Color.RED;
}
if (autumnColor.equals("orange")) {
fallColor = Color.ORANGE;
}
if (autumnColor.equals("yellow")) {
fallColor = Color.YELLOW;
}
if (price == 0) {
throw new IllegalArgumentException("Please enter a price value greater than zero dollars.");
}
treeSpecies = species;
treePrice = price;
currentColor = Color.GREEN;
}
public Tree(String species, String autumnColor, int price, boolean autumnSwitch) {
this.(Tree(String species, String autumnColor, int price));
if(!autumnSwitch.equals(true) && !autumnSwitch.equals(false)) {
throw new IllegalArgumentException("Please enter true or false.");
}
}
The second constructor gets an error message and I'm not sure what format I need in order to fix it. Thanx in advance.