PROBLEM STATEMENT
To help your gambling addiction, you have decided to write a program which
calculates the amount of money you win at a slot machine.
The slot machine has three reels, and earnings are determined based on what the
reels are after pulling the Slot Machine Lever:
If all three reels are "CHERRY", the amount you win is 1000 times your bet.
If all three reels are "DOUBLEBAR", the amount you win is 100 times your bet.
If all three reels are "BAR", the amount you win is 10 times your bet.
If one or two of the three reels is "CHERRY", the amount you win is 1 times
your bet.
If the reels end up on some other combination, the amount you win is 0.
Write a class SlotMachine which contains a method getEarnings which takes the
amount of your bet and final values of the three reels and outputs the amount
of your earnings.
DEFINITION
Class Name: SlotMachine
Method Name: getEarnings
Param Types: int, String[]
Return Type: int
Method Signature (be sure your method is public): int getEarnings(int bet,
String[] reels);
TOPCODER WILL ENSURE
bet is between 1 and 10, inclusive.
reels contains exactly three elements, each element consists of between 1 and
50, inclusive, capital letters (A - Z)
NOTES
- Do not subtract the amount of your bet from the earnings the program outputs.
- reels[0] contains the final value of the first reel, reels[1] contains the
final value of the second, and reels[2] contains the final value of the third.
- "CHERRY", "DOUBLEBAR" and/or "BAR" cannot be considered if they are
substrings of another string. See last example.
EXAMPLES
If bet is 1 and reels = {"DOUBLEBAR", "DOUBLEBAR", "DOUBLEBAR"}, the program
should output 100 * 1 = 100.
If bet is 10 and reels = {"DOUBLEBAR", "DOUBLEBAR", "CHERRY"}, the program
should output 1 * 10 = 10.
If bet is 8 and reels = {"DOUBLEBAR", "BAR", "STAR"}, the program should output
0.
If bet is 8 and reels = {"STAR", "STAR", "STAR"}, the program should output 0.
If bet is 8 and reels = {"STAR", "BLANK", "CHERRY"}, the program should output 8.
If bet is 8 and reels = {"FOO", "FOO", "CHERRYFOO"}, the program should output 0.