Please report any errors directly to us: cs61b@eecs.berkeley.edu
Navigation
A. Before You Start
We're going to start enforcing deadlines, so now is a good time to make sure you've turned in what you think.
- Use
glookup -t
or the grades link on the Account Administration page to check that you have submissions for everything at the times you expect. - Use
git fetch origin
to make sure you have all the tags work in the central repository. - Use
git tag
to see what tags you have. If you have a tag (say
hw1-2
), then the commandgit log -1 hw1-2 # That's a one, not an ell
will print the log message for that tag, which has a date and time.
- You can match up tags with glookup submissions by date.
After making sure that all current work in your local repository, you can check out any selected submission (say,
hw1-2
) withgit checkout hw1-2
(It will tell you that you are in "detached head state", but that's normal. This will allow you to see what we received from you. Make sure you do
git status
to make sure that the files you are looking at have all been added to the repository, and aren't just files you created and never bothered to track.- When finished looking, you can use 'git checkout' on the branch you came from to get back (be sure you do this, or you will commit and submit something random next time!)
- Use
- On your home machine or laptop make sure you have the latest version of
cs61b-software
(do not do this on your instructional account; there should not be acs61b-software
directory there. Just go intocs61b-software
and use the commandgit pull --rebase
to get any updates we might have made.
B. Some Review
We'll start with some review exercises on the subjects of pointers and OOP:
C. Project 0
Take a look at the Project 0 specification.
Set up your working directory with its files in the usual way (see the
instructions in the specification
if you're not sure how. Take particular care about the
git push -u origin ...
step, so that you don't end up trying to push to
our repository instead of yours.
Compile the code in the canfield
and in gui
(the command make
will
do this), and play around a bit with the text interface to the Canfield
game (after first looking at the rules in the spec, if you need them):
java -ea canfield.Main --text
(-ea
means "enable assertion statments", generally a good idea when developing
code).
The command help
will print out a list of commands you can use. Play with it
enough to understand what the program does from the user's perspective.
Run the (broken) GUI version, too:
java -ea canfield.Main
Now try running the sample GUI code:
java gui.Main
Clicking on an empty area creates a new point. Clicking on an existing point
and then moving the mouse to another point and clicking it will create a line
segment (an edge) between the points. Dragging a point will move it and
any attached edges.
Now go into the files gui/SampleData.java
and
gui/SampleGUI.java
and see if you can figure out how
to add a new menu button that clears just the edges between points,
not the points themselves.
You might find the documentation of the ucb.gui package, especially
the TopLevel
class, to be helpful.
Go into the file gui/DataSisplay.java
and see if you can figure out how
to draw the points as filled red circles instead of images of bears. You
will probably find the documentation of java.awt.Graphics and its
subtype java.awt.Graphics2D to be helpful.
There is nothing to submit for this lab.