frogs and toads 3 froggame and froggametester n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Frogs and Toads 3: FrogGame and FrogGameTester PowerPoint Presentation
Download Presentation
Frogs and Toads 3: FrogGame and FrogGameTester

Loading in 2 Seconds...

  share
play fullscreen
1 / 13
monifa

Frogs and Toads 3: FrogGame and FrogGameTester - PowerPoint PPT Presentation

59 Views
Download Presentation
Frogs and Toads 3: FrogGame and FrogGameTester
An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Frogs and Toads 3:FrogGame and FrogGameTester

  2. Summary • Pad class • Pond class • FrogGame class • FrogGameTester class

  3. Dealing with complexity • The full has much variability: • a variable game board size means we are forced to generalize everything • this could be challenging as we are just learning many new skills • beginners often freeze in these situations • A Winning Strategy? • SIMPLIFICATION!

  4. How can we simplify Frogs And Toads • And still have an interesting experience? • Reduce the board size? – only do 3x3 • Change the rules? • Any frog or toad can move any direction into vacant square • Like one of those tile puzzles, very easy to solve • Still needs • Solving simpler version gives insights into harder version

  5. Pad class Represents: A single lily pad in our game board Instance variables: int startState, currentState; Methods Pad(int startState) Creates a new lily pad with a given initial state int getStatus() Returns current state of the lily pad(FROG, etc) boolean isSolved() Returns true if this lily pad is in the solved state void reset() Restores the lily pad to the start state void setStatus(int status) Changes the current state of the lilypad String toString()           Returns the string representation of the lily pad.

  6. Pond Class Represents: A 2D array of lily pads (Game board) Instance variables: int size; Pad [][] grid; Methods: Pond(int size)  Creates a grid of lily pads with height and width = size PadgetPad(int row, int column) Returns Pad object at the row,col int getSize()   Returns the width of the pond boolean isSolved() Indicates whether or not all lily pads solved void reset() Resets the pond to the state it was in originally String toString() Returns the current state of the pond as a String

  7. FrogGame Represents: An active Frog Game Instance variables: int size; Pond gameBoard; Methods FrogGame(int size) Creates a new game with the given size PondgetPond() Returns the pond object (Game Board) boolean isSolved() Indicates whether puzzle has been solved. void moveAmphibian(int row, int column) Moves Frog/Toad at given location to Vacant pad (if possible). Making row, column the new Vacant pad boolean moveStillPossible() Indicates if legal move is still possible void print() Prints the game board (using the Pond object). int statusOfPad(int row, int column) returns status of the pad at row, col boolean validMove(int row, int column) Returns true if the given coordinates represent a Pad that has an amphibian that can make a legal move (hint: you may want to use the statusOfPad method to make your job easier).

  8. FrogGameTester • A demo app that tries out the different features of Frog Game. • Just has a main method • Lets look at some example scenarios • using "original" move rules

  9. FrogGame fg = new FrogGame(3); fg size gameBoard

  10. Result of fg.moveAmphibian(2,1) fg size gameBoard

  11. Result of fg.moveAmphibian(2,0) fg size gameBoard

  12. Result of fg.isValid(1,0) trueResult of fg.isValid(2,1) false fg size gameBoard