====== Lab 8 ======
~~NOTOC~~
** CS203 ** \\
** Spring 2013 ** \\
** Mar 29 **
===== Goals =====
* Clone a project from GitHub
* Implement and use iterators
* Use inner classes to implement your iterators
* Test your iterators
===== Activities =====
- Configure git for your CS Linux account:
* Login and enter the following commands at the Linux prompt:
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
- Set up your public sshkey so that you don't get prompted for a password every time you access your GitHub account:
ssh-keygen -t rsa -C "your@email.com"
Note: you will be prompted for what file to save the key in--take the default; you will also be prompted for a passphrase--make one up you can remember
* point your browser to https://github.com/ and login to your GitHub account
* in the upper right corner, click on the ''Account Settings'' icon (it's the second icon from the right; hover over it and it should tell you which one it is)
* along the left hand side of the page, click on ''SSH Keys'', and click the button to add an SSH key
* in the Title field, type in your Vassar email address
* from your Linux prompt, cd into your ''.ssh'' directory, and type the following command:
cat id_rsa.pub
* copy/paste your public SSH key from the terminal into the ''Key'' text area of your browser
* click the ''Add Key'' button
* test if all went well by trying to ssh into GitHub:
ssh -T git@github.com Note: you may be prompted about trusting GitHub's fingerprint. Reply 'yes'
* //DO NOT CONTINUE UNLESS THIS LAST COMMAND WAS SUCCESSFUL//
- cd into your ''cs203'' course directory
- Grab your starter Netbeans project from GitHub using the git clone command: git clone git@github.com:Vassar-cs203/lab8.git
- Open your **//Lab8//** project in Netbeans--it will show up as **//InnerIterator//** in Netbeans
* Note: you may have to fix the reference to the tester library
* There are two classes in this project: an ''Examples'' class for your tests, and a ''Num'' class that contains an inner class named ''PrimesGen''
* Notice that ''PrimesGen'' is a private static inner class, defined within Num.
* Run the project, look at the tests, see if you can figure out what's going on before you continue...
- Add a new inner class named ''NatGen'' that is also an iterator, but more simply generates 1, 2, 3,...
- Add a method to class Num named ''allNats'', similar in spirit to ''allPrimes'', but the iterator returned will be an instance of ''NatGen''.
* Recall that this method is an example of the //Factory// design pattern.
* The factory method provides a way to construct an object without invoking a constructor for that object's class.
* We need such factory methods when we need to return an Iterator that's an instance of an inner class.
- Add a few tests in your Examples class for the ''allNats'' iterator
- Add one more iterator, as an inner class, that generates multiples of 10, e.g., 10, 20, 30,..
- Similarly add a factory method for your multiples of 10 iterator, and add a few tests.
===== Submit your lab =====
* When you've had enough fun, submit your work using the new submit203 script: \\ ''submit203 lab8 lab8''
* the first ''lab8'' is the assignment name, the second ''lab8'' is the root directory of the project you checked out of GitHub
===== When you've had enough (for today) =====
* Logout and have a good weekend