Please do the TODOs correctly please, thank you!
ort bridges.base.NamedColor; ort bridges.base. NamedSymbol; ort bridges.games.NonBlockingGame; lic class SnakeScaffold extends NonBlockingGame\{ java.util. Random random = new java.util. Random(); static int gridColumns =30; static int gridRows =30; final long FRAMERATE =1000000000/15; int startX = gridColumns / 3; int startY = gridRows /2; int startlength =3; long frametime; long nextFrameTime; II define the snake and apple with the Block object type Block head; Block tail; Direction dir; Block apple; Block bomb; Direction 1astDir; NamedColor bg= NamedColor, forestgreen; NamedcolorNamedColor=Namedcolor,silver; NamedColor he = NamedColor, white; NamedColor ac = NamedColor public Snakescaffold(int assid, String login, String apiKey, int c, int r) \& super(assid, login, apikey, c,r); 3 II keep track of user interaction to move the snake public void handleInput() \{ II update snake position public void updateposition() \{ Block current = head. next; int nextr = head. x; int nexty = head. int nexty = head, y; Block nextros = head; int temp X= current, x; Int tempy = current, y; current, x= nextox; II TOD0: choose a new location for the apple II given a randomly generated x and y location, loop over the block linked list, 11 and make sure the generated x and y location isnt on the snakes position. //Alsp be sure that the apple isnt placed at the position of the bomb. public void plantepple() ? public void plantApple() in int y; While(true){x=Math.abs(randon.nextInt()29);y=Math.abs(randon.nextInt()29); I/TODo check the apple location is good break; //TODO check the bonb location is good break; II redraw the board with snake and apple updated positions publice vold paint() \& for (Int 1. 0; is eridcoluans; ++1 ) \{ for (Int }=0;j s gridRows; +4j) \{ if (12=12) setascolor (j,1, be ); 33 seteccolor(j, 1, bc); setaccolor(head. y, head. x, he); dransymbol (apple.y, apple.x, Nanedsynbol, apple, ac); drawsymbol(bonb, y, bonb, x, Manedsynbol.bonb, ac); Dlock current = head.next; thile (current i= nu11) ? seteccolor (current. y, current . x,f(b); 3current=current.next; 3 II Set up the first state of the gase grid I/ITcoo: Init a queve of blocks that represent the snake. I/ the head and tall pointers are currently not initiolized. public void initiolize () 1 Systen-out.printen( "initlearize"); public void initialize() \{ Systen.out.println("initialize"); for (int i=0;i nextFrasetime) f frametime = Systen,nanotine( ); nextFraneTime = franeTine + FRAMERATE; Lastoir = dir; detectApple(); detectBonb(); updatePosition(); paint(); detectbeath(); 33 public static vold main(String ares[]) Snekefent Snakescaffold gane = new Snakescaffold(22, "test", "137842425086", grdColuens, eridrows); 1 came.start(); I/TOoD: Handle enqueve of a new block to the 1inked 1ist, the tail is the last position in the linked list, Iext is the new block to enqueue. //TODO: Handle enqueue of a new block to the 1inked 1ist, the tail is the last position in the 1inked 1 ist, I/ next is the new block to enqueue. I/Return the tail of the 1ist. public static Block enqueue(Block tad1, Block next) \{ ) IITOoo: Handle dequeve of a new block to the 1inked 1ist, the head is the first position in the 1inked List, 1/ /heturn the head of the 1ist. public static Block dequeue(Block head) \{ 3 return head; enum Direction 1 Nokth, SOUTH, EAST, 3 WEST class Block \{ public Block next; public int x; public int y; public Block() 1 this (1,1, nuag)s 3 enum Direction \{ NORTH, SOUTH, EAST, WEST class Block \{ public Block next; public int x; public int y; public Block() \{ this (1,1, nul1); \} public Block(int x, int y){ this (x,y, nuli); \} public Block(int x, int y, Block next) \{ this. =x; this. y=y; \} this.next = next