Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By pbrockway2

Thread: need help with program

  1. #1
    apescato is offline Member
    Join Date
    Oct 2011
    Rep Power

    Default need help with program

    i need help with this assignment my professor gave us. He wants us to create a type simple version of monopoly called opoly. This is my first semester doing java and i have no idea how to go on with this assignment please help. here is the assignment...

    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 straight linear track of variable length (you determine the length when you start up the game). There is only one playing piece, which begins the game just off the board, at position 0. Thus, if the board length is 20, then the board positions start at position 1 and end at position 20. To finish the game, the piece must land exactly on the last cell of the board (e.g., cell 20 in the example above).

    The object of the game is to acquire reward. The reward amount is initialized to 12. If your board piece lands on a board cell that is divisible evenly by 5, your reward doubles. However, if your piece lands one cell shy of the final board cell, your reward is reduced to 1/5 of its current value (via integer division), and your piece must go back to the start position - position 0. Note, though, that if the position of the last cell is divisible evenly by 5, then reward is doubled just before the game ends.

    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 advance value equally likely.

    Two additional rules:

    1) if a spin would move the piece beyond the end of the board, the piece should not advance at all (thus, if the piece is at location 18 of a 20 cell board, and if the spinner spins a 5, this is counted as a move but the piece remains at location 18.) If a piece doesn't move at all, its current reward amount should remain unchanged, even if the piece sits at a location that is divisible evenly by 5.

    2) if the next to last board location is divisible by 5, and if the piece lands on this location, the reward is reduced to 1/5 of its current value only - the reward is NOT also doubled. Example: the board size is 26, and the piece is at location 23, with reward 30. Suppose the spinner spins a 2. This puts the piece on the next to the last location on the board (25). This resets the reward to 6 = 30 * 1/5, and places the piece at location 0. Even though location 25 is divisible by 5, no doubling happens.

    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 - the size of the board");
    Scanner s = new Scanner(;
    int boardSize = s.nextInt();
    System.out.println("Board Size: " + boardSize);
    Opoly g = new Opoly(boardSize);

    Here is a sample run:

    > java OpolyDriver
    Enter an int - the size of the board
    Board Size: 20
    *O****************** 12 // current position is 2, current reward is 12
    ****O*************** 24 // current position is 5, reward is 24
    *******O************ 24
    **************O***** 48
    ********************O 96 // board size is 20, so reward doubles before game ends
    game over
    rounds of play 5
    final reward 96

    A requirement: your Opoly class must include and make use of the following methods, in addition to the Opoly constructor and principal method playGame(). These are:
    * spin - generates a 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. Feel free to improve on the display we've shown above.
    * 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 out the current position. Once you're satisfied with the general running of the game in this format, then work on the drawing part.

    * My board rendering is particularly klunky. If you like, you may devise a better way to draw the board. Of course make sure that you get the numbers right.

    Paste in your Opoly class in the box below:

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

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: need help with program

    Quote Originally Posted by apescato View Post
    i need help with this assignment my professor gave us. He wants us to create a type simple version of monopoly called opoly. This is my first semester doing java and i have no idea how to go on with this assignment please help. here is the assignment...
    Your question is too general to answer in any way other than to suggest you read your notes and study the Java tutorials. Also, please see the link below titled "So you need to write a program..." and use its suggestions to break the big problem down into little problems. If you're still stuck, then come back with your code attempts to solve your little problems. also talk to your teacher.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: need help with program

    Maybe you can contact your class mate:

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: need help with program

    Why do I keep seeing posts about this exact assignment, across multiple sites?

    Crossposted: Need help with creating Program
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  5. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power

    Default Re: need help with program

    This is not directed at the OP so much as @wholeClass: the internet is a great resource, but remember we are *people* not some AI resource dreampt up by google. We put *effort* into answering questions.

    So ask a specific question - include code and compiler messages, describe observed runtime behaviour (including error messages) and the behaviour you expected or intended. Engage in dicusssion: *think* about responses and respond to them.

    Treat us as colleagues sitting next to you. Not as passers by who might drop a code donation into your cup and pass on silently.

    Anyway, good luck (to all of you). These exercises/assignments are fun. Really.
    KevinWorkman likes this.

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2011, 12:57 PM
  2. Replies: 13
    Last Post: 03-22-2011, 06:49 AM
  3. changing my program to array working program
    By Chewart in forum New To Java
    Replies: 39
    Last Post: 11-18-2009, 06:53 PM
  4. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  5. Replies: 0
    Last Post: 10-04-2007, 09:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts