1. There are many ways to design a solution to this problem, but you are graded on meeting the specific specifications as given.

2. The game will only have one player play at a time.

3. Use proper statement indentation and meaningful variable names in the code.

4. Place a multi-line Javadoc block comment (not multiple single line comments) giving a description of what this application does before the class header.

5. Output spacing, formatting, and spelling are to match the example console output illustrated above, but of course the user input will be different.

6. Create and use the content of an interface with two constants named PREMIUM and BASIC. Set the value of PREMIUM to "P" and the value of BASIC to B. Include an abstract method called returnPlayer that has a Player parameter and returns a String value.

7. Create a superclass named Player that implements the interface. It has only four instance variables. One is for the player's name, one for the amount of money the player has, one for the players wager, and one for the players guess. Create getter and setter methods for all the instance variables. Implement the returnPlayer method so it returns all the Player object's data values with the type formatted with the first letter in uppercase and the remaining letters in lowercase.

8. Create two Player constructors. One will have no parameters and one will have the name and the amount of money parameters.

9. Create two subclasses of the Player class. One will be for the premium player and one for the basic player. Each has an instance variable that you need to determine from the specifications given below. Create necessary constructors and methods.

10. You mustuse this superclass and its subclasses in the application to create appropriate objects.

11. The premium player will have an automatic line of credit of $10.00. If a premium player loses all the money on the table, they will automatically be given $10.00 to continue playing.

12. The basic player has an enforced betting limit of $1 even if they have more than $1 on the table.

13. Add and use the Console class from chapter 7 or a modified version to validate user input data.

14. Create three packages to hold the five classes in the application and the one interface. One package will contain the super class and the two subclasses, one package will contain the interface and the console class, the third package will contain the class with the main method and the nine other methods described below. Give the packages appropriately descriptive names.

15. Prompt the user for data and store this data appropriately.

16. Validate the data so only acceptable values will be processed. If the user enters invalid data at any time in the application, the application should display an appropriate error message and prompt the user again until the user enters valid data. See example output above. Look up "validate input console" in index of textbook for help.

17. Generate random number between 0 and 3 inclusive using the Math class. Look up Math class in index of textbook for help.

18. Format currency values where illustrated in example output above. Look up NumberFormat class in index of textbook for help.

19. When the user responds to the continue prompts, the application should only accept a value of "yes" or no. The user will be prompted to continue with the same player and/or prompted to continue with a new player.

20. Add Javadoc comments to describe the purpose of every class in the application.

21. Add Javadoc comments to describe the purpose of every method in the application include complete @param and @return tags in the comments.

22. Upon completion of the application generate the Javadoc documentation file.

23. Create a static filed in the main method for a Scanner object to be used as needed by any static method in the class.

24. The application must contain and implement these ten static methods in the same class with the main method. Name them whatever you like. The functionality they will perform in the application is summarized below:

  • Main method- This method will declare and initialize necessary entities and control execution of the code. Anything not handled is the other methods will be accomplished by the main method.
    • parameter type: String array as always
    • return type: void
  • Random number generator method- This method will generate a value between 0 and 3 inclusive.
    • no parameter
    • return type: int
  • Initial welcome display - This method will display the welcome information.
    • no parameter
    • return type: void
  • Winning method - This method determines and prints the winning number. It then calls the method which determines if the player wins or loses.
    • 2 parameter types: NumberFormat, Player
    • return type: void
  • User wager validation and input method- This method will display the wager information based on the type of Player and will prompt, accept, and validate the user's wager
    • 1 parameter types: Player
    • return type: void
  • Winning message method - This method determines if the player wins or loses and displays the appropriate information based on the Player type to the user.
    • 3 parameter types: int, NumberFormat, Player
    • return type: void
  • User guess validation and input method- This method will display the guessing information and will prompt, accept, and validate the user's guess.
    • 1 parameter type: Player
    • return type: void
  • Create player- This method will prompt, accept, and validate the data needed to create a player object. It will also call the returnPlayer method and print appropriate output.
    • no parameter
    • return type: Player
  • Play again with same players- This method will prompt, accept, and validate the data needed to continue playing with the same players that started and print appropriate information in response.
    • no parameter
    • return type: String
  • Play again with new players- This method will prompt, accept, and validate the data needed to continue playing with brand new players from the beginning and print appropriate information in response.
    • no parameter
    • return type: String

Example Output

Welcome to Casino Royale
------------------------
Enter the player's data.

Enter a player’s name: Donna
How much money is Donna willing to put on the table?
Do not enter more than a thousand dollars: one dollar
Error! Invalid number. Try again.
How much money is Donna willing to put on the table?
Do not enter more than a thousand dollars: -1
Error! Number must be greater than 0.0.
How much money is Donna willing to put on the table?
Do not enter more than a thousand dollars: 9000
Error! Number must be less than 1000.0.
How much money is Donna willing to put on the table?
Do not enter more than a thousand dollars: 1000
Error! Number must be less than 1000.0.
How much money is Donna willing to put on the table?
Do not enter more than a thousand dollars: 999
Which type of player is Donna? (P or B) enter in uppercase letters only: b
Check your spelling and enter again.
Which type of player is Donna? (P or B) enter in uppercase letters only: B
Donna has a balance of 999.0 and is a Basic type of player

Donna, what number would you like to wager on?
The valid numbers are between 0 and 3 inclusive.
Donna, enter your number? what
Error! Invalid integer. Try again.
Donna, enter your number? -1
Error! Number must be greater than -1.
Donna, enter your number? 4
Error! Number must be less than 4.
Donna, enter your number? 3

Donna, you can now place a single wager of any size on this number
as long as you have that much money on the table.
Donna, how much do you wager? Your limit is $1.00: 2
Donna, how much do you wager? Your limit is $1.00: -1
Error! Number must be greater than -1.0.
Donna, how much do you wager? Your limit is $1.00: quit
Error! Invalid number. Try again.
Donna, how much do you wager? Your limit is $1.00: .50

Very good. The wheel is spinning.......

The winning number is: 1

Sorry Donna, you lose. You have $998.50 left on the table.

Play again with the same player? (yes/no): yes

Donna, what number would you like to wager on?
The valid numbers are between 0 and 3 inclusive.
Donna, enter your number? 0

Donna, you can now place a single wager of any size on this number
as long as you have that much money on the table.
Donna, how much do you wager? Your limit is $1.00: 1

Very good. The wheel is spinning…….

The winning number is: 0

Congratulations Donna, you have a winning number. You now have $999.50 on the table.

Play again with the same player? (yes/no): no

Play again with a brand new player? (yes/no): y
You must enter yes or no. Try again.

Play again with a brand new player? (yes/no): yes

Enter a player’s name: Rocky
How much money is Rocky willing to put on the table?
Do not enter more than a thousand dollars: 100
Which type of player is Rocky? (P or B) enter in uppercase letters only: P
Rocky has a balance of 100.0 and is a Premium type of player

Rocky, what number would you like to wager on?
The valid numbers are between 0 and 3 inclusive.
Rocky, enter your number? 1

Rocky, you can now place a single wager of any size on this number
as long as you have that much money on the table.
Rocky, how much do you wager? 100

Very good. The wheel is spinning.......

The winning number is: 1

Congratulations Rocky, you have a winning number. You now have $200.00 on the table.

Play again with the same player? (yes/no): yes

Rocky, what number would you like to wager on?
The valid numbers are between 0 and 3 inclusive.
Rocky, enter your number? 0

Rocky, you can now place a single wager of any size on this number
as long as you have that much money on the table.
Rocky, how much do you wager? 200

Very good. The wheel is spinning.......

The winning number is: 2

Sorry Rocky, you lose. You have $0.00 left on the table.

Play again with the same player? (yes/no): yes

Rocky, what number would you like to wager on?
The valid numbers are between 0 and 3 inclusive.
Rocky, enter your number? 3

Rocky, you can now place a single wager of any size on this number
as long as you have that much money on the table.
Rocky, how much do you wager? 50
Error! Number must be less than 11.0.
Rocky, how much do you wager? 10

Very good. The wheel is spinning.......

The winning number is: 0

Sorry Rocky, you lose. You have $-10.00 left on the table.

Play again with the same player? (yes/no): no

Play again with a brand new player? (yes/no): no

Take your money off the table when you leave. Come back soon.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.