Graphing
Calculator
Math
Worksheets
Scientific
Calculator
Chart
Maker


Home
Graphing Calc
Algebra
Fun Games
Geometry
Interactive
Trigonometry
Scientific Calc
Home
Graphing Calc
Algebra
Fun Games
Geometry
Interactive
Trigonometry
Scientific Calc

GwJeroo

Projects III

Jeroo Page
Objective: To continue to implement while loops as well as ints. Complete this program using while loops and count up the number of hurdles completed (numHurdlesCompleted), total number of hops taken (numHopsTaken), and the number of flowers found (numFlowersFound).
Project While with Ints
  • Island File
  • Create a new class in Eclipse. This class should be called Loops101. Delete the code that eclipse gave you and paste the code below into it
    import info.gridworld.world.*;
    import info.gridworld.grid.Location;
    import javax.swing.JOptionPane;
    
    public class Loops102 {
    	
    public static void main(String[] args) {
    	
    
    	JerooWorld world = new JerooWorld("ManyHurdles.jev");
    
    	Jeroo kim = new Jeroo();
    	world.add(new Location(5,1),kim);
    	String strMessage = "Complete program using while loops, update all 3 int variables \n";
    	strMessage += " print out their final values.";
    	JOptionPane.showMessageDialog(null, strMessage);
    
    	world.show();
    
    int numHurdlesCompleted = 0;
    int numHopsTaken= 0;
    int numFlowersFound=0;
    
    
    	}
    }
    
    
Extending Jeroo with MorrisJeroo
Objective: To more efficiently complete the projet up above by extending the Jeroo Class.
  • 1) Copy this code into a class called MorrisJeroo
  • 2) Coy and paste this code into a class called MorrisWorld
  • 3) Examine the MorrisJeroo class. Your objective is to modify the hopAndCount() method so that the jeroo hops and increments the variable numHops
  • 4) create a method called pickFlowerAndCount() . This method should pick a flower and increase the value of numFlowers by 1
  • 5) Complete the project using hopAndCount() and pickFlowerAndCount()
  • 6) Create a method that returns the total number of flowers picked.
    • hint you can use the following header
      • public int getNumFlowers(){}