|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.waldura.tw.City
public final class City
A city is identified by its name, a single uppercase character.
Conversions to/from characters are handled by
getName()
and valueOf(char)
, respectively.
Package members are also given access to an identity relationship between
cities and numbers: they can converts between City
instances and numbers using valueOf(int)
and getIndex()
.
This special relationship is used by the
DensesRoutesMap
to store cities in an array.
Field Summary | |
---|---|
static City |
A
|
static City |
B
|
static City |
C
|
private static City[] |
cities
|
static City |
D
|
static City |
E
|
static City |
F
|
static int |
MAX_NUMBER
The largest possible number of cities. |
private char |
name
|
Constructor Summary | |
---|---|
private |
City(char name)
Private constructor. |
Method Summary | |
---|---|
int |
compareTo(City c)
Compare two cities by name. |
private boolean |
equals(City c)
|
boolean |
equals(java.lang.Object o)
Two cities are considered equal if they are the same object, or their names are the same. |
(package private) int |
getIndex()
|
private static int |
getIndexForName(char name)
|
char |
getName()
|
private static char |
getNameForIndex(int index)
|
java.lang.String |
toString()
|
static City |
valueOf(char name)
|
(package private) static City |
valueOf(int n)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int MAX_NUMBER
private static final City[] cities
public static final City A
public static final City B
public static final City C
public static final City D
public static final City E
public static final City F
private final char name
Constructor Detail |
---|
private City(char name)
name
- Method Detail |
---|
private static int getIndexForName(char name)
private static char getNameForIndex(int index)
public static City valueOf(char name)
static City valueOf(int n)
public char getName()
int getIndex()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
Object.equals(Object)
private boolean equals(City c)
public int compareTo(City c)
compareTo
in interface java.lang.Comparable<City>
Comparable.compareTo(Object)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |