Programming > SOPHIA Milestone > Virginia Tech - CS 1114 MazeRunner.java. (All)

Virginia Tech - CS 1114 MazeRunner.java.

Document Content and Description Below

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 Now

Instant download

We Accept:

We Accept
document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

We Accept

Reviews( 0 )

$8.50

Buy Now

We Accept:

We Accept

Instant download

Can't find what you want? Try our AI powered Search

261
0

Document information


Connected school, study & course


About the document


Uploaded On

Mar 20, 2021

Number of pages

2

Written in

Seller


seller-icon
QuizMaster

Member since 6 years

1187 Documents Sold

Reviews Received
185
56
29
11
17
Additional information

This document has been written for:

Uploaded

Mar 20, 2021

Downloads

 0

Views

 261

Document Keyword Tags


$8.50
What is Scholarfriends

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 are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·