On Thu, Apr 18, 2019 at 10:01 AM Roelof Wobben <r.wobben@home.nl> wrote:
yep, I have read that one
but I never gets a answer how I can "convert"�� a point to something like north, east
because the challenge wants this to be the answer :
(Dictionary new
������ ������ ������ ������ add: 'direction' -> 'north';
������ ������ ������ ������ add:
������ ������ ������ ������ ������ 'position'
������ ������ ������ ������ ������ ������ ->
������ ������ ������ ������ ������ ������ ������ (Dictionary new
������ ������ ������ ������ ������ ������ ������ ������ add: 'x' -> 0;
������ ������ ������ ������ ������ ������ ������ ������ add: 'y' -> 0;
������ ������ ������ ������ ������ ������ ������ ������ yourself);
������ ������ ������ ������ yourself)
If you have previously defined a "representation map", you would be golden.
e.g.Dictionary newat: self northDirectionVector put: 'north';at: self eastDirectionVector put: 'east';at: self southDirectionVector put: 'south';at: self westDirectionVector put: 'west';yourself.
Then:(Dictionary new
������ ������ ������ ������ add: 'direction' -> (self directionRepresentationMap at: self directionVector);...
and I think I need then to use if then , which I try to avoid as much as possible.
Roelof
Op 18-4-2019 om 18:33 schreef Richard Sargent:
On Thu, Apr 18, 2019 at 8:57 AM Roelof Wobben <r.wobben@home.nl> wrote:
Hello,or tried without it but then I use a lot of if then's
I know I have asked earlier but im still stuck on this one : https://github.com/exercism/problem-specifications/blob/master/exercises/robot-simulator/description.md
so it�� there�� a better way to model this problem so it will be all nice and readable code.
If I remember correctly, Richard O'Keefe gave you a viable design. 1) Use a Point for your direction vector. 2) Use a second Point for your position.
e.g. if you align the compass with a Cartesian plane, 0@1 is North, 0@-1 is South, 1@0 is East, and -1@0 is West. When you move, you add the direction vector to your current position. If you allow movements of greater than a single unit, you multiply the direction vector by the distance before adding that product to the position.
Roelof