Version: 5.2.1.6

2 5/8: Subversion, Testing, and Recursive Methods

The goal of this lab is to introduce more aspects of our work environment: the Subversion revision control system and the Tester library. In the second part of the lab, you will practice writing some recursive data definitions and their methods.

Administrivia

Exercise 1. Check your partner assignment on the Blog and alert the TA if there are any mistakes.

Tester setup

Exercise 2. Set up the tester library in Eclipse.

Running this will run all your tests and give a result digest.

Exercise 3. Revisit your code from Lab 1 and reformulate all of your examples as tests. Run them and correct any mistakes this uncovers.

For the remainder of the course, when writing tests, you should use the Tester library.

Getting started with Subversion

Subversion is a revision control system. It helps you keep track of the changes to a document over the course of its lifetime. It can be used for any kind of document: papers, notes, spreadsheets, web pages, etc., but it is often used for the source code of programs. We’re going to be using Subversion (svn) for the remainder of the course in order to track changes to code written for labs and homeworks and we will use it as the mechanism for turing in and receiving feedback on assignments.

Exercise 4. Skim the course notes on Subversion.

Subversion is available on all the lab machines, but you may also want to install a Subversion client (there are several to choose from) on your personal computer.

The course repository, cs2510spring2012, has been created with a directory for each pair and a directory for each student. You will only have access to access to your user directory and your pair directory. No one but the course staff has access to your user directory and no one but your partner and the course staff has access to your pair directory.

Exercise 5. Check out a copy of your user directory in the cs2510spring2012 repository. Verify that your solution to assignment 1 is in it.

You should use this directory to store lab material, notes, or anything else you’d like that shouldn’t be shared with others (beside the staff). We will use this directory to communicate (non-pair) grades back to you.

Remember that no changes are made to the repository until you successfully commit. Until then, any changes you make are only stored on the computer you’re working on. Therefore you should commit early and often (like voting).

Exercise 6. Check out a copy of your pair directory in the cs2510spring2012 repository.

You should use this directory to store assignments. We will use this directory to communicate pair grades back to you and your partner.

Exercise 7. Within your user directory, create two directories called lab1 and lab2. Add your Java source code to for each lab to these directories. Check these directories in to the repository and commit.

The Tree of Life

For the remainder of the lab, you will gain experience designing recursive classes. Be sure to test all of your designs using the Tester library and commit your work to your user directory in the svn repository.

Life can be viewed as a sequence of situations in which you must make a decision about what to do. Let’s simplify things and say life is really series of situations in which you can either do or not do something. For example, “do you go to college?”, “do you brush your teeth?”, “do you step out on to Hungtington without looking both ways?”. Your choice influences the remaining questions you will face; if go to college, for example, you will probably face choices such as “should I go to lecture to today?”, whereas this situation doesn’t present itself if you chose not to go to college; instead you’d face a different set of decisions to make.

Eventually, no matter what series of decisions you make, you’ll die. At which point, you’re done making decisions.

Exercise 8. Design a data definition for representing different life scenarios.

Your data definition must be adequate to represent scenarios such as the following:

Exercise 9. Make 4 examples of life scenarios (different from the above).

Exercise 10. Design a method that determines the least number of decisions you can make before dying.

Exercise 11. Design a method that determines the maximum number of decisions you can make before dying.

Exercise 12. Design a method that determines the number of decisions you can make if you always answer “yes”.

Exercise 13. Design a method that determines the number of decisions you can make if you always answer “no”.

Exercise 14. (Tricky) Design a method that determines the number of decisions you can make if you always alternate between answering “yes” and “no” (starting with “yes”).

Exercise 15. Design a data definition for lists of questions.

Exercise 16. Design a method that produces the list of questions you face if you always answer “yes”.

Exercise 17. (Tricky) Design a method that produces the list of questions you face if you always alternate between “yes” and “no”.

Be sure to check the course web page later this afternoon; the second assignment will be posted.