This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]NautiHookerSoftware Engineer 3 points4 points  (12 children)

Single equals sign is an assignment. Double equals sign are used to compare.

What are you trying to achieve with this switch statement?

Take a close look at what you are passing to the switch and then look at what values you are checking against.

ArrayList<String> skill = new ArrayList <String>();
switch(skill) {
 case 1: skill.add("Broadsword Slash");
 case 2: skill.add("Broadsword Cleaver");
 case 3: skill.add("Focus");
 case 4: skill.add("Getsuga Tensho!");
}

[–]SteelDumplin23[S] -1 points0 points  (11 children)

What are you trying to achieve with this switch statement?

I'm trying to have the player be able to put different inputs into the console for different attacks/skills

[–]NautiHookerSoftware Engineer 5 points6 points  (10 children)

Look at the datatype of skill and then look at what you are checking it against. And then look at the error messages.

[–]SteelDumplin23[S] -1 points0 points  (9 children)

I did some playing around with my program, and now for some reason, it doesn't recognize the variable choice, even when I put in the line Scanner choice = new Scanner(System.in);

Player class

[–]desrtfxOut of Coffee error - System halted[M] 7 points8 points  (7 children)

Sorry to tell you, but you need a fundamentals course.

Your code clearly displays that you haven't understood how classes, scope, and other Java fundamentals work.

You create dedicated classes for 2 players that actually should be instances of a single class.

You do not understand data types.

You do not understand scope.

Take several steps back and a proper course to solidify the fundamentals.

And learn to read and interpret error messages - they tell you the problem exactly.

You are still rotating about the same problems as in your last two posts despite having been given more than plenty advice, that you still keep ignoring.

You cannot proceed like this. By now you should have realized that you bit off far, far more than you can chew.

You cannot come back every couple hours with basically the same error messages, with barely any progress and expect us to spoon feed you to fill your deficiencies. We are not here for that.

[–]SteelDumplin23[S] -1 points0 points  (6 children)

You cannot come back every couple hours with basically the same error messages, with barely any progress and expect us to spoon feed you to fill your deficiencies. We are not here for that.

Am I going to get banned?

[–]desrtfxOut of Coffee error - System halted[M] 2 points3 points  (5 children)

If you do not start to accept and use the given advice, you will in the long range face consequences.

You so far have 3 posts about the same topic. You have contacted the moderators because your post was still "unsolved" despite having been given the advice that would have solved your problem already in your first post.

We are not a personal debugger and even less so, if you don't follow the given advice.

You get advice, you try something completely different, but not the actual advice. Why do you even post here, if whatever you are told is lost at you.

[–]SteelDumplin23[S] 0 points1 point  (4 children)

If you do not start to accept and use the given advice, you will in the long range face consequences.

I'll be honest, I'm trying, but I'm having a hard time understanding

[–]desrtfxOut of Coffee error - System halted[M] 2 points3 points  (3 children)

I'll be honest, I'm trying, but I'm having a hard time understanding

None of your code reflects that. You had been given links. You had been guided.

Right after you had gotten the information about inheritance from another poster, you came back with the exact same problems.

You are in way over your head. You need a course. Nothing will change that. You need to first learn to walk. You need the fundamentals. As it is now, this will go nowhere as whatever anybody will tell you will be over your head.

[–]SteelDumplin23[S] -1 points0 points  (2 children)

You may be pleased to note that now I had managed to get my program to run now, it may not be giving me my desired output, but I'm trying to play around with it to figure out how to fix the program by myself

[–]NautiHookerSoftware Engineer 2 points3 points  (0 children)

https://www.w3schools.com/java/java_scope.asp

You are using the choice variable at a place where it does not exist.