I think we can use only one variable for both score and foodIndex. Since before ending the game, the score and foodIndex are same. After the sneak touch the border or itself body, the game will over. And there are no more move. So I think case 0 will not used. Correct me if I am wrong.
Design Snake Game