Daniel Hoang

Ranch Hand
+ Follow
since Apr 22, 2013
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
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Hoang

I dont think im allowed to edit the demo
5 years ago
Oh yeah, i didnt include that in my code example, oops. While i do have a set method, im trying a couple ways shown below, but still get a nullpointer. What else am i missing?



5 years ago
I have a Person class, a Name class, and a demo. What i need is to call a method from the Person class that calls a method from the Name class for the demo. Heres an example:




5 years ago
yes 0 means i havent got the number, 1 means i have. The condition i tried using for that loop is, keep rolling the die if none of the numbers in pattern have been matched. The while condition you quoted may be unneccessary, but i wanted to make sure the game would keep going until the six digit number has been matched. Maybe i could shorten it by making it } while ((gotSixth ==0)); since gotSixth ==1 can only be achieved if all the numbers before it have been matched. Also i know its hard to read, im not allowed to use methods or arrays. This is one game of 6, so i can only have a test and 6 classes for each game.
5 years ago
Yeah thats the problem, i cant seem to figure it out, im not sure if it still does it since i took out the System.out.printlns that showed me how my program was running, but heres my code now.
5 years ago
Well i got to it finally check for the entire pattern. But im having trouble getting the program to reset and try to roll for the first number whenever a number doesnt match. Right now, if i want to get 123456 and get a 1 on a roll, itll see if the next 5 numbers match 23456 before resetting. I want it to reset if i roll a 1 and dont get a 2 after.
5 years ago

Henry Wong wrote:
Also, for a topic named "Why wont these nested loops run?", it must be pointed out that there isn't a nested loop in the code.

Henry


oops
5 years ago
Sorry, let me try to be more specific. If i input that i want 123456 as my 6 digit number, the die will roll until i get a 1. Then on the next roll, if it lands on anything but a 2, everything resets and it has to land on 1 again before going to 2. If the die does land on 2 after a 1, then the next roll must be a 3 or the process resets until the 6th number is reached. But with the code i have now, it never reads the 3 after landing a 1 and 2.
5 years ago
But i need gotFirst to be 1, the 1's mean that the die rolled onto the first number out of six. so if the die doesnt land on the correct face, it will be given the value 0 and try to get the first number again, starting the process all over.
5 years ago
Im creating a program that asks the user for a 6 digit number consisting of dice face values, ex: 123456. A die will roll until the pattern 123456 has been rolled in that exact format, but for some reason, my third while loop in the portion of code ive shown wont execute. any ideas? I can show you the entire code if you need it
5 years ago
The entire game is looped once the player wants to play again, thanks your advice worked. My code is indented incorrectly? I dont get it, i tried to make all the indents even. And im not allowed to make another method.
5 years ago
Hi, i made a program that asks the user to input a number for the amount of times they want to roll a die. The die will roll a certain amount of times and count the number of times each face is landed on. Then display a chart that has the number of times the number was landed on in asterisks, like so
Please enter the number of times you would like to throw the die: 100
The chart showing 100 throws of the die:
1 ******************
2 ****************
3 **************
4 *******************
5 **************
6 *******************
Would you like to play the game again?
Please enter (yes/no) no

My problem is that when I input "yes" to play again, the variables in the code dont reset, forcing me to only input a higher number than the last time playing, and the asterisks save between each play. Here is my code. Can anybody clue me in on how i can get the game to reset properly? Thanks
5 years ago
I have figured everything out. Thanks everyone for the tips and help!
5 years ago

Tony Docherty wrote:

The cloning is in the test which i posted, here it is again.


Can you post the whole of the test code you have been given, I want to see how the test code creates a clone because the methods you have been told to implement do not include any sensible way of cloning/copying an object.

Heres what im working with now, im using the print to see if the method is calling correctly, which it is. But cloneName itself isnt capitalized which is where im stumped.


I suspect your toUpperCase() method should change each of the individual values in the object to uppercase and then return the concatenated values.



Ive actually figured out the cloning process in the test, and yes you were right about what i had to do! The full test is in my first post if you would like to see it. Im now trying to figure out how to print myName as: First Middle BridesLast-Last.
EX: myName is D D H, bridesName is 1 2 3. After being married myName will be D D 3-H, and bridesName will be 1 2 3-H
5 years ago
Heres what im working with now, im using the print to see if the method is calling correctly, which it is. But cloneName itself isnt capitalized which is where im stumped.


EDIT: I finally figured it out i think! This is what i ended up doing to get the cloneName to capitalize. Now onto the brides name
5 years ago