So, I have an assignment in beginning java in which 3 guys (Aaron, Bob, Charlie)shoot at each other until 1 is left standing.
Aaron shoots first and hits with 33% accuracy.
Bob shoots second and hits with 50% accuracy.
Charlie shoots last and hits every time.
Each shooter aims for the best shot (so Aaron and Bob would shoot at Charlie if he was still alive).
We have not yet studied inheritance and I'm a beginner so go easy on me.
Here is what I have. I have not yet included a main method and I've been working at this for too long...please help me out.
The last method is giving me an error, which I understand, but I don't see any other way to do it.
Should each shooter have his own class? How can I check to make sure at least two people are alive after each round?
You can shorten those methods; look at these conventions for a hint how to do it.
You should never use == true or == false or similar. Miss out == true throughout, and use the bang operator ! instead of == false.
There is something very wrong with a design where a class has details of potential objects. The class should never know that its instances might have names like Charlie. Even less when those names are in other objects. You need to think again about those methods; that is something which ought to be implemented from outside the class.
Accuracy of shooting is something which should be inside the class. As you have been told, accuracy is a field of the class, and the shoot method uses that field. Those fields should not be static, otherwise each duellist would have the same number of lives, and all would die together.
I actually think you need to go back to the drawing board. Create the class, as you have already been told. Create rules for how the Duel class would run the duel. Don’t code anything until those rules are working all right.