Question
Using Java. For this lab you will be creating an abstract class called Game and then extending it with several concrete classes. Game should have
Using Java.
For this lab you will be creating an abstract class called Game and then extending it with several concrete classes.
Game should have the following two instance variables:
String gameName
String playerName
You should create an empty constructor for it as well as a constructor that sets playerName.
Game should contain one abstract class called playATurn that takes no arguments and which returns a string.
You should create getters and setters for the instance variables in Game.
You should create 4 subclasses that extend game:
Bingo
Roulette
CoinToss
RollDie
Each of them, obviously, should implement an appropriate playATurn method as well as any other methods you need to make the games work. Your constructors for the subclasses should set gameName.
Here are the descriptions of the games. Note that Bingo is the most complex game.
Roulette: There are 37 numbers on a roulette wheel, 0 through 36, and playATurn should return a string version of one of these (randomly selected) as an integer.
CoinToss: There are 2 possible outcomes, "heads" or "tails", and playATurn should return one of these values, randomly selected.
RollDie: There are 6 possible outcomes (1 through 6) and playATurn should return a string version of one of these (randomly selected) as an integer.
Bingo: playATurn should return a string that contains the letter (B, I, N, G, or O) and a 2-digit representation of the number, so 01 through 75. Recall that the ranges of each letter are B (1-15), I (16-30), N (31-45), G (46-60), O (61-75). In the game bingo, once a number has been drawn you can't draw the same number until the game is reset. I suggest you consider using an Array to store the output strings and an ArrayList to keep track of the numbers that have already been drawn. You should create a resetBingo method in Bingo to reset the game. You do not have to ensure that more than 75 numbers are drawn.
Your tester class should create an instance of each one of these subclasses, ensuring that the game name and player name is set. You should then invoke playATurn a few times for each one. For testing Bingo you may want to generate all 75 possibilities and make sure there are no duplicates, but your tester should only generate between 10 and 15. After that your tester should invoke resetBingo and generate another 10-15 bingo calls.
Your submission should consist of the following files which you will upload to Canvas:
Game.java
GameTester.java
Bingo.java
Roulette.java
CoinToss.java
RollDie.java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started