Basic OOP having trouble determining how to handle methods
Hey. Thanks for taking a look,
I'm working on a class assignment that creates a "Space Merchant" game where you buy and sell commodities and travel to complete missions. My part of the assignment is broken up to six classes (Commodity, Ship, Player, Location, Mission and SpaceMerchant) where I am given the instance methods, I just have to fill them out based on their description. Also included in the program are four completed classes (World, Pair, Action, and UserInterface). Since there is so much involved, I've decided to not post my code directly on here but make a rar file including my progress on the six classes, the JAR file including the four given classes, and the text based world.
It is located here: SpaceMerchant.rar (Mediafire link that takes you to the download, not a direct download)
I'd like to think I'm pretty far in the assignment but still have some lingering issues
In the Player class, I am unsure of how to complete getMission and setMission. I've noticed that the return variable for one is the given parameter for the other. I'm unsure if they have a relationship or if they should be developed completely different.
In the Mission class, I have the same situation with isComplete and setComplete.
Finally, I'm stuck on the SpaceMerchant class. This is the class that is responsible for putting everything in motion including loading the world. I heard my lecturer explain to another student that a switch or if/else if tree is needed (that's why you see the beginning of one in my code). Beyond that, I have no idea and I'm hoping for a little direction.
I realize this is a lot to ask, and I'm very appreciative of those willing to give it a shot. I'm really stuck and could use any advice or even a point in the right direction.
Re: Basic OOP having trouble determining how to handle methods
I doubt many will download a rar to look at some code, but getMission and setMission presumably deal with a mission, so you'd expect setMission to take a Mission argument and getMission to return a Mission. Usually, in setMission, the Mission would be stored in a class variable, and getMission would return that variable. Similarly for isComplete and setComplete. The Java convention for methods returning a boolean value is to call them isXxxxx rather than getXxxxx because it makes the code read better. But they're usually handled similarly - setComplete sets a boolean class variable and isComplete returns that variable. Of course, the setXxxx methods might do some other stuff related to setting the relevant variable, but more often than not, they just set the class variable.
As for SpaceMerchant, hoping for a little direction is a bit vague. You need to explain exactly what the bit you're having trouble with is supposed to do, and why you're having trouble with it. Posting some relevant code wouldn't hurt either.