70 likes | 234 Views
Frogs and Toads 4 FrogApp and FrogApplet. Some updates. Frogs and Toads 3 (after) has partial functionality can move an amphibian can determine if frog move (one square) is legal need to check if hops move is legal need to do Toads as well. FrogGame class. validMove method
E N D
Some updates • Frogs and Toads 3 (after) has partial functionality • can move an amphibian • can determine if frog move (one square) is legal • need to check if hops move is legal • need to do Toads as well
FrogGame class • validMove method • checks the status of a pad to see if FROG or TOAD • we used gameBoard.getPad(row,column).getStatus() • when checking for hops • have to check neighbor square is opposite type • could go "off the board" – outside legal limits for row/col • will cause run time error (red messages!) • Instead use gameBoard.statusOfPad(row,column); • this method will have protection inside • checks for illegal row/column values
FrogGame class • int StatusOfPad(row,column) • if the row is <0 OR >= size • return Pad.INVALID • same deal with col • otherwise, return gameBoard.getPad(row,column).getStatus();
Pond class • The toString method provided draws board upside down • low rows on top. • Opposite of the example games • We can easily flip the board, see method and verify in FrogGameTester
FrogApp class • comments and pseudocode provided • very easy once you get the FrogGame class working
FrogApplet class • starter code provided • we'll do the board drawing together • and also how to convert mouse clicks to row/col values