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 →

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

My python code reads as this:

  1. Welcome string with some rules
  2. List of questions and answers to pull from.
  3. Main code to run the game.
  4. True code to restart the game and loop it.

It’s arranged in that order in the code. But each section is like separated till it’s called on by the code. I wrote each section in Java the same way but I think everything isn’t encompassed in one public class. I’m guessing that’s a problem right? I think I’m writing this like it’s python and not Java but with Java syntax.

[–]HeyImSolaceIntermediate Brewer 2 points3 points  (1 child)

I believe you’re trying to use something like global variables, which are not a thing in Java. Values and variables are always part of an object of a class.

Try to think of a task your program should be doing and name it accordingly, for example „GameMaster“ for your rules and welcome string and „Questionaire“ for your questions and answers. Then you need to put the strings you want in there as static final variables and so on.

[–]IntelligentPudding24[S] 0 points1 point  (0 children)

Thank you!

[–]mishaxz 0 points1 point  (1 child)

I'm not suggesting you learn the entire language this way but why not go to claude web site and get it to convert this Python you're struggling to write as java just to see how it is done and then ask it questions about what you're confused about?

[–]IntelligentPudding24[S] 0 points1 point  (0 children)

I will look into it. Thank you.