Hello. I am new in Object Oriented Design. I am trying to write simple game where i can set labyrinth as array and add robot to this labyrinth. Robot can do simple actions: goahead(),turnRight(),turnLeft(). How to design this simple application in OOP style? Help me please
You could start by thinking about which objects you are going to need. A simple way to do this is decribe the game and check all the nouns in your description.
If I use your title as (very small) description, you will probably have a Game, Labyrinth and Robot object to start with.
Next, you should start thinking about how these objects communicate with eachother. For example, when a Game starts, a Labyrinth and a Robot will probably have to be created.
A robot should probably know about the Labyrinth, as would be in real life. So the goAhead() method should probably call some method of the Labyrinth to check if it is possible.
The robot should also know it's location, probably.
Adding some points after Fortega Answer and the question you asked in the comment.
1- For Adding Different Types of labyrinths ( though i don't know much about labyrinths but i am assuming that you want to add different objects (labyrinths )) based upon some conditon at runtime. If this is the case , You can Consider Factory Pattern here.
i am assuming labyrinths as a trajectory in which your robot will move.
If a tejectory is choosen by a robot then, Robot must complete this trajectory or die in the tejectory.
So when Robo is ready to move in the tejectory , it must ask trajectory service to give it a valid tejectory.
so you need a tejectory service which is totally responsible for creating , managing, Assigning tejectories.
And your Robot Class will use this sevice to get an tejectory.
till now,you got a robo and a tejectory to move on.
2-A robot will work according to the command issued ( Move To Left, Move to Right , Move UP, Move Down and so on...) a Command Issuer issues commnad and robo start moving, i think you would require a command pattern here.
these are some thoughts in addition to theForte