CSCI 1321 (Principles of Algorithm Design II), Fall 2002:
Homework 1
- Due:
- Design due September 5, 2002, at 5pm;
code due September 10, 2002, at 5pm.
- Credit:
- Design 20 points;
code 20 points.
First read Dr. Lewis's
Project Description,
including the short description of Assignment 1.
Then read the specific instructions for
Assignment 1.
See the course
links page
for information on running Together on one of
the lab machines or on your own machine.
Once you have started Together, do the following to
create a new project and set it up for this assignment.
- In the File menu, select
New Project to create a project.
You will be prompted to choose a name for the project
and a folder (directory)
for its location.
If you are doing this under Linux on one of the lab machines,
this folder should be somewhere in your home directory.
(Notice that the top-level file-selection menu should
have a choice ``Home'' that takes you to your home
directory.)
- Download Dr. Lewis's JAR file (containing the code he is
supplying for this assignment) from his
Assignment 1
page; put it in the same
directory/folder as the project you just created.
- Add the JAR file to the project's classpath, so that
the classes you write will be able to use the classes
in the JAR file:
In the Project menu,
select Project Properties.
Select the Search/Classpath tab, click
Add Path, Library, or Archive,
and select the JAR file you just downloaded.
Notice that the classes in the JAR file
will not show up in your project's diagram.
On the whole this is probably a good thing.
Caution:
If you mistakenly add the JAR file to the
Project Paths tab, the classes inside
will show up in your project's diagram,
but the Java runtime will not be able to find them.
If this happens, remove the JAR file from the
Project Paths tab and add it to the
Search/Classpath tab.
One would think there would be a way to have the JAR file
appear on both tabs, but this appears not to work.
- Create a ``main'' class for your game using the Designer
panel or by starting with the File menu and
selecting first New and then Class.
Right-click on the UML diagram for the new class
and select Properties. This should bring up the class's
properties in the Inspector panel. The
Properties tab
shows the class's name, among other things. Change it
to something meaningful for your game.
Once you have your project set up as described above,
do the following steps to finish the design part of this
assignment.
- Add comments to your main class describing your game:
Bring up your main class's properties in the
Inspector
panel as described earlier (right-click on
the class's UML
diagram and then choose Properties).
Select the Description tab.
Type your description of the game in the
Description panel that comes up.
- Generate HTML documentation for your project:
In the Project menu, select
Documentation, then Generate HTML.
You will prompted for the location of the folder in which
to put the generated documentation. If you put the
documentation in a subdirectory of your
Local/HTML-Documents directory
on Sol, it will be viewable from the Web.
(For example, if user jsmith puts the documentation in
Local/HTML-Documents/MyGame, it can be viewed using
URL http://www.cs.trinity.edu/~jsmith/MyGame.)
- Send me the URL for the generated HTML documentation.
Alternatively, you can simply send me a text e-mail message describing
your game. But at some point you should fold this description into
comments as described above.
For this step, you are to add a main() method to your main
game class. The parameters, return type, etc. of this method should
be the same as in the example we did in class September 5.
What the body of the code should do is described in
Dr. Lewis's Assignment 1
writeup.
You will be making use of his MainFrame class;
to find out how to use this class, read his
project documentation.
Once you have written your code, compile it and test it.
Here are some tips on writing, compiling, and testing your code
using Together.
They assume that you have followed the preceding steps for
creating a project and documentation for your main class.
- To add code (a main() method) to your main class,
you can open it in the Editor panel
(by double-clicking on its class diagram in the
Designer panel) and type the code in directly.
(There are other ways of
creating code with Together, but this is probably the
simplest at this point.)
When you have it typed it, save it
(by starting with the File menu and
selecting Save).
You can actually change things in your class using
the Editor panel, the Inspector panel,
and the Designer panel. Changes you make in
one panel show up in the other one(s) when you save them.
- Try compiling your code:
In the Project menu, select Make Project.
(Or find the Make Project icon on the toolbar.)
You will see any error messages in the
Message Pane panel at the bottom.
- Once you get code that compiles without errors,
try running it:
In the Run menu, select Run.
(Or find the Run icon on the toolbar.)
This pops up a window with more prompts.
Choose the Application tab and
fill in the box labeled
Select class for 'main'
with the name of your main class.
- If you have done everything right,
you will now get a little window that allows you to
play a very simple game (solid black screen, player
that moves around in response to the arrow keys).
You will probably want to make the window bigger,
and to make the player move you may need to hold
the arrow keys down longer than you might think.
If you don't get such a window,
the Message Pane panel should contain error messages
indicating what went wrong.
Turn in a description of your game, either in the form of
Together-generated HTML documentation or in the form of a plain
text e-mail, as described above.
E-mail the source code for your main class to me at
bmassing@cs.trinity.edu.
This code will be in a file with the extension .java.
(For example, if your main class is called MyGame,
this file will be MyGame.java.)
The simplest way to do this is probably to use your favorite
mail program and attach the .java file as an attachment.
I do not recommend cutting and pasting source code into
a mail program; this tends to result in garbled code.
Also, if you did not previously send me a link to Together-generated
HTML documentation for your main class, please do so now.
Berna Massingill
2002-09-09