This assignment will involve Linked Lists, Comparators, Recursion, Stacks, and Queues.
Note: Please read the turn-in procedure carefully before you begin, it has been updated specifically for this homework.
Gru has enlisted you to help him with his latest problem: he has too many minions to keep track of on his own! He is currently in the process of tracking his minions with his version of a linked list which he calls “MinionList
”, however he is missing some functionality and he is not able to sort them! According to Gru the natural ordering of minions is by name
, however he would also like to be able to sort them by height
and iQlevel
.
Gru realized that just a simple linked list will not suffice in keeping track of his minions. They like to stack on top of one another in order to pick bananas, so he will also require an implementation of a Stack
. The minions also line up every night before bed to hug Gru one by one, so he will need a Queue
to keep track of the line.
Once you have fulfilled those requirements Gru has one last challenge for you. You must prove you are the ultimate coding master in order to permanently join his team! How exactly do you do that? With recursion of course! You must code a handful of recursive methods to be used with the MinionList
, details for them are provided below.
Note: You should NOT use any extra instance variables or any non-private methods other than the ones that are required.
You have been provided with a partial implementation of a linked list. Your MinionList
must implement Iterable
, MinionQueue
, and MinionStack
. You must use Nodes to represent the list, you may NOT use an array or any other type of data structure.
Provided code includes:
Node
class.private Node head
: instance variable to keep track of the head of the list.public boolean isEmpty()
: returns whether or not the list is empty.You must also include these methods in MinionList
:
Note: The following methods MUST be implemented recursively to receive credit.
public Minion get(int i)
: Finds and returns the minion at specified index i. Throws IndexOutOfBoundsException if i
is < 0
or >= size
.public String toString()
: returns a String representation of the list in this format: “[minion1,minion2,minion3,]”.public int size()
: returns the number of elements in the MinionList
.public MinionList reverse()
: Returns a new MinionList
with the same elements as this MinionList
but whose elements are in reverse order from this MinionList
. For example for the list [minion1, minion2, minion3]
this method would return [minion3, minion2, minion1]
.Do not edit this file.
This interface includes the methods that you will need to provide implementation for in the MinionList
. See the javadocs for more details.
Do not edit this file.
This interface includes the methods that you will need to provide implementation for in the MinionList
. See the javadocs for more details.
Must implement Comparable. Minions should be compared by name for natural ordering.
This class must have the following attributes:
private String name
: name of minionprivate double height
: height of minionprivate int iQLevel
: IQ of minionequals
method. This should check name
, height
, and iQLevel
.toString
method. This should return a String in the format “name
has IQ of iQLevel
and height of height
cm.”. The height
must be rounded to 2 decimal places.hashCode
method.
public Comparator<Minion> compareByHeight()
: returns a Comparator that compares Minions by height.public Comparator<Minion> compareByIQ()
: returns a Comparator that compares Minions by iQLevel.You should not use any methods, libraries or packages that trivialize the assignment. If you are unsure of whether something is allowed, ask on Piazza. In general, if something does a large part of the assignment for you, it is probably not allowed.
To compile your code simply run javac *.java
from the directory in which your files are located.
You will need to write Javadoc comments along with checkstyling your submission. Some javadocs have already been provided for you. You also do not need to worry about writing javadocs for BuildTeam.java. However, you will need to modify the javadoc for the ComparableCollection class after modifying the class header appropriately.
Every class should have a class level Javadoc that includes @author <GT Username>
and @version <version #>
.
Every method should have a Javadoc explaining what the method does and includes any of the following tags if applicable.
@param <parameter name> <brief description of parameter>
@returns <brief description of what is returned>
@throws <Exception> <brief explanation of when the given exception is thrown>
See the CS 1331 Style Guide section on Javadoc comments for examples.
You must run checkstyle on your submission. The checkstyle cap for this submission is 100 points.
Run checkstyle for this assignment with java -jar checkstyle-6.2.2.jar -a *.java
. This will check for both checkstyle errors and javadoc errors.
Collaboration with other students When completing homeworks for CS1331 you may talk with other students about:
You may not discuss, show, or share by other means the specifics of your code, including screenshots, file sharing, or showing someone else the code on your computer, or use code shared by others.
Examples of approved/disapproved collaboration:
s 10:40 on Thursday... can I see your code? I won
t copy it directly I promise”Collaborating with others in a way that violates the approved means is a Georgia Tech Honor Code violation.
YOUR SUBMISSION SHOULD ONLY CONTAIN .JAVA FILES!
Compress the hw7 files into a .zip file and submit that on T-square. Make sure the zip file contains MinionList.java
, MinionQueue.java
, MinionStack.java
, and Minion.java
. Do NOT submit your .class files.
In addition to submitting on T-Square you will also need to put the assignment on the Georgia Tech Github. Git is a Version Control System. I highly suggest you learn how to use git through either here, here, or by doing your own research and reading. We outline step by step how to get everything set up below.
Do not change your username on github. It should remain your GT username as was given to you by the institute. For example, I changed my email a long time ago to be hschirra@gatech.edu, but my github account name is still hschirra3. If you change your name you will be making everyone’s lives more difficult. So just don’t do it.
In your web browser…
Now, inside of your command line…
cd
into a directory where you want to keep your homework.git clone
and then paste the link you copied from github in step 9 above.
git clone https://github.gatech.edu/hschirra3/hw7_summer2017
ls
or dir
and you should see a folder called hw7_summer2017
in your directory!Great! Now you have basic set up done.
Copy all of your hw7 files into the hw7_summer2017
folder.
Now do the following:
cd
into hw7_summer2017 in your command line.git add *.java
. This will add all changes you have made to be staged for commit.git commit -m "My first commit and adding hw7 files"
. The part in quotes is your commit message. This message will tell anyone who takes a look at your repository’s commit history what you changed or did every time you committed.git push
. This pushes all of the changes you committed on your local repository up to the remote repository.If you go back to github.gatech.edu and go look at your repository you will see that all of your Java files are now in your remote repository!
If you want to make changes to the files in the repository you should first type git pull
in your command line to make sure you are up-to-date with the remote version of the repository. This is important especially if you are working from multiple computers where the local repositories may not all be up to date.
Then you can edit your files as you normally would, and upon saving them:
git add .
to add all changes you have made to be staged for commit.git commit -m "My message"
to commit your changes to your local repository.git push
to push your changes up to the remote repository.Practice safe submission! Verify that your HW files were truly submitted correctly, the upload was successful, and that your program runs with no syntax or runtime errors. It is solely your responsibility to turn in your homework and practice this safe submission safeguard.
This procedure helps guard against a few things.