Question Separate Main Program Jeopardygame Class Means Least Two Java Class Jeopardygam Q26368048

QUESTION:

A. Separate your main program from your JeopardyGame Class fromhere

This means that you will have at least two Java Class.

i. JeopardyGame Class

ii. JeopardyTestMain Program that uses JeopardyGame class to runthe game

B. Use Linked List and Node Class in your JeopardyGame class.

3. Make sure to use file input out to save game score

4. Create Java Interface (e.g., JFrame) in your program.

NOTE: Please answer this as soon as possible and make sure itworks…

import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class JeopardyGame
{
public static void main(String args[])
{
Scanner input_letter = new Scanner(System.in);
ArrayList<Character> possiblevalues= newArrayList<Character>() {{add(‘r’); add(‘h’);}};
int playerzdice=0;
int computerzdice=0;
int player_points=0;
int computer_points=0;
int max_points_in_a_turn_computer = 0; // maximum points thecomputer can get per turn.
boolean playerz_turn = true;//check if player’s turn.
while(player_points<100 || computer_points <100)
{
if(playerz_turn)
{
while(true)
{
System.out.println(“Gamer 1, you have “+player_points + ” pointsnow..in total. Plz enter”+possiblevalues+” where r to Roll, h tohold dice”);
char action = input_letter.next().charAt(0);
if(action == ‘r’)
{
playerzdice = rollDice();
System.out.println(“Gamer 1 you got ” + playerzdice);
if(playerzdice == 1)
{
System.out.println(“Gamer 1..Your Turn Over”);
playerzdice = 0;
player_points = 0;
playerz_turn =! playerz_turn;
break;
}
else
{
player_points=+playerzdice;
System.out.println(“Gamer 1 your total is ” +player_points);
}
}
else if(action == ‘h’) // if to hold
{
System.out.println(“Gamer 1’s current score is”+player_points);
playerz_turn = !playerz_turn;
break;
}
}
}
else
{
while(true)
{
System.out.println(“Gamer 2… you have ” +computer_points +”points as total..Plz enter”+possiblevalues+” where r to Roll, h tohold dice”);
char action = input_letter.next().charAt(0);
if(playerz_turn == true)
{
computerzdice = rollDice();
System.out.println(“Gamer 2… you got ” + computerzdice);
if(max_points_in_a_turn_computer >= 20)
{
playerz_turn =! playerz_turn;
break;
}
if(computerzdice == 1)
{
System.out.println(“Gamer 2 …Turn Over Now”);
computerzdice = 0;
computer_points = 0;
playerz_turn =! playerz_turn;
break;
}
else
{
computer_points+=computerzdice;
System.out.println(“Gamer 2.. now your total is “+computer_points);
}
}
else if(playerz_turn == true)
{
computer_points = computerzdice;
System.out.println(“Gamer 2 now has “+computer_points);
playerz_turn = !playerz_turn;
break;
}
}
}
}
if (computer_points >= 5)//you can fix the computer points
{
System.out.println(“Computer has won! :-(“);
}
else if(player_points >= 5)
System.out.println(“Gamer 1 has won! :-)”);
}
private static int rollDice()
{
Random dice = new Random();
return (int) (dice.nextInt(6)) + 1;
}
}

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *