Win a copy of Terraform in Action this week in the Cloud forum!

David Vach

Ranch Hand
+ Follow
since Oct 24, 2016
David likes ...
Chrome Java Windows
Cows and Likes
Cows
Total received
3
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by David Vach

Hi all, so what im trying to do is create a button that allows the player of my game to enter the number of players they want competing in their tournament. Then they enter the names of the contenders which gets recorded and stored in an array for use later. I created a playerList method to check if it was recording the names correctly, but it keeps returning null without any names. Im intending to use these names later to set up matches between players for advancement in the tournament, so this is a vital part of my project. If anyone could help it would be much appreciated. Thanks and have a great day!



This is the code i consider important to this part of the project. If you need it, I can post the rest of the code for the class, but that code does not effect what I am trying to do here.
4 years ago
Hi all, so this is a rather hard question to explain, but I will try my best. So I am creating a painting mini game for my first java game, which actually spawned from a failed attempt at something else funnily enough. But what I want to do now is create something on my paint object that allows the user to more easily see where they are painting. For instance, say the user is trying to fill a box with the color yellow for some reason (By the way, I like the way my paint game is right now, I only want to add this feature). As the user colors it in right now, it becomes harder for the user to track where their paint object is because it gets lost in the color. What I want to do is create an indicator, a color or even something at flashes for the user to know where their paint object is and then they can more accurately color in said box. This would be especially helpful if they switch to the color black, which I am using for the eraser on this game, since the background is also black (I know its not practical, but I do not have the time to learn how to make a proper eraser yet). I don't know if this is possible, especially since I want the color the user is using to paint to not be affected by the paint object identifier. You can more easily see what I mean if you examine or run the code below:



(Note) Ignore comments that say not to edit code in a method
4 years ago
Thanks guys, good suggestions. Ill look to attempt your suggestions when I have time.
4 years ago
Hi all, so I am currently making a tron game for my computer science class, and it is going quite well. However, one persistent issue that I am having which I have not been able to find an answer for is how to get java to detect a key release, at least for the way that I want it to detect it. What I am doing is that when a certain key is pressed, a boost in speed will be activated for that specific player. Now, I have been able to get the boost working, that is not the problem. My problem is trying to get the boost to stop. I want the boost to work only so long as the player holds down their button. I believe that this code should go in my keyRelease method in order for it to work, however I am not exactly sure how to do this. If anyone could help me, that would be much appreciated! Thanks guys!




And now for my game class



sorry it's so long guys, i believe its only in my keyRelease method in my TronGame class that needs work, but I wasnt completely sure.
4 years ago
Here is the code for my sorted methods. Sorry I didn't include it earlier, I could've sworn I did. Here is my full code:
4 years ago
To be completely honest, I'm not entirely sure. When I was having trouble with my linear method only returning the value -1, my teacher had me add in a lot of that extra code that you referenced above. I'm not sure what she was trying to have me do, as what she told me to add didn't seem to fit. To the best of my understanding each parameter is supposed to be referenced from the SortSearchApp class which print out all of this information. Hence this code:

       

which should be taking the original unsorted array from the SortSearchApp class and running it through the linear search method while comparing it to the array3merge which is already sorted to find the middle values in array3merge and find their equivalent location in the unsorted array. Im not really sure why I have those extra arrays in my Search class, my teacher had me add those even though they made no sense as to why they were added.
4 years ago
Hi all, so I have been practicing with linear search, binary search, and various other sorting techniques. However, I have only had success with my different sorting methods correctly sorting my randomly generated array. The problem I am currently having is that my linear array should be finding the location of my middle three elements in my original unsorted array and returning their location, while my binary array should just be searching an already sorted array(since binary requires the array to be sorted) and returning the location of the middle three values there. By location I mean index location. I believe my binary is working as intended, but my linear does not seem to want to cooperate and as much as I can figure out, it should be printing out its locations in the random array. It does this somewhat accurately when I comment out other code to narrow in on the problem, but at the sacrifice of the binary method working as intended. I'm not sure where to go from here. Here is my code:

4 years ago
Thanks Junilu, that looks a lot cleaner!
4 years ago
Alright I changed line 32. Is this better?



The change is now line 34.
4 years ago
Would changing the while loop to a for loop like:



make it iterative?
4 years ago
How could I change it to be iterative the if it is actually recursive?
4 years ago
Hi all, so essentially what I am trying to do is get my compiler to add the sum of my digits through both iteratively and recursively. However, when I try running my program, I get a StackOverFlow error: null at my iterative method. Im pretty sure that this is how my method should work. Am I missing something? Here is my code:

4 years ago
Yeah I definitely can. It also makes sense why you wouldn't want the compiler to go through adding 0 when it has no over all effect on the output. However, I still have two questions. Is there any difference between the two main methods that I made for this program and why would the recursive method encounter a StackOverflow over the iterative method?
4 years ago
Hi all, so I have been messing around with recursion and I found two different ways of getting my result from the main method. However, I'm not sure which is better to use or if both are just fine to use. Just some simple curiosity about the differences in using each or if there are any really at all. Thanks everyone! Heres the two different samples of code:



My other main method which uses the same recursive and iterative methods:



Just an inquisitive question.
4 years ago