Thomas Anderz

Greenhorn
+ Follow
since Jul 02, 2019
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
2
Given in last 30 days
2
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Thomas Anderz

But isnt that exactly what im doing already? With this
1 week ago
Hello guys,

I tried to write a Tic Tac toe game today and I will hopefully learn to set up a GUI for it soon.
I did it all in one class - assinged numbers from one to nine and im letting the user pass the numbers the players want to occupy into Array Lists.
If one of the ArrayLists assinged to a player (either cross or circle) containts certian numbers (meaning if the player occupies certian squares 3 in a row) one player wins.

I do have a while loop for the progress of the game that does work, but it just doesnt feel practical to jam the definition for my variable "winCheck" 5 times there.



Without those definitions the second part with moveCirclePlayer(*) method is called one time too much.
Depending on how the game plays out, the "winCheck" definitions are required on different places.

Do you have an idea on how I can structure it so that the moveCirclePlayer(*) method doesnt execute again?
1 week ago
Thanks for the responses!
I just started all over again, and considered cases like dividing by 0.
I initially thaught of Lists and arrays because I wanted to make it possible to always add another number by user input but its more elegant if I just call the Method again or create a different one I guess.
I have looked into the main method thread - thank you!

And I did not think, that an array list is generally an uneficient data structure. I just thaught it might not be suited very well for this case. I originally wanted a programm that calls the method which then passes the number of required array list entries to the main method and then calls the calculation method.
I was thinking that the machine will do different things during this process and if there are 5 entries created one by one it wont happen at the same time, which causes the machine jumping around in the memory because it will do other tasks in between - i just thaught there had to be a better way!

And yes youre right! Thats probably the smallest of my worries right now :P

Anyways,
Thank you both for your help and the warm Welcome @Ritche Campbell.

Good night from Germany!
2 weeks ago
Thank you, works great now!
Now I can go to bed peacefully <3
I think I will try to split it up next time functions like Math.pow just make it hard to read :$
2 weeks ago
Hello, a problem just arose!

I have a Method in my Calculator class to calculate the solutions for a Quadratic Equation
Code looks like this:



I must have made a mistake in the block of calculations but I cant seem to find it.

Normally the solution should be x = -b/2a +-sqrt.(b^2/4a^2-c/a) (I also put a more clear formula in the attatchement but I didnt to +- there)  when the equation has the form of ax^2+bx+c=0 right?

Also how does one do this more elegantly when programming? Those calculations are an absolute mess!


Thanks guys!
2 weeks ago