Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: help me!!! opoly project

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help me!!! opoly project

    So my counselor signed me up in an AP Computer Science class this year(YES, I'm the only girl). I had no idea that I would be programming in Java, and I was pretty scared since I didn't take any of the introductory classes. Anyway, we were given a project, and although I have come a long way from what I started, I have no idea how to do it. Please help?

    For this assignment, your job is to create a kind of lobotomized version of a board game (such as Monopoly) called Opoly.

    Opoly works this way: The board is a circular track of variable length (you determine the length when you start up the game). There is only one player, who begins the game at position 0. Thus, if the board length is 20, then the board locations start at position 0 and end at position 19. The player starts with a reward of 100, and the goal of the game is to reach or exceed reward value 1000. When this reward value is reached or exceeded, the game is over. When the game ends, your program should report the number of turns the player has taken, and the final reward amount attained.

    In Opoly the game piece advances via a spinner - a device that takes on the values 1-2-3-4-5 at random, with each of the five spin values equally likely.

    Although the board is circular, you should draw the state of the board as a single "line", using an 'o' to represent the current player position, and * represent all other positions. Thus if the board size is 10, then this board drawing

    **o******

    means that the player is at location 2 on the board.

    Here are the other Opoly game rules:

    1) If your board piece lands on a board cell that is evenly divisible by 7, your reward doubles.

    2) If you land on the final board cell, you must go back 3 spaces. Thus if the board size is 20, the last position is position 19, and if you land there, you should go back to position 16. (If the position of the last cell is evenly divisible by 7, no extra points are added, but if the new piece location, 3 places back, IS evenly divisible by 7, then extra points ARE added).

    3) If you make it all the way around the board, you get 100 points. Note that if you land exactly on location 0, you first receive 100 extra points (for making it all the around), and then your score is doubled, since 0 is evenly divisible by 7,

    4) Every tenth move (that is, every tenth spin of the spinner, move numbers 10,20,30,... etc.), reduces the reward by 50 points. This penalty is applied up front, as soon as the 10th or 20th or 30th move is made, even if other actions at that instant also apply. Notice that with this rule it's possible for the reward amount to become negative.

    Here is the driver class for the game:
    import java.util.*;

    public class OpolyDriver{

    public static void main(String[] args){
    System.out.println("Enter an int > 3 - the size of the board");
    Scanner s = new Scanner(System.in);
    int boardSize = s.nextInt();
    System.out.println("Board Size: " + boardSize);
    Opoly g = new Opoly(boardSize);
    g.playGame();
    }
    }

    Here is a sample run:

    > java OpolyDriver

    Enter an int - the size of the board
    [DrJava Input Box]
    Board Size: 17
    o**************** 100
    *o*************** 100
    *****o*********** 100
    **********o****** 100
    ************o**** 100
    o**************** 400 // 100 added to reward, then score is doubled at location 0
    ****o************ 400
    ********o******** 400
    **********o****** 400
    *************o*** 400
    o**************** 900 // 10th turn - so reward reduced by 50; then 100 added; then score doubled
    ***o************* 900
    *******o********* 1800 // at location 7, so score doubled
    game over
    rounds of play: 12
    final reward: 1800


    A requirement: your Opoly class must include and MAKE ESSENTIAL USE OF the following methods, in addition to the Opoly constructor and principal method playGame(). These are:
    * spin - generates an integer value from 1 to 5 at random
    * move - advances the piece
    * spinAndMove - spins the spinner and then advances the piece according to the rules of the game (uses spin, move methods)
    * isGameOver - checks if game termination condition has been met
    * drawBoard - draws the board using *'s and an o to mark the current board position. Following each board display you should also report the current reward.
    * displayReport - reports the end of the game, and gives the number of rounds of play, and the final reward



    How to proceed:

    * First, decide on the attributes for the Opoly class. At any instant, what is the "state" of the board? What do you need to keep track of to give the final report? The answers to these questions will tell you what the attributes to Opoly can be.

    * Second, write the Opoly constructor.

    * Third, try to write the playGame method using the methods outlined above. A good way to proceed is to write a "dummy" drawBoard method first - instead of having it draw anything, merely have it print the current position. Once you're satisfied with the general running of the game in this format, then work on the drawing part. Another simplification to start with: just implement the rule that increases the reward by 100 every time you circle the board. You can add the other rules later.

    Paste your Opoly class code in the box below:

    NOTE: you may NOT use any import statements in your class. Use the Math class random method to generate your random numbers. Do NOT import the java.util library. Do NOT implement your solution using arrays.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: help me!!! opoly project

    What have you done so far with the project? If you have any specific questions about the program you are writing, post the code and your questions.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: help me!!! opoly project

    Well this is the structure I was given. I really just don't know how to start, and I'm not sure how this would be done without using arrays.

    private int ;
    private int ;
    private int ;
    private int ;

    public Opoly(){
    }

    pubolic int getPos(){
    }

    public int getSteps(){
    }

    public int getReward(){
    }

    public int getBoardSize(){
    }

    public int spin(){
    }

    public void move(){
    }

    public boolean isGameOver(){
    }

    public void spinAndMove(){
    }

    public void drawBoard(){
    }

    public void playGame(){
    }

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: help me!!! opoly project

    You need to give unique names to all of the int variables.

    Not allowing arrays is a strange requirement. Any idea why? What is the learning objective?
    Are you expected to use some classes instead of arrays?


    In the future when you post code be sure to wrap the code in code tags:

    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: help me!!! opoly project

    So would the variables be position. reward, boardSize, and round? Well we hadn't learned arrays yet when we were assigned this project but I was stumped and moved on to the next lesson. The assignment states not to implement arrays so I'm assuming that there's another way to do this without arrays?

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: help me!!! opoly project

    The required variables should be gotten from the program requirements and possibly added to as you write the program as the need arises.

    If array's don't come until the next lesson, then they are probably not needed.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. I need help for my project
    By GCollector in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 19th, 2013, 10:44 AM
  2. Opoly game
    By ksahakian21 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 15th, 2012, 01:50 PM
  3. Can anyone help me on my project?
    By alesana514 in forum Paid Java Projects
    Replies: 1
    Last Post: December 16th, 2009, 09:24 AM
  4. Need Help With Project
    By jstew132 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 11th, 2009, 07:15 PM
  5. Need a project
    By helloworld922 in forum Project Collaboration
    Replies: 6
    Last Post: July 31st, 2009, 08:30 AM

Tags for this Thread