Homework 0
PGSS Computer Science Core
Note: This assignment is not required, and you
will submit nothing as proof that you completed it. We do, however,
strongly recommend that you try it out, before Homework 1 is
distributed. The purpose of Homework 0 is to become acquainted with
the local programming environment. Without this, future assignments
will be unnecessarily difficult.
In this assignment, you will download a program from the Web and
compile it on your local machine, using a simple step-by-step process.
This is a hurdle we must leap in order to have interesting programming
homeworks later.
The program we'll run tests the primality of a number. In Homework
1, we'll modify this program for efficiency, but for now we just want
to run it at least once.
You may run into problems in the course of following these steps. If
so, find a friend, ask a TA, or contact the instructor.
- Set up the system.
- We'll use the CMU Macintosh system, so find one and log in.
- Create a folder in which to store this homework.
- In the Finder, Open Netscape Navigator. (It may be in the
``Netscape Navigator'' folder, which itself may be in the ``WWW''
folder.)
- In Netscape, go to the course home page
(http://www.cs.cmu.edu/~cburch/pgss/).
Select the link labeled ``Prime.java''.
Select ``Save As...'' from the File menu, and save the
file (in the folder you created) as ``Prime.java''.
- Quit Netscape.
- Create the project.
- In the Finder, Open CodeWarrior IDE. (It's probably in the
``Programming'' folder, in the folder titled ``CodeWarrior'', in its
folder titled ``Metrowerks CodeWarrior''.)
- In CodeWarrior, select ``New Project...'' from the File menu. This
will bring up a dialog box.
- Click on the triangle next to ``Java'', and select
``Java Application''. Unselect the checkbox for ``Create Folder''.
Click ``OK''.
- Enter the folder you created in the new dialog box. Name the
project ``Prime.proj'', and click ``Save''.
- Select ``TrivialApplication.java'' in the project window and
choose ``Remove Files'' from the Project menu.
- Choose ``Add Files...'' from the Project menu, and select
``Prime.java''. Click ``Add'', then ``Done''. This should insert
``Prime.java'' into the project window.
- Choose ``Project Settings'' from the Edit menu. Select
``Java Project'', and type ``Prime'' in place of
``TrivialApplication'' (in the ``Main Class'' text field).
Click on ``OK''.
- Debug and run the program.
- Still in CodeWarrior, double-click on ``Prime.java'' in the
project window. This should bring up the code for you to view and
edit. Find the function PrimeTestAll, and look over it. (This
is the part you'll modify in Homework 1.)
- Add an error to ``PrimeTestAll''. (Remove the line ``int
i;'', for example.) Now select ``Run'' from the Project menu.
- If you successfully inserted an error, a window should appear
describing some problems with the program. Close the window and undo
your change.
- Now select ``Run'' from the Project menu again. This should begin
the application. Go ahead and try a few numbers to make sure the code
is correct. (Do this by typing something in the text field and clicking
``Test''. The answer will appear at the top of the dialog.) Click
``Quit'' to quit.
- You're done! If you don't feel comfortable with any of the above
steps, try them again. Be sure to log out (through the right-hand
key-icon menu) after you're finished.