CompSci 6- Classwork 4 - Jan 26, 2010
10 pts

Today's classwork focuses on problem solving and using Eclipse to download a Java program. You will submit your solutions via Eclipse. If you don't finish in class, then you should finish by the next class period.

PART 1A: Getting Started: Using Eclipse to snarf a project.

In this class we will setup many programs that you will modify. You will need to copy those files into Eclipse by "snarfing" them.

To download the files for today, startup Eclipse. Click on "Ambient", and then "Download (Snarf) a Project".

If you don't see "CompSci 6" appear in the Snarfer Site Browser, then you will need to add CompSci 6 as a snarf site. Click on the two blue arrows pointing down in the picture above to add a snarf site and enter in:

    http://www.cs.duke.edu/courses/spring10/cps006/snarf/

Then you should see "CompSci 6, classwork, 04_class_cps006_spring10". Click on "04_class_cps006_spring10", then click on "Install Project" and it should appear in your Eclipse view as a project.

There are two Java files in this project: Chicken.java and Farm.java. Also a README file has been started for you.

Part 1B: Modifying a Class

Consider the following Java program.

Run the program and see the output in the console window. To run it, right click on the Farm.java, select "Run as", then "Java Application".

Make the following modifications.

  1. Add the following private state to the Chicken class. Think about good names for these.

  2. What other changes do you need to make when you add this state?

Part 2 - Practice APT

You will solve the following problem using Eclipse and the APT. In your current project, create the class called CountAppearances (be sure to spell it exactly like that with no spaces and two capital letters).

  1. Count Appearances

Remember that this is NOT a complete Java program, so you will need to test this class with the class APT link.

Submit

Make sure you modify README.txt (put in your name and other info) and then submit your project Class04-Jan26 on Ambient.