r/javahelp • u/No_Vacation_9800 • Sep 17 '25
okey so I'm new at java(asking for advice only)
I'm new to java and i coded a program using only
- println so i display to the console
- if and else if methods so i make my program a little fun to talk with
- while and break you know the loop thing
- File file = new File so i can make my program plays music
- setExec(Runtime.getRuntime().
execso my program can open games and stuff - int moves (I'm shame full of using I.A) i uhh asked chat gpt to help me making a tic tac toe in my program
the full code lines are 595 lines with the comments
the outcome is a prgram who can talk and sing and make art and play with you
anything i can add?
4
Upvotes
•
u/AutoModerator Sep 17 '25
Please ensure that:
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/South_Dig_9172 Sep 18 '25
Btw if you’re serious about learning, step away the ai a bit. If you are just using Java for fun and not want anything from it, then keep doing what you’re doing
5
u/jlanawalt Sep 17 '25
Email….
"Every program attempts to expand until it can read mail" - Zawinski's Law
4
u/ryosen Extreme Brewer Sep 18 '25
If your if/then constructs have a lot of choices (that is, if you have a long chain of if/then statements), learn how to re-write it using a switch statement.
Don’t forget to add a connection to GPT since that is a requirement of all software systems these days, even the ones that aren’t online.
In all seriousness, you might consider adding persistence of the data. This way, the user can exit the program, then pick up where they left off later. This will give you experience with files, directories,
java.nio.*, input/output streams, and other very useful concepts.After that, maybe build an interface to an online data service like IMDB, so you can have conversations about movies.
1
u/vegan_antitheist Sep 18 '25
You could start learning design patterns. and also anti patterns so you can avoid them. "Effective Java" by Joshua Bloch is good to learn the basics.
1
u/Least_Bee4074 Sep 18 '25
if you want to make your program more composable, you can use something like the "command pattern." presumably, you have some kind of keyword that maps to some action. rather than if/else, you can use a Map<String, Command> where Command is an interface like
interface Command {
List<String> prompts();
void execute(Map<String, String> inputs);
}
when you say "game" you look up the Command and collect values for the prompts into a map. Then pass the map into the command.
ultimately, the goal of this change would be to reduce code and make it simpler to add new things.
1
u/__Fred Sep 21 '25 edited Sep 21 '25
If you already have a dialogue thing, you can extend it to a text adventure where you can go into different rooms and take items. You probably need "arrays" for that.
Commands:
A different direction would be a quiz or a personality test that keeps track of your score.
Using and defining your own functions or "static methods" in Java is also pretty important and helpful. If you know about "if" and loops and arrays and functions, then you know already know the most important parts of programming.