private Vector get_line(location from, location to) {
location nextLoc = new location();
Vector loc = new Vector();
Random r = new Random();
if(to.r == from.r && to.c == from.c) {
return(loc);
} else {
if(to.r > from.r && to.c > from.c) {
nextLoc.r = from.r + 1;
nextLoc.c = from.c + 1;
} else if(to.r < from.r && to.c < from.c) {
nextLoc.r = from.r - 1;
nextLoc.c = from.c - 1;
} else if(to.r < from.r && to.c > from.c) {
nextLoc.r = from.r - 1;
nextLoc.c = from.c + 1;
} else if(to.r > from.r && to.c < from.c) {
nextLoc.r = from.r + 1;
nextLoc.c = from.c - 1;
} else if(to.r == from.r && to.c > from.c) {
if(r.nextInt(2) == 0) {
nextLoc.r = from.r + 1;
} else {
nextLoc.r = from.r - 1;
}
nextLoc.c = from.c + 1;
} else if(to.r == from.r && to.c < from.c) {
if(r.nextInt(2) == 0) {
nextLoc.r = from.r + 1;
} else {
nextLoc.r = from.r - 1;
}
nextLoc.c = from.c - 1;
} else if(to.r < from.r && to.c == from.c) {
nextLoc.r = from.r - 1;
if(r.nextInt(2) == 0) {
nextLoc.c = from.c + 1;
} else {
nextLoc.c = from.c - 1;
}
} else if(to.r > from.r && to.c == from.c) {
nextLoc.r = from.r + 1;
if(r.nextInt(2) == 0) {
nextLoc.c = from.c + 1;
} else {
nextLoc.c = from.c - 1;
}
}
loc.add(nextLoc);
return(get_line(nextLoc,to)); //stack overflow error occurs here.
}
}