Manuel Diaz

Ranch Hand
+ Follow
since Apr 22, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Manuel Diaz

Oh sry I forgot to mention, that when I input the die to re roll, my program re rolls everysingle dice, Why this is happening??
12 years ago
ok guys this is what i have so far
12 years ago


Now, I think you should write a method that asks the user which dice to keep. We will worry about how to re-roll the other dice after you get that method finished.

Layne



Yes man, but thats the point, I can't get it done
12 years ago

Originally posted by Layne Lund:
That's a great start. One comment: you can combine the first two lines into a single one. Also, you can put these few lines of code into a single method, say rollDice(). What will its return value and parameters be? Next, write a method that asks the user to enter which dice to keep. You can write yet another method to actually reroll the other dice, but worry about that later. When you get that far, post the whole class and we can keep helping you from there.

Layne

[ January 24, 2006: Message edited by: Layne Lund ]



OK so i added a reRoll method


How can I get the values of the dice random generated, cuz I need to ask the user if he want me to, which die to re-roll , plzz, can someone make that method for me, or explain me a bit more. I also need u guys to help me with how divide the random numbers into separate dies, for example, first number generated == die1, and so on, so in that way when the user asks me to re-roll let's say die number 4 and 5,how do only change those dice, plzz give me hand
12 years ago

Originally posted by Jim Yingst:
Understood. It's going to be hard if you try to replace the whole method at once, so I think you'll probably be better of sticking with the new short bit of code you just wrote, and "growing" it to gradually do all the things you wanted the original code to do.

So, what does this method (the short one you just wrote) print out? Does it print the same thing every time? Is there a way to can midify the code so that the results are random, like you're "rolling" the dice?



here's the thing Now that i use an array to generate 5 random dice, in a short form. But It's gettin a little bit harder for me trying to ask the user which dice to keep and which ones to re roll. And once the user says ok, I'm going to re roll 1 2 3, how can i re-roll, I'm stuck on that thing, this is what i have so far:


that's it, if you look to my first code, you'll se that the longest part of my code relays on the if statements used during re roll depending on user answer on which dice to re roll. Can you please tell me a shorter form to replace all those if statements
12 years ago
hey I'm sorry man, i forgot to create the dice on the loop random so I include this line

12 years ago
Lol, yes man, But I'm having a hard time , don't know how to create a loop for replacing my bunch of if statements
12 years ago
Ok I change it, sry about that
12 years ago
Ok, there you go Hope this helps

int dice [];
dice = new int [6];
for (int i = 0 ; i < 6 ; i++)
{
dice [i] = i + 1;
c.println(dice[i]);
}
12 years ago
OK,lol, this is not a college class, it's an grade 12 class. the point is that if I use loops, i have to explain why did i chose loops, and for. Which will make my documentation longer anyways. but ok, I'm gonna do that, but let's start by replacing my code, and once again, I'm stuck in that, cuz if a change my code again, and start using loops, I'll still have the same problem doing the scoring method. plzz give me a hand on this, I don't know how to replace my rolling dice method with a loop, and none of my code.
12 years ago
After each roll, The program asks the user for which di(c)e to keep, let's say, if there were 2 dice equals, the player should want to keep them, to get a better score once the total amount of rolls finished (3). So the program only re-roll the di(c)e left over. Once you decide which one to keep.

Hope this helps!
12 years ago
Ok, so are u guys gonna help me, or just criticize my code?
12 years ago
this is my teacher's code, he gave it to me, becasue I was doing a gui, but he wanted me to stop doing it because of it's complicity, in that way he decided to give the whole class a non-gui code. he want us to generate the methods by using the "primitive" and long way. Without for statements, and while and so on.So the thing is it does have to be that long, cuz we are not allow to use the for loops i wanted to use.
12 years ago
I'm doing a game in Java called Yahtzee, i'm sure some of u may heard about it. Well if you haven't this program is a game that rolls 5 dice 3 times, random generated dice, and it ask the user which di(c)e to keep after every roll. You only have 3 chances to roll the dice and once you decide which dice keep, you can re-roll the others left. So where is the point in this game, well depending on the value of dice you come up with, will be the total score you will make. Here a brief explanation of the scoring:

three of a kind (3 dice of the same kind)score: sum of all the dice
four of a kind(4 dice of the same kind)score: sum of all the dice
full house(2 of one kind, 3 of another)score: 25 points
small straight(4 consecutive numbers) score: 30 points
straight(5 consecutive numbers) score: 40 points
Yahtzee (5 dice of the same kind)score: 50 points
Chance (any combination) score: sum of all the dice

This is what i have so far:




AS u may notice, I haven't being able to come up with the scoring method, and thats what i need the most, if you guys can give me a hand on this, that'll be very helpful.
12 years ago
Thanks you all, I got it now.
13 years ago