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 4 of 4

Thread: Simple java board game exercise

  1. #1
    Junior Member
    Join Date
    Jan 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Simple java board game exercise

    Hello i have recently started to learn java from book "Introductory Java" by David Parsons and i got stuck on exercises trying to go back all way and can't find how to do the exercise but even tho i would like to see how it should look like so maybe it will stuck in my mind if someone can help with that would really appreciate
    Exercises:
    1. Create a class called 'counter' to represent the type of counter used to play board games. It should have attributes to represent its colour and the number of the square it is currently on. It should have methods to set and return its colour. It should also have a method to move to a given position on the board using an integer parameter and another method to return its current position. The counter should begin on square zero(i.e., off the board) and its default colour should be white.
    2. Create a class called 'BoardGame'. This class should create two counters of different colours. For each counter, use a dice object to move it with four throws of the dice. Display the various positions of the two counters as they are moved.
    3. Many games insist that the player throw a six before being allowed to start. Use an 'if' statement to write a start BoardGame class that checks if the counters have thrown a six on the dice. To avoid too much tedious code, give each counter only two throws, and display whether or not either has thrown a six(and is therefore able to start). If a counter throws a six on its first go, move the counter on its second throw.

  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: Simple java board game exercise

    Do you have any specific java programming questions?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member azirafaelsish's Avatar
    Join Date
    Jan 2024
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Simple java board game exercise

    Hmmm I love simple games, but now I'm too busy to play for a long time to get some wins

  4. #4
    Junior Member tiamatzzo's Avatar
    Join Date
    Jun 2023
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Simple java board game exercise

    I'd suggest focusing on creating a Counter class. Define attributes for color and position, and methods to set and return the color, move the counter to a given position, and return its current position. Remember, the counter starts on square zero by default with a white color.
    In the BoardGame class, you'll create two counters of different colors and use a dice object to simulate movement. Implement the logic for throwing a six before starting the game, and display the positions of the counters as they move.
    And hey, if you need a breather from coding, why not take a break and enjoy a game of Spades? It's a classic card game that's perfect for unwinding and having some fun.
    Last edited by tiamatzzo; March 4th, 2024 at 10:09 AM.

Similar Threads

  1. Problem in my 2-Dimensional Array Board Game
    By rodneybunkley in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 14th, 2024, 11:52 PM
  2. Help with assignment about a board game (enum and array question)
    By Kranti1992 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 12th, 2012, 07:47 AM
  3. Java TV Board Game/Grid + Moving objects
    By Massaslayer in forum Java Theory & Questions
    Replies: 6
    Last Post: December 13th, 2011, 08:03 AM
  4. help with board game assignment
    By pjay in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 19th, 2011, 12:58 PM
  5. DOS board game
    By SageNTitled in forum Java Theory & Questions
    Replies: 5
    Last Post: March 4th, 2010, 03:53 PM