WARNING: The coding in this lab can be difficult. Expect to spend some time on this outside of class. Do not copy code off someone else - you actually need to learn the material in this section so you can do your final project.
This lab is due on Tuesday, March 12 at 11:59 pm. Please submit all code from the exercises by that time. All written questions should be typed up/handwritten and shown in class the next day. Your task is to do sections of part 4 in the .pdf in this folder (https://drive.google.com/drive/folders/124OKC1zgDE7M8ccQ-mZjqoo-XtMufwQM?usp=sharing - directions can be found here):
-Make sure to read through the document very carefully as you go. There is lots of good stuff here which will help with your final project. I have also included tips and hints at the bottom of this page.
-Answer the questions on pg. 2 and pg. 5-6 on your document/sheet of paper. You may skip the questions on page 7 (but not the exercises, see below).
-On page 7, complete exercises 3 and 5 [DO NOT DO exercises 1,2,4, 6 or the group activity]. These are tricky assignments and I have included some tips below. You will do these in the "part 4" folder which is under projects in the GridWorld code. You will submit the entire part 4 project folder containing RockHound.java, CrabCritter.java (this should be unchanged) and QuickCrab.java as well as the GW4Driver.java class I have attached in this folder (https://drive.google.com/drive/folders/124OKC1zgDE7M8ccQ-mZjqoo-XtMufwQM?usp=sharing). Do NOT upload the entire GridWorldCodeBlueJ folder, just the "part 4" folder in projects.
To test your code, use my GW4Driver.java class that is linked above. Please also include this class in your project. You should just submit the entire "part 4" project folder and all of the files in it - just like last time. If you want to further differentiate between the different types of Critters in the grid, feel free to put in .gif files for each Class inside the same folder.
Here are some useful tips and directions:
-For each class you make, include the same 4 import statments:
import info.gridworld.actor.*; //this loads Actor, Bug, Critter, etc.
import info.gridworld.grid.*; //this loads all the Grid and Location stuff
import java.util.*;
import java.awt.Color;
-Do NOT alter any of the classes that are in the framework folder - Actor, Flower, Critter, Grid, etc. should not be moved or changed at all.
-If something says “it moves like a Critter” or “then it processes them like a Critter does,” consider either using super or just not overriding the method at all.
-It will be easiest to do these projects by not changing the act() method, but by overriding other methods.
-Make sure your critters do not give runtime errors!!! Often this might happen if they are facing or next to the edge of the grid. Calling the isValid(Location loc) method in Grid should be done before you try and call .get or do anything with another Location.
-To see what is in a location, there is a .get method in Grid which inputs a location. So call getGrid() then call .get on that and send it a location. It will return null if there is nothing in that location.
-For exercise 5, you should only have to override the getMoveLocations() method. This one is going to be tricky. You will need to use the getAdjacentLocation( ) method [think about Jumper] and lots of testing.
-Don't forget the tips I posted from the last set of labs, including the difference between a location being Valid (part of the grid) and occupied (an object is in the location)!
Make sure to test out your critters!! You will definitely want to be familiar with the methods in the Location and Grid classes and how to call them (through methods like getGrid() for an Actor).