Question

The premise of this project is to make a basic GUI and code for the game...

The premise of this project is to make a basic GUI and code for the game Keno. The specifics of the gui and game are below.

Description:

In this project you will implement the popular casino and state lottery game, Keno. This is a somewhat simple game to understand and play which should allow you to focus on learning GUI development in JavaFX and trying your hand at event driven programing.

Implementation Details:

You may add as many classes, data members, interfaces and methods as necessary to implement this program. You may only use JavaFX components for your GUI. You may NOT use Java Swing of Java AWT.

The GUI:

You are welcome to use/discover any widget, pane, node, layout or other in JavaFX to implement your GUI. For this project, you are not allowed to use Scene Builder or FXML layout files. The following elements are required:

1) Your program must start with a welcome screen that is it’s own JavaFX scene. It will consist of: It will have a menu bar at the top with one tab “Menu”. Under “Menu”, you will have the following three options:

• display the rules of the game

• display the odds of winning

• exit the game

***Each of the menu options should be implemented***

It will also have a button that allows the player to start playing. This will change the GUI to the game play screen.

2) The game play screen is its own JavaFX scene. It will consist of:

• The same menu as the welcome screen with an additional menu option: New Look. This option, when implemented, will change the look of the GUI; such as new colors, fonts, images….etc. While there is no minimum for elements to change, the new look must be noticeable to the average user.

• The bet card will be displayed and you must use JavaFX GridPane to implement it. It will be a 8X10 grid of clickable Nodes (Buttons, ImageViews, etc.). Each of the Nodes should display the number it represents (1-80).

• The Nodes in the GridPane should be disabled until the player decides on how many spots they want to play.

• There must be a way for the player to pick how many spots to play(1,4,8 or 10). This can not change once the drawings begin.

• There must be a way for the player to pick how many drawings they will play their bet card for (minimum of 1 and maximum of 4). This can not change once the drawings begin.

• Once the player decides on how many spots they want to play, the Nodes of the GridPane should be enabled to allow the user to choose their numbers. The user should not be able to select duplicate numbers or select more spots than they decided originally.

• Once a number is selected on the bet card, it should show that it has been chosen. Players can edit their choices as often as they want before the drawings occur. They can not change once the drawings begin.

• There should be a way that the player can select to have their numbers chosen automatically and randomly for them if they don’t want to choose themselves.

• It is up to you to ensure that all input is correct and no illegal selections, choices or options have been made.

• When the number of spots has been chosen, bet card filled and number of drawings selected the user should have a way to start the first drawing.

• The drawing will display 20, randomly selected numbers (1-80) with no duplicates, one by one with a pause in between selection. How they are displayed is up to you. After each drawing, the user should be able to see how many numbers they matched, which numbers they matched and how much they won in that particular drawing. They should also be able to see what they have won since the program was started.

• There should be a way for the player to decide to continue to the next drawing.

• When all drawings are complete, the user should be able to fill out a new bet card, number of spots and number of drawings or exit the program.

Playing the game in your Program:

Your game must play and feel like the user is actually playing in real time. You must include pause transitions or add buttons like “continue” to control the flow of the game. If you did not, the program would move too fast and not allow the user to understand what is happening. You must also provide ways to prompt the player as to what they should do next. It will not always be obvious to someone using your software what they are supposed to do. It is also up to you to ensure that all input is correct and no illegal selections, choices or options have been made.

This is the sample code given:

import javafx.application.Application;

import javafx.scene.Scene;

import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class JavaFXTemplate extends Application {

   public static void main(String[] args) {
      // TODO Auto-generated method stub
      launch(args);
   }

   //feel free to remove the starter code from this method
   @Override
   public void start(Stage primaryStage) throws Exception {
      // TODO Auto-generated method stub
      primaryStage.setTitle("Welcome to JavaFX");
      
      
      
            
      Scene scene = new Scene(new VBox(), 700,700);
      primaryStage.setScene(scene);
      primaryStage.show();
   }

}

Homework Answers

Answer #1

CONSIDERING THE GIVEN PARAMETERS FROM QUESTION WE SHOW THE FOLLOWING AS:

import java.util.Scanner; //used to get input in the game
import java.util.Random; //used to generate random numbers by the computer

public class kenoTest
{

public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
double playerMoney = 100; //Start the player off with some money
int playerNums[] = new int[15];
int computerNums[] = new int[20];
int kenoSpot, kenoCatch;
double bet;
boolean continueGame = true;
String userInput;

  
System.out.println("Hello, and welcome to the game Keno!");
System.out.println("This is a high stakes game. You can win and lose money quickly!");
while(continueGame)
{
System.out.println("You currently have: $" + playerMoney);
System.out.println("Let's get some numbers to begin.");
System.out.println("You may enter up to 15 numbers");
playerNums = getUserInput();
bet = getBet(playerMoney);
computerNums = getComputerNums();
kenoSpot = getSpot(playerNums);
kenoCatch = getCatch(playerNums, computerNums);
System.out.println("Catch: " + (kenoCatch + 1));
playerMoney += payout(kenoSpot, kenoCatch, bet);
playerMoney -= bet;
System.out.println("You now have: $" + playerMoney);
if (playerMoney <= 0)
{
continueGame = false;
System.out.println("Sorry, you ran out of money!");
System.out.println("Better luck next time! :)");
}
else
{
System.out.println("Would you like to continue?");
userInput = input.nextLine();

if ((userInput.equals("y"))|| userInput.equals("yes"))
{
continueGame = true;
}
else
{
continueGame = false;
}
}
}
System.out.println("Thanks for playing!");
System.out.println("Overall, you now have: $" + playerMoney);
}

/*
getUserInput function
@return array userInput
the array userInput is all of the numbers that the user entered
this function initally sets all the numbers in the array to 0.
It checks to make sure the user has not inputted the number before
and also that the number entered is greater than 0 and less than 80
*/

public static int[] getUserInput()
{
Scanner input = new Scanner(System.in); // for input
boolean invalidInput = true;
boolean continuePlayer = true;
int playerNums[] = new int[15];
int index;
int numberEntered;
String enterString;
for (index = 0; index < playerNums.length; index++ )
{
playerNums[index] = 0;
}
index = 0;
while(continuePlayer && index < 15)
{
do
{
do
{
System.out.println("Enter number " + (index+1));
numberEntered = input.nextInt();
if ((numberEntered > 0) && (numberEntered < 81))
{
if(isUnique(numberEntered, playerNums))
{
invalidInput = false;
playerNums[index] = numberEntered;
}
else
{
System.out.println("Sorry, you already entered that number before!");
System.out.println("Try again! ");
invalidInput = true;
}
}
else
{
invalidInput = true;
System.out.println("Sorry, the number you entered is either less than 0 or greater than 80");
System.out.println("Try again");
System.out.println("");
}
} while(invalidInput);
  
if(index < 14) //makes sure program doesn't ask to continue when on the last number
{
System.out.println("Do you wish to continue? (yes/no)");
input.nextLine();
enterString = input.nextLine();
if ((enterString.equals("n")) || (enterString.equals("no")))
{
invalidInput = false;
continuePlayer = false;
}
else if ((enterString.equals("y")) || (enterString.equals("yes")))
{
invalidInput = false;
continuePlayer = true;
}
else
{
System.out.println("Sorry, I didn't understand that.");
System.out.println("");
invalidInput = true;
}
  
}
}while(invalidInput);

index++;
}
return playerNums;
}

/*
isUnique function
@return boolean isUnique
@params number and array
Returns whether the number is unique to the array or not
if it is, it will return true, if it is not then it will return false
Used to ensure that there are no repeats in both playerNums and computerNums
*/

public static boolean isUnique(int number, int[] array)
{
int index;
for (index = 0; index < array.length; index++)
{
if(number == array[index])
{
return false;
}
}
return true;
}

/*
getComputerNums function
@return array computerNums
  
This function generates the numbers for the computer
The numbers are generated randomly. Follows same rules as user input
but array has 20 instead of 15 numbers.
*/

public static int[] getComputerNums()
{
int[] computerNums = new int[20];
Random rand = new Random();
int index;
int randomNumber = 0;
  
for (index = 0; index < computerNums.length; index++)
{
randomNumber = rand.nextInt(80) + 1;
if(isUnique(randomNumber, computerNums))
{
computerNums[index] = randomNumber;
}
else
{
index--;
}

}
return computerNums;
}

/*
getSpot function
@return spot
@params playerArray
The getSpot function returns the spot, which is
the number of numbers the user initially picked
it makes spot go up when it doesn't find a 0.
A 0 shows that the user did not enter a number for that index
*/

public static int getSpot(int[] playerArray)
{
int index;
int spot = 0;
for (index = 0; index < playerArray.length; index++)
{
if(playerArray[index] != 0)
{
spot++;
}
  
}
spot -= 1; //Subtract one so it works properly in array
return spot;
}

/*
getBet function
@return bet
@param playerMoney
This function gets the bet from the user.
It makes sure that the best is greater than or equal to 0
It also makes sure that the user has enough money to bet
*/

public static double getBet(double playerMoney)
{
Scanner input = new Scanner(System.in);
double bet = 0;
boolean invalidInput = true;
while(invalidInput)
{
System.out.print("Enter the bet amount in whole dollars: $");
bet = input.nextInt();
if(bet < 0)
{
System.out.println("Bet amount can't be less than 0!");
invalidInput = true;
}
else if(bet > playerMoney)
{
System.out.println("You don't have enough money to bet that!");
invalidInput = true;
}
else
{
invalidInput = false;
}
}
return bet;
}

  
/*
getCatch function
@return catch
@params arrays playerArray and computerArray
This function returns the catch which is
how many of the user's numbers matched the computer's.
*/

public static int getCatch(int[] playerArray, int[] computerArray)
{
int playerIndex;
int computerIndex;
int kenoCatch = 0;
for (playerIndex = 0; playerIndex < playerArray.length; playerIndex++)
{
for(computerIndex = 0; computerIndex < computerArray.length; computerIndex++)
{
if(playerArray[playerIndex] == computerArray[computerIndex])
{
kenoCatch++;
}
}
}
kenoCatch -= 1;//subtact one so it works in array
return kenoCatch;
}

/*
payout function
@return payoutAmount
@param spot and catch
This function will return the total amount that should be multiplied
by the bet amount. For the payout array, each line is a spot and
each number within the array is the catch
*/

public static double payout(int kenoSpot, int kenoCatch, double betAmount)
{
double payoutAmount = 0;
double multiplier;
double payout[][] =
{
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //1
{1, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //2
{1, 2, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //3
{0.5, 2, 6, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //4
{0.5, 1, 3, 15, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},//5
{0.5, 1, 2, 3, 30, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0},//6
{0.5, 0.5, 1, 6, 12, 36, 100, 0, 0, 0, 0, 0, 0, 0, 0},//7
{0.5, 0.5, 1, 3, 6, 19, 90, 720, 0, 0, 0, 0, 0, 0, 0},//8
{0.5, 0.5, 1, 2, 4, 8, 20, 80, 1200, 0, 0, 0, 0, 0, 0},//9
{0, 0.5, 1, 2, 3, 5, 10, 30, 600, 1800, 0, 0, 0, 0, 0},//10
{0, 0.5, 1, 1, 2, 6, 15, 25, 180, 1000, 3000, 0, 0, 0, 0},//11
{0, 0, 0.5, 1, 2, 4, 24, 72, 250, 500, 2000, 4000, 0, 0, 0},//12
{0, 0, 0.5, 0.5, 3, 4, 5, 20, 80, 240, 500, 3000, 6000, 0, 0},//13
{0, 0, 0.5, 0.5, 2, 3, 5, 12, 50, 150, 500, 1000, 2000, 7500, 0},//14
{0, 0, 0.5, 0.5, 1, 2, 5, 15, 50, 150, 300, 600, 1200, 2500, 10000}//15
};
if(kenoCatch < 0)
{
multiplier = 0;
}
else
{
multiplier = payout[kenoSpot][kenoCatch];
payoutAmount = multiplier * betAmount;
}
return payoutAmount;
}
}

PLEASE UPVOTE ITS VERY NECESSARY FOR ME

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program that allows two players to play a game of tic-tac-toe. Use a twodimensional...
Write a program that allows two players to play a game of tic-tac-toe. Use a twodimensional char array with three rows and three columns as the game board. Each element in the array should be initialized with an asterisk (*). The program should run a loop that: • Displays the contents of the board array. • Allows player 1 to select a location on the board for an X. The program should ask the user to enter the row and...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...
Programing lanugaue is C++ Plan and code a menu-driven modular program utilizing an array An input...
Programing lanugaue is C++ Plan and code a menu-driven modular program utilizing an array An input file has an unknown number of numeric values(could be empty too).Read the numbers from the input fileand store even numbers in one arrayand odd numbers in another array.Create menu options to Display count of even numbers, count of odd numbersand the sum values in each array Determine the average of each array Determine the median of each array Sort each array in ascending order(use...
in c++ : Problem Domain: The classic TicTacToe game alternatively place Xs and Os on a...
in c++ : Problem Domain: The classic TicTacToe game alternatively place Xs and Os on a 3x3 grid. The winner is the first player to place 3 consecutive marks in a horizontal, vertical or diagonal row. Understanding the Problem: In this assignment, you will: 1) Create a tic tac toe board data structure. 2) Check for game over. 3) Clear the tic tac toe game for each game. 4) Display the tic tac toe board to screen. 5) Simulate playing...
SIMPLE PAINTING GUI APP in Java Your mission in this exercise is to implement a very...
SIMPLE PAINTING GUI APP in Java Your mission in this exercise is to implement a very simple Java painting application. Rapid Protyping The JFrame app must support the following functions: (you can use any other programming languages that you are comfortable)  Draw curves, specified by a mouse drag.  Draw filled rectangles or ovals, specified by a mouse drag (don't worry about dynamically drawing the shape during the drag - just draw the final shape indicated).  Shape selection...
use repl.it intro to C-programing no advance code also put good comment that i can know...
use repl.it intro to C-programing no advance code also put good comment that i can know whats this code use for  thank you use repl.it intro to C-programing no advance code also put good comment that i can know whats this code use for  thank you program for a game of hangman. Store the word to be guessed as individual characters of an array called word. The player must guess the letters belonging to word. If the user enters a valid letter,...
Using Java, write a program that allows the user to play the Rock-Paper-Scissors game against the...
Using Java, write a program that allows the user to play the Rock-Paper-Scissors game against the computer through a user interface. The user will choose to throw Rock, Paper or Scissors and the computer will randomly select between the two. In the game, Rock beats Scissors, Scissors beats Paper, and Paper beats Rock. The program should then reveal the computer's choice and print a statement indicating if the user won, the computer won, or if it was a tie. Allow...
Create in JAVA Suppose you are designing a game called King of the Stacks. The rules...
Create in JAVA Suppose you are designing a game called King of the Stacks. The rules of the game are as follows:  The game is played with two (2) players.  There are three (3) different Stacks in the game.  Each turn, a player pushes a disk on top of exactly one of the three Stacks. Players alternate turns throughout the game. Each disk will include some marker to denote to whom it belongs.  At the end...
I need the java code for a 4-function calculator app on android studio. Please make sure...
I need the java code for a 4-function calculator app on android studio. Please make sure all the requirements shown below are followed (such as the error portion and etc). The topic of this app is to simply create a 4 function calculator which calculates math expressions (add, subtract, multiply, and divide numbers). The requirements are the following : - The only buttons needed are 0-9, *, /, +, -, a clear, and enter button - Implement the onclicklistener on...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...