/*
 * In a hypothetical real-estate themed board game, a player rolls two dice to
 *move their token around the perimeter of the board by the number of squares
 *shown on the face of the dice. At each spot the player lands, he or she must
 *take an action, either purchasing a property or paying some cash penalty. If
 *the player lands on a property, she or he must purchase it. If the property
 *has already been purchased, the player does nothing. If the player lands on a
 *penalty square, he or she must pay the penalty, no matter how many times the
 *player lands on it. The table below shows each square on the board, and the
 *price or penalty for each square.
 * Each time the player rounds the board (reaches or passes the "Go" square),
 *the player earns $200. There is no other way to earn money. Play continues
 *until the player lands on a property or penalty he or she cannot afford or
 *there have been 1,000 rolls of dice.
 * Assuming only one player who starts with $1500 per game, and 1,000 games,
 *please answer the following questions:
 * What is the average number off rolls (turns) in a game?
 * What is the average number of properties purrchased in a game?
 * As a percentage, in how many games is Indiana Avenue purchased?
 */

package jmonopoly;

/**
 *
 * Beginning...
 */
public class JMonopoly {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
    }

}

Edited 2 Years Ago by tbuchli

These are the squares on the board:
Name of Square           Type of Square    Cost
Mediterranean Avenue           property      60
Community Chest                penalty        0
Baltic Avenue                  property      60
Income Tax                     penalty      200 or 10% of total cash,
                                                whichever is greater
Reading Railroad               property     200
Oriental Avenue                property     100
Chance                         penalty        0
Vermont Avenue                 property     100
Connecticut Avenue             property     120
Jail Visit                     penalty       50
St. Charles Place              property     140
Electric Company               property     150
States Avenue                  property     140
Virginia Avenue                property     160
Pennsylvania Railroad          property     200
St. James Place                property     180
Community Chest                penalty        0
Tennessee Avenue               property     180
New York Avenue                property     200
Free Parking                   penalty        0
Kentucky Avenue                property     220
Chance                         penalty        0
Indiana Avenue                 property     220
Illinois Avenue                property     240
B. & O. Railroad               property     200
Atlantic Avenue                property     260
Ventnor Avenue                 property     260
Water Works                    property     150
Marvin Gardens                 property     280
Police Bribe                   penalty       50
Pacific Avenue                 property     300
North Carolina Avenue          property     300
Communnity Chest               penalty        0
Pennsylvania Avenue            property     320
Short Line                     property     200
Chance                         penalty        0
Park Place                     property     350
Luxury Tax                     penalty       75
Boardwalk                      property     400
Go                             penalty        0

aaaaaaaaaaaaaand ... what exactly is your question? if it's a request to do your homework .. no.
I suggest you take a look at the community rules, especially the one that states:

Do provide evidence of having done some work yourself if posting questions from school or work assignments

we'll help you improve your code, but we're not here to help you cheat your way through school.

It isn't homework, just a java project I found and would like help doing

// I can not get this to run in NetBeans... Any Ideas?

package JavaMonopoly;

import java.util.Random;
import java.util.ArrayList;


public final class JavaMonopoly {
    public Random rand = new Random();
    public int[] board;
    public long[] rolls;
    public long loops = 0;

    final private ChanceDeck chance;
    final private ChestDeck chest;

    public JavaMonopoly(String[] args) {

        board = new int[40];
        rolls = new long[20];
        chance = new ChanceDeck();
        chest = new ChestDeck();

        int num = Integer.parseInt(args[0]);

        board = game(num,board);

        printBoard();
    }

    public int roll() {
        int rval = Math.abs(rand.nextInt()%6)+Math.abs(rand.nextInt()%6)+2;
        rolls[rval]++;
        return(rval);
    }

    public int[] game(int count, int[] board) {
        int spot = 0;
        for(int x = 0; x < count; x++) {
            int roll = roll();
            spot = spot + roll;
            if(spot >= 40) {
                spot = spot - 40;
                loops++;
            }
            board[spot]++;
            if(spot == 30) {
                spot = 10;
            }
            else if(spot==7 || spot==22 || spot==36) {
                int newspot = chance.getChance(spot);
                if(newspot!=spot) {
                    board[newspot]++;
                    spot = newspot;
                }
            }
            else if(spot==2 || spot==17 || spot==33) {
                int newspot = chest.getChest(spot);
                if(newspot!=spot) {
                    board[newspot]++;
                    spot = newspot;
                }
            }
        }

        return(board);
    }

    public void printBoard() {
        System.out.println("GO collect $200              = "+board[0]);
        System.out.println("Mediterreanian Ave [purple]  = "+board[1]);
        System.out.println("Community Chest 1            = "+board[2]);
        System.out.println("Baltic Ave         [purple]  = "+board[3]);
        System.out.println("INCOME TAX                   = "+board[4]);
        System.out.println("Reading Railroad    < RR >   = "+board[5]);
        System.out.println("Oriental Ave       [cyan]    = "+board[6]);
        System.out.println("Chance 1                     = "+board[7]);
        System.out.println("Vermont Ave        [cyan]    = "+board[8]);
        System.out.println("Connecticut Ave    [cyan]    = "+board[9]);
        System.out.println("Jail                         = "+board[10]);
        System.out.println("St. Charles Place  [magenta] = "+board[11]);
        System.out.println("Electic Company    (Utility) = "+board[12]);
        System.out.println("States Ave         [magenta] = "+board[13]);
        System.out.println("Virginia Ave       [magenta] = "+board[14]);
        System.out.println("Pennsylvania RR     < RR >   = "+board[15]);
        System.out.println("St James Place     [orange]  = "+board[16]);
        System.out.println("Community Chest 2            = "+board[17]);
        System.out.println("Tennessee Ave      [orange]  = "+board[18]);
        System.out.println("New York Ave       [orange]  = "+board[19]);
        System.out.println("Free Parking                 = "+board[20]);
        System.out.println("Kentucky Ave       [red]     = "+board[21]);
        System.out.println("Chance 2                     = "+board[22]);
        System.out.println("Indiana Ave        [red]     = "+board[23]);
        System.out.println("Illinois Ave       [red]     = "+board[24]);
        System.out.println("B&O Railroad        < RR >   = "+board[25]);
        System.out.println("Atlantic Ave       [yellow]  = "+board[26]);
        System.out.println("Ventnor Ave        [yellow]  = "+board[27]);
        System.out.println("Water Works        (Utility) = "+board[28]);
        System.out.println("Marvin Gardens     [yellow]  = "+board[29]);
        System.out.println("GO TO JAIL                   = "+board[30]);
        System.out.println("Pacific Ave        [green]   = "+board[31]);
        System.out.println("North Carolina Ave [green]   = "+board[32]);
        System.out.println("Community Chest 3            = "+board[33]);
        System.out.println("Pennsylvania Ave   [green]   = "+board[34]);
        System.out.println("Short Line RR       < RR >   = "+board[35]);
        System.out.println("Chance 3                     = "+board[36]);
        System.out.println("Park Place         [blue]    = "+board[37]);
        System.out.println("LUXURY TAX                   = "+board[38]);
        System.out.println("Boardwalk          [blue]    = "+board[39]);

        System.out.println("\nProperties:");
        System.out.println("purple  = "+(board[1]+board[3]));
        System.out.println("cyan    = "+(board[6]+board[8]+board[9]));
        System.out.println("magenta = "+(board[11]+board[13]+board[14]));
        System.out.println("orange  = "+(board[16]+board[18]+board[19]));
        System.out.println("red     = "+(board[21]+board[23]+board[24]));
        System.out.println("yellow  = "+(board[26]+board[27]+board[29]));
        System.out.println("green   = "+(board[31]+board[32]+board[34]));
        System.out.println("blue    = "+(board[37]+board[39]));
        System.out.println("RR      = "+(board[5]+board[15]+board[25]+board[35]));
        System.out.println("Utility = "+(board[12]+board[28]));
        System.out.println("chance  = "+(board[7]+board[22]+board[36]));
        System.out.println("chest   = "+(board[2]+board[17]+board[33]));
        System.out.println("Ooops  = "+(board[4]+board[30]+board[38]));

        System.out.println("\nThe board was traversed a total of "+loops+" times");

        System.out.print("\nRolls: ");
        for(int x=2;x<13;x++) {
            System.out.print("("+x+")="+rolls[x]+" ");
        }
        System.out.println("\n\n");
    }

    public static void main(String[] args) {
        JavaMonopoly game = new JavaMonopoly(args);
    }

        final class ChanceDeck {
        ArrayList<ChanceCard> cards;
        ArrayList<ChanceCard> discards;

        public ChanceDeck() {
            cards = new ArrayList<>();
            discards = new ArrayList<>();

            discards.add(new ChanceCard(0,"get out of jail free"));
            discards.add(new ChanceCard(0,"pay poor tax"));
            discards.add(new ChanceCard(0,"elected chairman of the board"));
            discards.add(new ChanceCard(0,"bank pays"));
            discards.add(new ChanceCard(0,"collect 150"));
            discards.add(new ChanceCard(0,"make repairs"));
            discards.add(new ChanceCard(1,"GO TO JAIL"));
            discards.add(new ChanceCard(2,"advance to go"));
            discards.add(new ChanceCard(3,"advance to charles"));
            discards.add(new ChanceCard(4,"advance to boardwalk"));
            discards.add(new ChanceCard(5,"advance to nearest utility"));
            discards.add(new ChanceCard(6,"advance to illinois"));
            discards.add(new ChanceCard(7,"advance to reading"));
            discards.add(new ChanceCard(8,"go back 3 spaces"));
            discards.add(new ChanceCard(9,"advance to nearest RR"));
            discards.add(new ChanceCard(9,"advance to nearest RR"));

            shuffle();
        }

        public void shuffle() {

                        //System.out.println("shuffling chance");
            Random random = new Random();
            while(discards.size()>0) {
                int index = Math.abs(random.nextInt())%discards.size();
                cards.add(discards.get(index));
                discards.remove(index);
            }
        }

        public int getChance(int location) {
            int rval = location;

            if(cards.isEmpty()) {
                shuffle();
            }
            ChanceCard card = (ChanceCard)cards.get(0);
            cards.remove(0);
            discards.add(card);
            if(card.type==1) {
                rval = 10;
            }
            else if(card.type==2) {
                loops++;
                rval = 0;
            }
            else if(card.type==3) {
                if(location>11) {
                    loops++;
                }
                rval = 11;
            }
            else if(card.type==4) {
                rval = 39;
            }
            else if(card.type==5) {
                if(location==7) {
                    rval = 12;
                }
                else if(location==22) {
                    rval = 28;
                }
                else if(location==36) {
                    loops++;
                    rval = 12;
                }
                else {
                    System.out.println("I fucked up");
                }
            }
            else if(card.type==6) {
                if(location>24) {
                    loops++;
                }
                rval = 24;
            }
            else if(card.type==7) {
                loops++;
                rval = 5;
            }
            else if(card.type==8) {
                rval = location-3;
            }
            else if(card.type==9) {
                if(location==7) {
                    rval = 15;
                }
                else if(location==22) {
                    rval = 25;
                }
                else if(location==36) {
                    loops++;
                    rval = 5;
                }
            }

            //System.out.println("GOT Chance: "+card.label);


            return(rval);
        }

    }

    class ChanceCard {
        public int type;
        public String label;

        public ChanceCard(int cardtype, String cardname)
        {
            type = cardtype;
            label = cardname;
        }
    }

    final class ChestDeck {
        ArrayList<ChestCard> cards;
        ArrayList<ChestCard> discards;

        public ChestDeck() {
            cards = new ArrayList<>();
            discards = new ArrayList<>();

            discards.add(new ChestCard(0,"second prize"));
            discards.add(new ChestCard(0,"bank error"));
            discards.add(new ChestCard(0,"life insurance"));
            discards.add(new ChestCard(0,"income tax refund"));
            discards.add(new ChestCard(0,"grand opera opening"));
            discards.add(new ChestCard(0,"recieve for services"));
            discards.add(new ChestCard(0,"you inherit"));
            discards.add(new ChestCard(0,"get out of jail free"));
            discards.add(new ChestCard(0,"street repairs"));
            discards.add(new ChestCard(0,"doctor's fee"));
            discards.add(new ChestCard(0,"pay school tax"));
            discards.add(new ChestCard(0,"pay hospital"));
            discards.add(new ChestCard(0,"xmas fund"));
            discards.add(new ChestCard(0,"from sale of stock"));
            discards.add(new ChestCard(1,"advance to go"));
            discards.add(new ChestCard(2,"go to jail"));

            shuffle();
        }

        public void shuffle() {
            //System.out.println("shuffling chest");

            Random random = new Random();
            while(discards.size()>0) {
                int index = Math.abs(random.nextInt())%discards.size();
                cards.add(discards.get(index));
                discards.remove(index);
            }
        }

        public int getChest(int location) {
            int rval = location;

            if(cards.isEmpty()) {
                shuffle();
            }
            ChestCard card = (ChestCard)cards.get(0);
            cards.remove(0);
            discards.add(card);
            if(card.type==1) {
                loops++;
                location = 0;
            }
            else if(card.type==2) {
                location = 10;
            }

            //System.out.println("GOT CommunityChest: "+card.label);

            return(rval);
        }
    }

    class ChestCard {

            public int type;
            public String label;

            public ChestCard(int cardtype, String cardname) {
        type = cardtype;
        label = cardname;
            }

    }

}

if you can't get to run it in NetBeans, maybe you should consider not using NetBeans.
if it was code you have written, you would know how to run it.

I need to gain practice, and have no book anymore.

you don't gain practice from copy pasting code and trying to get it to work. chances are, the code you've copied is worthless crap, or even when it is decent code, it's to complicated for your level of knowledge.
buy a new book, and go through it, or just use the official online documentation

Edited 2 Years Ago by stultuske

I am now getting 2 errors, and I can not figure it out, here is my code again:

package javamonopoly;

import java.util.Random;

public final class JavaMonopoly {

    public Random rand = new Random();
    public int[] board;
    public long[] rolls;
    public int funds = 1500;
    public long loops = 0;

    public JavaMonopoly(String[] args) {

        board = new int[40];
        rolls = new long[20];

        int num = Integer.parseInt(args[0]);

        board = game(num, board);

        printBoard();
    }

    public int roll() {
        int rval = Math.abs(rand.nextInt() % 6) + Math.abs(rand.nextInt() % 6) + 2;
        rolls[rval]++;
        return(rval);
    }

    public int[] game(int count, int[] board) {

                int spot = 0;

        for(int x = 0; x < count; x++) {
            int roll = roll();
            spot = spot + roll;
            if(spot >= 40) {
                spot = spot - 40;
                                funds += 200;
                loops++;
            }

            board[spot]++;

            if(spot == 30) {
                funds -= 50;
            }
            else if(spot == 7 || spot == 22 || spot == 36) {
                funds -= 0;
            }
            else if(spot == 2 || spot == 17 || spot == 33) {
                funds -= 0;
            }
        }

        return(board);
    }

    public void printBoard() {

                System.out.println("GO collect $200              = "+board[0]);
        System.out.println("Mediterreanian Ave [purple]  = "+board[1]);
        System.out.println("Community Chest              = "+board[2]);
        System.out.println("Baltic Ave         [purple]  = "+board[3]);
        System.out.println("INCOME TAX                   = "+board[4]);
        System.out.println("Reading Railroad    < RR >   = "+board[5]);
        System.out.println("Oriental Ave       [cyan]    = "+board[6]);
        System.out.println("Chance                       = "+board[7]);
        System.out.println("Vermont Ave        [cyan]    = "+board[8]);
        System.out.println("Connecticut Ave    [cyan]    = "+board[9]);
        System.out.println("Jail                         = "+board[10]);
        System.out.println("St. Charles Place  [magenta] = "+board[11]);
        System.out.println("Electic Company    (Utility) = "+board[12]);
        System.out.println("States Ave         [magenta] = "+board[13]);
        System.out.println("Virginia Ave       [magenta] = "+board[14]);
        System.out.println("Pennsylvania RR     < RR >   = "+board[15]);
        System.out.println("St James Place     [orange]  = "+board[16]);
        System.out.println("Community Chest              = "+board[17]);
        System.out.println("Tennessee Ave      [orange]  = "+board[18]);
        System.out.println("New York Ave       [orange]  = "+board[19]);
        System.out.println("Free Parking                 = "+board[20]);
        System.out.println("Kentucky Ave       [red]     = "+board[21]);
        System.out.println("Chance                       = "+board[22]);
        System.out.println("Indiana Ave        [red]     = "+board[23]);
        System.out.println("Illinois Ave       [red]     = "+board[24]);
        System.out.println("B&O Railroad        < RR >   = "+board[25]);
        System.out.println("Atlantic Ave       [yellow]  = "+board[26]);
        System.out.println("Ventnor Ave        [yellow]  = "+board[27]);
        System.out.println("Water Works        (Utility) = "+board[28]);
        System.out.println("Marvin Gardens     [yellow]  = "+board[29]);
        System.out.println("GO TO JAIL                   = "+board[30]);
        System.out.println("Pacific Ave        [green]   = "+board[31]);
        System.out.println("North Carolina Ave [green]   = "+board[32]);
        System.out.println("Community Chest              = "+board[33]);
        System.out.println("Pennsylvania Ave   [green]   = "+board[34]);
        System.out.println("Short Line RR       < RR >   = "+board[35]);
        System.out.println("Chance                       = "+board[36]);
        System.out.println("Park Place         [blue]    = "+board[37]);
        System.out.println("LUXURY TAX                   = "+board[38]);
        System.out.println("Boardwalk          [blue]    = "+board[39]);

        System.out.println("\nProperties:");
        System.out.println("purple  = "+(board[1]+board[3]));
        System.out.println("cyan    = "+(board[6]+board[8]+board[9]));
        System.out.println("magenta = "+(board[11]+board[13]+board[14]));
        System.out.println("orange  = "+(board[16]+board[18]+board[19]));
        System.out.println("red     = "+(board[21]+board[23]+board[24]));
        System.out.println("yellow  = "+(board[26]+board[27]+board[29]));
        System.out.println("green   = "+(board[31]+board[32]+board[34]));
        System.out.println("blue    = "+(board[37]+board[39]));
        System.out.println("RR      = "+(board[5]+board[15]+board[25]+board[35]));
        System.out.println("Utility = "+(board[12]+board[28]));
        System.out.println("chance  = "+(board[7]+board[22]+board[36]));
        System.out.println("chest   = "+(board[2]+board[17]+board[33]));
        System.out.println("Ooops  = "+(board[4]+board[30]+board[38]));

        System.out.println("\nThe board was traversed a total of "+loops+" times");

        System.out.print("\nRolls: ");

        for(int x = 2; x < 13; x++) {
            System.out.print("(" + x + ") = " + rolls[x] + " ");
        }

                System.out.println("\n\n");

        }

    public static void main(String[] args) {

            JavaMonopoly game = new JavaMonopoly(args);
    }

}

Edited 2 Years Ago by tbuchli

Please test and let me know what i am doing wrong

package javamonopoly;

import java.util.Random;

public final class JavaMonopoly {

    public int[] board;
    public long[] rolls;
        public int funds = 0;
    public long loops = 0;

    public JavaMonopoly(String[] args) {

        board = new int[40];
        rolls = new long[20];

        int num = Integer.parseInt("12");

        board = game(num, board);

        printBoard();
    }

        /**
         *
         * The Die Class should have a integer (int) called value that will contain the die's value.
         * In addition, two constants, HIGHEST_DIE_VALUE (= 6) and LOWEST_DIE_VALUE (=1) should be declared.
         * When the default constructor is called, the roll method will be called. In the roll method, a
         *random number between 1 and 6  will be generated and stored in an instance variable called value.
         * 
         * @author TBuchli
         * 
        */
        class Die {
            public static final int Highest_Die_Value = 6;
            public static final int Lowest_Die_Value = 1;    

            private int value;

            /**
             * Default constructor
             */
            public Die(){
                roll();
            }

            /**
             * Overloaded constructor
             */
            public Die ( int value){
                this.value = value;
            }

            /**
             * This will assign a random value to this die object
             */
            public void roll(){
                Random rand = new Random(); // create a new Random Object
                this.value = rand.nextInt(Highest_Die_Value) + Lowest_Die_Value;
            }

            /**
             * Getter for the Die Object's value
             * @return the value of this Die
             */
            public int getValue(){
                return this.value;
            }

        }

    public int[] game(int count, int[] board) {

                int spot = 0;
                funds = 1500;
                Die die1 = new Die();
                Die die2 = new Die();

        for(int x = 0; x < count; x++) {
            int roll = (die1.getValue() + die2.getValue());
            spot = spot + roll;
            if(spot >= 40) {
                spot = spot - 40;
                                funds += 200;
                loops++;
            }

            board[spot]++;

            if(spot == 30) {
                funds -= 50;
            }
            else if(spot == 7 || spot == 22 || spot == 36) {
                funds -= 0;
            }
            else if(spot == 2 || spot == 17 || spot == 33) {
                funds -= 0;
            }
        }

        return(board);
    }

    public void printBoard() {

                System.out.println("GO collect $200              = "+board[0]);
        System.out.println("Mediterreanian Ave [purple]  = "+board[1]);
        System.out.println("Community Chest              = "+board[2]);
        System.out.println("Baltic Ave         [purple]  = "+board[3]);
        System.out.println("INCOME TAX                   = "+board[4]);
        System.out.println("Reading Railroad    < RR >   = "+board[5]);
        System.out.println("Oriental Ave       [cyan]    = "+board[6]);
        System.out.println("Chance                       = "+board[7]);
        System.out.println("Vermont Ave        [cyan]    = "+board[8]);
        System.out.println("Connecticut Ave    [cyan]    = "+board[9]);
        System.out.println("Jail                         = "+board[10]);
        System.out.println("St. Charles Place  [magenta] = "+board[11]);
        System.out.println("Electic Company    (Utility) = "+board[12]);
        System.out.println("States Ave         [magenta] = "+board[13]);
        System.out.println("Virginia Ave       [magenta] = "+board[14]);
        System.out.println("Pennsylvania RR     < RR >   = "+board[15]);
        System.out.println("St James Place     [orange]  = "+board[16]);
        System.out.println("Community Chest              = "+board[17]);
        System.out.println("Tennessee Ave      [orange]  = "+board[18]);
        System.out.println("New York Ave       [orange]  = "+board[19]);
        System.out.println("Free Parking                 = "+board[20]);
        System.out.println("Kentucky Ave       [red]     = "+board[21]);
        System.out.println("Chance                       = "+board[22]);
        System.out.println("Indiana Ave        [red]     = "+board[23]);
        System.out.println("Illinois Ave       [red]     = "+board[24]);
        System.out.println("B&O Railroad        < RR >   = "+board[25]);
        System.out.println("Atlantic Ave       [yellow]  = "+board[26]);
        System.out.println("Ventnor Ave        [yellow]  = "+board[27]);
        System.out.println("Water Works        (Utility) = "+board[28]);
        System.out.println("Marvin Gardens     [yellow]  = "+board[29]);
        System.out.println("GO TO JAIL                   = "+board[30]);
        System.out.println("Pacific Ave        [green]   = "+board[31]);
        System.out.println("North Carolina Ave [green]   = "+board[32]);
        System.out.println("Community Chest              = "+board[33]);
        System.out.println("Pennsylvania Ave   [green]   = "+board[34]);
        System.out.println("Short Line RR       < RR >   = "+board[35]);
        System.out.println("Chance                       = "+board[36]);
        System.out.println("Park Place         [blue]    = "+board[37]);
        System.out.println("LUXURY TAX                   = "+board[38]);
        System.out.println("Boardwalk          [blue]    = "+board[39]);

        System.out.println("\nProperties:");
        System.out.println("purple  = "+(board[1]+board[3]));
        System.out.println("cyan    = "+(board[6]+board[8]+board[9]));
        System.out.println("magenta = "+(board[11]+board[13]+board[14]));
        System.out.println("orange  = "+(board[16]+board[18]+board[19]));
        System.out.println("red     = "+(board[21]+board[23]+board[24]));
        System.out.println("yellow  = "+(board[26]+board[27]+board[29]));
        System.out.println("green   = "+(board[31]+board[32]+board[34]));
        System.out.println("blue    = "+(board[37]+board[39]));
        System.out.println("RR      = "+(board[5]+board[15]+board[25]+board[35]));
        System.out.println("Utility = "+(board[12]+board[28]));
        System.out.println("chance  = "+(board[7]+board[22]+board[36]));
        System.out.println("chest   = "+(board[2]+board[17]+board[33]));
        System.out.println("Ooops  = "+(board[4]+board[30]+board[38]));

        System.out.println("\nThe board was traversed a total of "+loops+" times");

        System.out.print("\nRolls: ");

        for(int x = 1; x <= 13; x++) {
            System.out.print("(" + x + ") = " + rolls[x] + " ");
        }

                System.out.println("\n\n");

        }

        /**
         * This is where we will instantiate the Die objects
         * @param args the command line arguments
        */
    public static void main(String[] args) {

            JavaMonopoly game = new JavaMonopoly(args);

            // Instantiate away!
            Die die1 = new Die();
            Die die2 = new Die();
            //Die die3 = new Die();
            // Die1, 2, 3 are reference variables!
            System.out.println("Die 1's value is " + die1.getValue());
            System.out.println("Die 2's value is " + die2.getValue());
            //System.out.println("Die 3's value is "+ die3.getValue());

            System.out.println("your Total is: " + (die1.getValue() + die2.getValue()));

        }

}

Error saying JavaMonopoly game = JavaMonopoly(args); has to be static, but then my Die get errored out because they need to be static...

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - non-static variable this cannot be referenced from a static context
    at javamonopoly.JavaMonopoly.main(JavaMonopoly.java:183)

JavaMonopoly(args); has to be static

why should it? no, the error says you can't use this in a static context.

do you know what the this keyword is/does/refers to?

the code as you posted it doesn't even compile, so that's not producing any runtimeexceptions. just so you know... make your Die class static and try again.

You have created Die as an inner class, but there's no reason to do that. I would move the declaration of Die to outside the JavaMonopoly class.

This article has been dead for over six months. Start a new discussion instead.