An object on the playing field can have one of two states: it can be alive (isAlive=true) or dead (isAlive=false).
For example, if the snake hits the edge of the playing field, it dies. The same thing happens to an apple when it is eaten by the snake. To store object state,
create a boolean isAlive
Snake (Part 7/20)
- 3
Locked
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
Ian De Bie Full Stack Developer
21 July 2020, 03:51
they make you put the enum in a separate file or you won't pass this lesson
+3
Guadalupe Gagnon
19 February 2021, 15:30
It says that it should be a public enum. Class files can only have one public class/enum/interface per file, not one of each but only one. Java code will not compile if you have more than one public in the same file, which means that you would couldn't put a public interface in the file that already had a public Snake class.
0
Nikesh
17 January 2020, 15:44
I have created private Direction direction and setter for it but still last two requirements are not getting fulfilled. Please help.
0
Laura
10 March 2020, 15:48
I had the above problem until I realized the file with the enum needs to be empty save for the enum declaration - when it was inside the class, it wouldn't work.
0