For this lab we will write a class that represents a pocketful of change.
From the login screen, choose "Options->Session->OpenWindows Desktop". Type your username and password to log in. After logging in, type "passwd" and return in a terminal window. Follow the prompts to choose a new password for your account.
Start eclipse by typing "eclipse &" in a terminal window and hitting return. Wait for the main window to open. If necessary, click on "Workbench".
Start a web browser by typing "mozilla &" in a terminal window and hitting return. Go to the class web page: http://www.cs.vassar.edu/~cs102/. Go to the table in the Projects section. Right click on the link to the file "lab1.zip" in today's lab (12 Sep 2005) and choose "Save Link Target As...". Save the file in your home directory.
In Eclipse, choose "File->Import->Existing Projects into Workspace" from the menu. Click on "Select archive file", and then the "Browse" button next to this option. In the file chooser, select the file "lab1.zip" from your home directory. Click "Finish". You should now see a project called "lab1" in the Package Explorer.
Implement the class called Coins, which is in the file called Coins.java. This file can be found by expanding the "lab1" project, then the "src" folder, and then the "edu.vassar.cs.cs102" package. Double click on the file to open it in an editor window.
The class should have instance variables for each coin type listed below:
pennies, nickels, dimes, and quarters
The class should provide:
where args... is the list of arguments you want to pass to the 4-parameter constructor.this(args...);
After you have finished the Coins class, you should run the main method in the class called CoinsTester. The main method for this class takes a single command line parameter, which determines the upper bound of how many coins of each type to randomly create. For example, if you pass the value "5" to CoinsTester's main method, it will randomly create from 0 to 4 of each kind of coin in the Coins objects it creates.
To execute the CoinsTester main method from within Eclipse:
You will see the output of the program in the Console window. Try varying the value you pass to the main method in order to find the largest value you can pass in order to have two randomly-created Coins objects compare as equal. To change the argument:
Note that you can re-run the last program you ran by clicking on the green toolbar button that looks like this:
Note: just to make sure everything gets submitted properly, please ask me to help you through this part.
First, save your project as a zip file:
Sending an email with your project solution:
When you are done, close Eclipse, and then click on the "VCCS" menu in the lower left of the screen. Choose "Logout..." and then click "Yes" when prompted. Always remember to log out when you are done using the system, to ensure that no one else uses your account.