hello there, im trying to create some java code that spits out a board of 5 rows of sticks, each one with it's corresponding number. (Row 1 = 1 Stick)
Like so:
|
| |
| | |
| | | |
| | | | |
Then it needs to ask Player A to choose a row, and how many sticks to remove from that row ONLY. Then Player B takes a turn.
You can only remove sticks from one row at a time, unlimited amount of sticks.
The object of the game is to be the one to remove the LAST stick.
Then spit out. "You win!"
My code:
import java.util.Scann er;
public class StickGame
{
public static void main (String[]args)
{
Scanner scan = new Scanner(System. in);
{
String a = " | ";
String Row1 = (a);
String Row2 = (a+ " "+a+ " ");
String Row3 = (a+ " "+a+ " "+a+ " ");
String Row4 = (a+ " "+a+ " "+a+ " "+a+ " ");
String Row5 = (a+ " "+a+ " "+a+ " "+a+ " "+a+ " ");
//Initial Board
System.out.prin tln(" 1: " +a+ " ");
System.out.prin tln(" 2: " +a+ " "+a+ " ");
System.out.prin tln(" 3: " +a+ " "+a+ " "+a+ " ");
System.out.prin tln(" 4: " +a+ " "+a+ " "+a+ " "+a+ " ");
System.out.prin tln(" 5: " +a+ " "+a+ " "+a+ " "+a+ " "+a+ " ");
System.out.prin tln();
System.out.prin tln("Player A, Please choose a row.");
int x = scan.nextInt();
System.out.prin tln("How many sticks would you like to remove?");
int y = scan.nextInt();
}
}
}
I don't know how to remove "n" number of sticks from Row "n", and then continue back and forth between players until its finished.
thankz alot for any responses... im getting a headache just thinking about it
PS -- urggh, my uncle just told me I cant use array?? I dont know what that means.. but I have to find a different method..
(Hes my teacher.. im homeschooled) so he wont help me :[
Like so:
|
| |
| | |
| | | |
| | | | |
Then it needs to ask Player A to choose a row, and how many sticks to remove from that row ONLY. Then Player B takes a turn.
You can only remove sticks from one row at a time, unlimited amount of sticks.
The object of the game is to be the one to remove the LAST stick.
Then spit out. "You win!"
My code:
import java.util.Scann er;
public class StickGame
{
public static void main (String[]args)
{
Scanner scan = new Scanner(System. in);
{
String a = " | ";
String Row1 = (a);
String Row2 = (a+ " "+a+ " ");
String Row3 = (a+ " "+a+ " "+a+ " ");
String Row4 = (a+ " "+a+ " "+a+ " "+a+ " ");
String Row5 = (a+ " "+a+ " "+a+ " "+a+ " "+a+ " ");
//Initial Board
System.out.prin tln(" 1: " +a+ " ");
System.out.prin tln(" 2: " +a+ " "+a+ " ");
System.out.prin tln(" 3: " +a+ " "+a+ " "+a+ " ");
System.out.prin tln(" 4: " +a+ " "+a+ " "+a+ " "+a+ " ");
System.out.prin tln(" 5: " +a+ " "+a+ " "+a+ " "+a+ " "+a+ " ");
System.out.prin tln();
System.out.prin tln("Player A, Please choose a row.");
int x = scan.nextInt();
System.out.prin tln("How many sticks would you like to remove?");
int y = scan.nextInt();
}
}
}
I don't know how to remove "n" number of sticks from Row "n", and then continue back and forth between players until its finished.
thankz alot for any responses... im getting a headache just thinking about it
PS -- urggh, my uncle just told me I cant use array?? I dont know what that means.. but I have to find a different method..
(Hes my teacher.. im homeschooled) so he wont help me :[
Comment