In my tree class the user can set the fall color of whatever tree they choose, but it's not taking the colors I type in when I test it.
import java.awt.Color;
public class Tree
{
private String treeSpecies;
private int treePrice;
private Color currentColor;
private Color fallColor;
private int treeAge;
/**
* Creates a tree and initialises it's values.
*/
public Tree(String species, Color autumnColor, int price){
if (species == "") {
throw new IllegalArgumentException("Please enter a tree species.");
}
if (autumnColor == null) {
throw new IllegalArgumentException("Please enter the tree's Autumn color.");
}
if (price == 0) {
throw new IllegalArgumentException("Please enter a price value greater than zero dollars.");
}
species = treeSpecies;
autumnColor = fallColor;
price = treePrice;
currentColor = Color.GREEN;
}
public Tree(String species, Color autumnColor, int price, int age){
if (species == "") {
throw new IllegalArgumentException("Please enter a tree species.");
}
if (autumnColor == null) {
throw new IllegalArgumentException("Please enter the tree's Autumn color.");
}
if (price == 0) {
throw new IllegalArgumentException("Please enter a price value greater than zero dollars.");
}
if (age == 0) {
throw new IllegalArgumentException("Please enter an age value greater than zero.");
}
species = treeSpecies;
autumnColor = fallColor;
price = treePrice;
age = treeAge;
currentColor = fallColor;
}
The error I'm getting in create object is "Error: cannot find symbol - variable GREEN