Each edge of the spiral is of square longer than the preceding one. A simple loop draws the edges, increasing the length in each iteration:

public void myProgram() {
  final int MAX_LENGTH = 20;
  int d = 1;

  while (d < MAX_LENGTH) {
    walk (d);
    kara.turnRight();
    d ++;
  }
}