enums:
sunspotfrcsdk/lib/WPILibJ/enum.txt:
Code:
//Going to use this pattern for enumeration classes, since they are otherwise unsupported
//The typesafe enum pattern
public class Suit {
public final int value;
protected static final int CLUBS_VAL = 0;
protected static final int DIAMONDS_VAL = 1;
protected static final int HEARTS_VAL = 2;
protected static final int SPADES_VAL = 3;
public static final Suit CLUBS = new Suit(CLUBS_VAL);
public static final Suit DIAMONDS = new Suit(DIAMONDS_VAL);
public static final Suit HEARTS = new Suit(HEARTS_VAL);
public static final Suit SPADES = new Suit(SPADES_VAL);
private Suit(int value){
this.value = value;
}
}
WPILIB uses this method throughout, and I used it in our bot.
Classes in one file:
Don't. Trust me, I know where you're coming from, I was there once. You're trying to program in some other language. Wrap your mind around Java, and then, this will seem stupid.
However, you may be interested to know that you can define sub-classes, which are all in the same file.