java implementation of snake