Hi guys,
For context I have started learning java for school and we have our first assignment coming up and I can't seem to fix 4 bugs in the game. The code is for a piles game where basicly you pick a pile from an array and choose how many tokens from that pile you would like to remove and the player with the last token wins.
Code:
import java.util.Scanner;
import java.util.Random;
public class modingCode{
private static Scanner imput = new Scanner (System.in);
private static Random rand = new Random ();
public static void main (String [] args){
game();{
private static void game();{
String p1_name = name_check("Player 1 enter your name");
String p2_name = name_check("Player 2 enter your name");
int num_games = int_check("How many games would you like to play?");
int [] score = new int [2];
int [] piles = new int [5];
int pile;
boolean game_won;
String turn = p1_name;
int game_count = 0;
while(game_count <num_games){
game_count = game_count + 1;
System.out.println("Game : " );
for(int i = 0; i < 5; i++){
piles [i] = rand.nextInt(5)+1;
}
while(game_won = true){
System.out.println();
System.out.println(turn + " its your turn ");
for(int i = 0; i < 5; i++){
pile = i + 1;
System.out.println("Pile " + pile + " has " +
piles [i] + " tokens");
}
int pile_to_take = int_check ("Enter the pile to take away from: ");
int taken = int_check("Enter the number of tokens to take: ");'
piles [pile_to_take - 1] = piles [(pile_to_take - 1)] - taken;
for(int i = 0; i < 5; i++){
piles[i] = rand.nextInt()+1;
}
}
}
}
private static String name_check String prompt;{
while(true){
System.out.println(prompt);
String text = input.nextLine();
if(text.isEmpty){
System.out.println("Please enter your name: ");
}
else{
System.out.println("Hello " + test);
return num;
}
}
}
private static int int_check String prompt;{
while(true){
System.out.println(prompt);
try{
int num = Integer.parseInt(input.nextLine);
return num;
}
catch(NumberFormatException e ){
System.out.println("Please enter a number: ");
}
}
}
}
}
}
4 errors found:
File: C:\Users\*****\Desktop\Programming\Java\Java Basics\Programming challeges\modingCode.java [line: 10]
Error: Syntax error, insert "VariableDeclarators" to complete LocalVariableDeclaration
File: C:\Users\*****\Desktop\Programming\Java\Java Basics\Programming challeges\modingCode.java [line: 10]
Error: Syntax error, insert ";" to complete BlockStatements
File: C:\Users\*****\Desktop\Programming\Java\Java Basics\Programming challeges\modingCode.java [line: 45]
Error: Syntax error, insert ";" to complete LocalVariableDeclarationStatement
File: C:\Users\*****\Desktop\Programming\Java\Java Basics\Programming challeges\modingCode.java [line: 58]
Error: Syntax error, insert ";" to complete LocalVariableDeclarationStatement
Any help on a fix would be great or a step in the right direction.
Cheers, ya boi Dellzie.