Hey all,
I'm trying to create a text-based movement simulator for my little pet MUD project. It consists of six classes:
Room.java: Instance variables for x-y location, list of mobs in the room, name, short descriptive narrative, etc.
Grid.java: Instantiate an ArrayList<Room>, create two Rooms and add them to said arraylist.
Mob.java: Contains the framework for your basic player or creature
unit. All the instance variables including the now-relevant currentRoom and x/y integers, and the perhaps later relevant attackStrength etc. Also behavioural methods like move(
String direction) and look();
Input.java: Contains the method directory, which tests player input against various different possible commands.
GameHelper.java: Knows how to capture keyboard input.
Tester.Java: Instantiates all the above classes, loops GameHelper.getUserInput() and Input.directory().
For the most part, the code works (save for the fact that when you move the wrong look() is reported, due to setLoc() not being utilized yet, due to the fact that I don't know how to access my list of rooms from Mob.java, because it was instantiated in Tester.java), but it's terribly clunky, and I know it. Grid.java for example only contains two rooms, because it's system for implementing rooms is a huge hassle.
Basically for any and all advice on how to tighten my code up, so that I can get a better practical understanding of
Java. Thus far I've learned up to and including interfaces in the Head First book, and I feel like I understand most of the concepts which I've learned thus far, but as far as implementing them...well...I can tell I'm missing a few tips and tricks.
Thanks a ton!
(I'll reply to this post with the code)