Something went wrong. Try again.
2-APL UPC project.
Something went wrong. Try again.
1.1 kB · 58 lines
Java
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859package cardtable;
import java.util.*;
public final class Suit { private String name; private String symbol;
/** * The suit clubs. */ public final static Suit CLUBS = new Suit( "clubs", "c" ); /** * The suit diamonds. */ public final static Suit DIAMONDS = new Suit( "diamonds", "d" ); /** * The suit hearts. */ public final static Suit HEARTS = new Suit( "hearts", "h" ); /** * The suit spades. */ public final static Suit SPADES = new Suit( "spades", "s" );
public final static java.util.List VALUES = Collections.unmodifiableList( Arrays.asList( new Suit[] { CLUBS, DIAMONDS, HEARTS, SPADES } ) );
private Suit( String nameValue, String symbolValue ) { name = nameValue; symbol = symbolValue; }
public String getName() { return name; }
public String getSymbol() { return symbol; }
public String toString() { return name; }
public int compareTo( Object otherSuitObject ) { Suit otherSuit = (Suit) otherSuitObject; return VALUES.indexOf( this ) - VALUES.indexOf( otherSuit ); }
}