mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-11 20:55:40 -08:00
Handle 'an' vs 'a' grammar
This commit is contained in:
@@ -61,6 +61,19 @@ public final class Card {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of {@link #toString()} preceded by either "AN " or "A " depending on which is gramatically correct.
|
||||
*
|
||||
* @return "AN [x]" when [x] is "an" ace or "an" 8, and "A [X]" otherwise.
|
||||
*/
|
||||
public String toProseString() {
|
||||
if(value == 1 || value == 8) {
|
||||
return "AN " + toString();
|
||||
} else {
|
||||
return "A " + toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
// Overriding 'equals' and 'hashCode' (below) make your class work correctly
|
||||
|
||||
Reference in New Issue
Block a user