The Magnet Lab
- We'll work on the Magnet lab next week
- Bring in design for part 1 to lab
- We'll look at it and give feedback, but not record a grade this week.
The goal of this week's lab is to practice designing classes and
methods. You will be designing a Magnet class that can generate
objects representing magnets that can be dragged around the screen.
The lab handout describes the program in detail. However, we'd like
to remind you of a few important points here.
- This week we ask that you to bring a "design" of the Magnet
and MagnetGame classes to lab. You only need to provide a design
for part 1 of the lab (though you should think about the rest as
well). Your design should consist of the following for each
class:
- A list of all constants and instance variables for the
class (with their associated types). Constants should be
provided with their values.
- A list of all methods of the class. Each method should include
- the return type of the method. (void if it is a
mutator)
- the list of parameters of the method.
- the comment that you will include at the top of the
method. For example, for a move method with parameters x
and y, the comment might be: moves the laundry item x
units to the right and y units down.
- a description (in English) of what the body of the
method does. As an example, consider the Tshirt dragging
example above. The design for the onMouseDrag method
might say: If the t-shirt is being dragged, move it from
lastPosition to point and update lastPosition to point.
- We'll circulate through the lab at the beginning of the
period checking the designs and giving comments on their
completeness. You will not be graded on your design this week -
we'll simply check that you have one.
- Your Magnet class will interact with the Pole class that we
wrote. You must define the methods of Magnet exactly as we
specify or Pole will not work.
- Note that you are not to change anything in the Pole class.