The Artima Developer Community
Sponsored Link

Java Answers Forum
need help in java

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
hyderman

Posts: 11
Nickname: salem99
Registered: Oct, 2002

need help in java Posted: Oct 29, 2002 5:24 PM
Reply to this message Reply
Advertisement
Please please help me, I am having alot of difficulty doing a program in Java, I'm new to this programming language and would much appreciate your help! This is the program, I need to make, could you please reply, with how I should do it?

Write a program that simulates a game of dice. In this game, players take alternate turns rolling two dice. On each turn, they record the sum of the two dice and add this to their total. If a player rolls a doublet (both dice have the same value), then the player gets to roll again. However, if the doublet is "snake eyes" (both dice have a value of 1) or "box cars" (both dice have a value of 6), then the player loses their next turn instead. The first player to reach a total of 75 will win.


For example, if games went to 20 (instead of 75), the output should be as follow (note: no user input is required):


Example 1:


Player 1 rolls a 3 and a 3

Player 1 now has 6

Player 1 gets to roll again

Player 1 rolls a 5 and a 1

Player 1 now has 12

Player 2 rolls a 5 and a 1

Player 2 now has 6

Player 1 rolls a 5 and a 6

Player 1 now has 23

Player 1 wins with a total of 23


Example 2:


Player 1 rolls a 4 and a 6

Player 1 now has 10

Player 2 rolls a 4 and a 1

Player 2 now has 5

Player 1 rolls a 2 and a 5

Player 1 now has 17

Player 2 rolls a 6 and a 3

Player 2 now has 14

Player 1 rolls a 1 and a 1

Player 1 now has 19

Player 1 loses a turn

Player 2 rolls a 1 and a 2

Player 2 now has 17

Player 2 rolls a 3 and a 5

Player 2 now has 25

Player 2 wins with a total of 25



also:
the rolls do need to be random for every roll of the two dies, so, I think you need to use the Math.Random command or something for every roll:)

Topic: Singleton Previous Topic   Next Topic Topic: Substr in a function

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use