A Geocache Object is a custom data structure that you will be responsible for implementing in this class. (Geocaching is an outdoor recreational activity.)
The requirements for Geocache.java are the following:
A GeocacheList is simply a well managed array of Geocache objects.
Warning: You must get Geocache.java working before you start GeocacheList.java, because GeocacheList relies on Geocache to work (i.e., you will get a 0 on GeocacheList if Geocache is a 0).
You will have to complete the following code:
//UIUC CS125 FALL 2014 MP. File: GeocacheList.java, CS125 Project: Challenge5-DataStructures, Version: 2014-10-12T11:30:28-0500.439145392 /** * Complete the following GeocacheList, to ensure all unit tests pass. There are * several errors in the code below * * Hint: Get the Geocache class working and passing its tests first. */ public class GeocacheList { private Geocache[] data = new Geocache[0]; private int size = 0; /** * Returns the ith Geocache object in Geocache[] data. */ public Geocache getGeocache(int i) { return null; } /** * Public getter method for private int size */ public int getSize() { return 0; } /** * Default/No args constructor for GeocacheList */ public GeocacheList() { } /** * Copy constructor for GeocacheList: This constructor should create a copy * of of a GeocacheList given a reference to that GeocacheList. Whether its * a deep copy or shallow copy is dependent on boolean deepCopy * * If you dont know the difference between a deep copy and shallow copy, * please go to an office hour, since it's essential to this assignment */ public GeocacheList(GeocacheList other, boolean deepCopy) { data = new Geocache[other.data.length]; size = other.size; } /** * Adds a Geocache object to the end of the GeocacheList */ public void add(Geocache p) { size++; if (size > data.length) { Geocache[] old = data; data = new Geocache[size * 2]; for (int i = 0; i < old.length; i++) data[i] = old[i]; } data[size - 1] = p; } public Geocache removeFromTop() { return null; } /** * Prints out all the content of the GeocacheList */ public String toString() { StringBuffer s = new StringBuffer("GeocacheList:"); for (int i = 0; i < size; i++) { if (i > 0) s.append(','); s.append(data[i]); } return s.toString(); } }