- create class name 'cart'
Cart attribute
int dx:
int dy:
int state;
int x,y; track coordinate on matrix
/*
if state == 1: turn left.(dx = -1)
if state == 2: turn straight(dy = 1)
if state == 3: turn right(dx = 1)
*/- read input. store in matrix(150x150)
- matrix representation
\/-|= '1'+= '2' arbitary' '(blank) = '0'- if see '<|>|v|^|'
- then create a object Cart. at that coor
- So now we have.
- one matrix of the map.
- an Array list of 'Cart' object.
- main Algorithm
- Iterate through array list of object. update the coordinate of each object base on 'dx' and 'dy' attribute of each. by lookingat the map matrix
- if object coor hit position with '2'(intersection) then update 'stage' attribute
- If 2 object have same coordinate then exit return that coor