Search

Wednesday, August 15, 2012

Day 7: Coding the translator



I updated the class design with this information:


  1. I need a class Translator. For now, it will be a new actor, so in the package Actors there is a new class. It have some methods.
  2. This class have two methods: coordinateToPosition, that translates a coordinate to a position in the array. It takes 2 arguments: the coordinate and the size of the board. The other method is positionToCoordinate that translates from a position in the board array to a coordinate.
  3. There is also a private variable, coord, that have all the coordinates first part. It is needed to change it to a number. For example A=0 (0 is the position and will be the value), B=1, etc.
The code:


This should work looking at the last post. Now, let's see if this works. For now, I will add a println in the main loop so when the engine sends a position it will write the coordinate.



And...



A 22x22 board:


That's it, next time I think I will start with some loop and then I think I will try to group.


No comments:

Post a Comment