What am I doing wrong? JAVA code

Discussion in 'Programming' started by SuperDuper, Oct 2, 2007.

  1. #1
    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.Scanner;
    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.println(" 1: " +a+ " ");
    System.out.println(" 2: " +a+ " "+a+ " ");
    System.out.println(" 3: " +a+ " "+a+ " "+a+ " ");
    System.out.println(" 4: " +a+ " "+a+ " "+a+ " "+a+ " ");
    System.out.println(" 5: " +a+ " "+a+ " "+a+ " "+a+ " "+a+ " ");

    System.out.println();
    System.out.println("Player A, Please choose a row.");
    int x = scan.nextInt();
    System.out.println("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:confused:

    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 :[
     
    SuperDuper, Oct 2, 2007 IP