Lab 1
Navigating MazesWhat we'll cover today:
The MazeIn this lab you will use methods to navigate a character through a maze. Let's get familar with your character: meet Puss in Boots![]() Puss can turn right and left, move backward and forward. He can put on and take off his boots, he can also tiptoe and jump if need be. This is very helpful for you because there will be obstacles within the maze that you will have to help puss move around. Examples of these obstacles are mud, a sleeping dog, and a gully.
To run the maze program, go into the MazeLab folder in Eclipse and expand the
default package list by clicking on the plus symbol. Then right click on
Here's a quick summary of the most important buttons:
MazeLab.java and try out the different actions that Puss can take. Move him around the maze and see which methods get Puss around the obstacles. Pay attention to the console as well, because some of the methods and some of your actions may cause information to be printed to the console.
Exercise 1. Getting Puss through the MazeNow you're ready to write your first program! The goal is to write code that will navigate Puss through the maze.
In today's lab, you are going to modify the
Here are the methods that you have at your disposal: forward() or forward(int n) - These methods both move Puss forward. The first moves him forward one step and the second moves him forward by n steps.
backward() or backward(int n) - These methods are the same as above only they move Puss backwards.
right() - Turns Puss to the right.
left() - Turns Puss to the left.
jump() - This method jumps Puss over one square.
startTipToe() - Puss starts to tip toe as he moves.
stopTipToe() - Puss stops tip toeing.
putOnBoots() - Puss puts on his boots.
takeOffBoots() - Puss takes off his boots.
Once you think you have a working solution, run Good Luck! |