-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContestant.java
More file actions
87 lines (78 loc) · 2.23 KB
/
Contestant.java
File metadata and controls
87 lines (78 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* Lab 8
*
* Enum containing a subset of Rock-Paper-Scissors contestants.
* Members of the enumeration contain the following information:
* The Contestant's name (given by the exact enum name),
* the Contestant's region, and the choice of hand they use.
*
* @author Stephen
* @version 2018-03-12
*/
public enum Contestant
{
/**
* The Contestant "George".
*/
GEORGE(new ContestantInfo(Region.NORTH, HandChoice.ROCK)),
/**
* The Contestant "Jill".
*/
JILL(new ContestantInfo(Region.SOUTH, HandChoice.ROCK)),
/**
* The Contestant "Matthew".
*/
MATTHEW(new ContestantInfo(Region.EAST, HandChoice.SCISSORS)),
/**
* The Contestant "Betty".
*/
BETTY(new ContestantInfo(Region.WEST, HandChoice.PAPER));
/**
* ContestantInfo that holds information about this Contestant.
*/
private ContestantInfo info;
/**
* Enum constructor. Assigns the values specified for an enum type to the internal
* variable stored in that type. If you are unsure of how to store data inside of an enum, you should
* reference the following java documentation:
*
* https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html
*
* The planet enum is particularly useful.
*
* @param info The instance of ContestantInfo that describes this Contestant.
*/
private Contestant(ContestantInfo info)
{
this.info = info;
}
/**
* @return the Contestant's region.
*/
public Region getRegion()
{
return info.getRegion();
}
/**
* @return the Contestant's hand choice.
*/
public HandChoice getChoice()
{
return info.getChoice();
}
/**
* Returns a string with the Contestant's name (lowercase),
* region, and hand choice.
*
* TODO: Nothing to implement here, but you should reference this if
* you are having trouble with your other toStrings.
*
* @return Information about the contestant in the form <contestantname>: <contestantinfo>
*/
@Override
public String toString()
{
String contestantName = name().toLowerCase();
return String.format("%s: %s", contestantName, info.toString());
}
}