• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class work help (Dice Class and DiceClient Class)  RSS feed

 
Paul D Pearson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is my very first post and I'm, as you can see, quite new to Java.  35 y/o breaking my way into this world. 
I have found "Building Java Programs" 4th ed with website Practice-It to be the single best resource/s out there for someone like me that has ZERO programming experience.





[HENRY: fixed code tags]
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Please UseCodeTags (←click that, it's a link) when posting code. Code tags preserve formatting and indentation and they make it much easier to read properly formatted code.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding #1 Create a new Dice class name TwoDice. EDIT: Sorry, my bad, misreading what was posted. The part of the comment below that isn't stricken out still applies though.

That doesn't make a lot of sense. Are you sure that's what the instructions say? Maybe it just says "Create a new class and name it TwoDice" - that makes more sense.  Also why would you name the class DiceClient when the instructions tell you to name it TwoDice?
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like this exercise assumes you have already defined the Dice class. Have you done that? Does that code that you posted even compile? If not (and I'm betting it doesn't), what are the compiler errors reported?
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you already have a Dice class, you haven't followed #3 correctly. Look at the Dice class again and find the constructor that #3 refers to.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You haven't done #4 correctly either. What the instruction is telling you to do is figure out how many different outcomes you can have if you roll both dice. Obviously, the first outcome would be snake eyes (both dice show 1). How many other outcomes are there?

#4 tells you to figure that out and create an array that can hold that many ints. This is in preparation for what you'll be asked to do later in the exercise, which is to count how many times you get each particular outcome over X number of rolls.

EDIT: The above assumes that Dice.getNumberShowing() does what you'd expect a method named that to do, which is to show the number that's showing after you "roll" the dice. That number is not necessarily the highest number that could be shown by the dice. Is there another method of the Dice class that tells you how many faces there are? That's probably the method you want to call instead of getNumberShowing, assuming of course that if a die has 8 faces, then the faces would be numbered from 1 to 8 and a die with 11 faces would have faces number from 1 to 11.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#5 - you haven't followed the part that says "with the maximum being the value of a variable" - on line 40 you hard-coded the maximum instead.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!