Programming > SOPHIA Milestone > Virginia Tech - CS 1114 MazeRunner.java. (All)
import sofia.micro.jeroo.*; public class MazeRunner extends Jeroo { //~ Fields ................................................................ //~ Constructor ....................................... ....................... // ---------------------------------------------------------- /** * This method creats a Jeroo that holds 15 flowers */ public MazeRunner() { super(15); } //~ Methods ............................................................... /** * This method calls upon another method while the * the conditions of the maze are not met */ public void myProgram() { while (!allConditions()) { this.navMaze(); } } /** * This method contains all the conditions of the maze * @return if conditions are all true the maze is complete */ public boolean allConditions() { return (this.getWorld().getObjects(Net.class).size() == 0 && this.getWorld().getObjects(Flower.class).size() == 0 && this.getGridX() == 1 && this.getGridY() == 1); } /** * This method is the main navigation for the Jeroo, * it contains instruction for gathering flowers, disabling * traps and moving in the maze */ public void navMaze() { if (this.seesNet(AHEAD)) { this.toss(); } if (this.seesFlower(HERE)) { this.pick(); } if (!this.turnLeft() && !this.hopIfClear()) { this.turn(RIGHT); } /** * This method tells the Jeroo * to turn left whenever it is possible to turn * @return if conditions are true the Jeroo will turn left and hop */ public boolean turnLeft() { if (!this.seesWater(LEFT) && !this.seesNet(LEFT)) { this.turn(LEFT); this.hop(); return (true); } else { return (false); } } /** * This method tells the Jeroo * to hop forward if it is clear * @return if conditions are true the Jeroo will hop forward */ public boolean hopIfClear() { if (!this.seesWater(AHEAD) && !this.seesNet(AHEAD)) { this.hop(); return (true); } else { return (false); [Show More]
Last updated: 2 years ago
Preview 1 out of 2 pages
Buy this document to get the full access instantly
Instant Download Access after purchase
Buy NowInstant download
We Accept:
Can't find what you want? Try our AI powered Search
Connected school, study & course
About the document
Uploaded On
Mar 20, 2021
Number of pages
2
Written in
This document has been written for:
Uploaded
Mar 20, 2021
Downloads
0
Views
261
In Scholarfriends, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Scholarfriends · High quality services·