Uhhhhhh I'm not sure what string representation you actually want but you have two options.
Either:
Java Code:
public String getOn() {
if(on) {
return "whatever you want for on goes here";
} else {
return "whatever you want for off going here";
}
}
If you want to do this in one line, you can use
Java Code:
return (on ? "whatever you want for on" : "whatever you want for off");
This does the exact same thing, in the format of (boolean ? what to do if true : what to do if false)
No comments:
Post a Comment