|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectlabtest1.General
public class General
This class represents a general. There can be at most MAX_NUMBER generals (that is, at most MAX_NUMBER General objects can be created).
| Field Summary | |
|---|---|
static int |
MAX_NUMBER
The maximum number of generals that can be created. |
| Method Summary | |
|---|---|
boolean |
equals(Object object)
Tests if this general is the same as the given object. |
static General |
getInstance(String name)
Returns a general with the given name who is not retired if the number of created generals has not reached MAX_NUMBER. |
String |
getName()
Returns the name of this general. |
int |
hashCode()
Returns the hashcode of this general. |
boolean |
isRetired()
Checks if this general is retired. |
void |
retire()
Sets this general to be retired. |
String |
toString()
Returns a string representation of this general. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_NUMBER
| Method Detail |
|---|
public String getName()
public boolean isRetired()
public void retire()
public static General getInstance(String name)
name - the name of the general.
public boolean equals(Object object)
equals in class Objectobject - an object.
public int hashCode()
hashCode in class Objectpublic String toString()
toString in class Object
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||