Practice creating, documenting, and testing classes based on a given public interface. More graphics and loop practice.
The first programming problem is based on Big Java exercises P3.16 and
P3.17.
Your programming work for this assignment must be done in the
ImplementingClasses
project inside Eclipse. Check out this project. All
of the work you are required do is in the three
Car files, but I want to describe
the other files in the project:
BankAccount is code from Big Java Chapter 3, slightly modified and annotated to show how you would do the same things in Python.
TestBankAccount is a collection of JUnit tests for BankAccount.
The four Face files are the solution to a problem that Curt Clifton assigned in Fall, 2008-09, and provide another example of defining a class and using it to draw objects on the screen.
Car
classes are taken for the book, with a
slight modification (to make the window bigger):
()
method so it draws the car at
its given size.
Modify the constructor so it takes the size as its third argument. Change the
second Car creation so it creates a car
twice as big as the first one.
The second car should still be drawn in the lower right corner of the window.
paintComponent()
, make the first car blue and the second one red.
paintComponent()
to
make it draw a triangular fleet of 21 cars, like the one
shown here.
Car sizes and spacing should be based on the
window size, in such a way that the triangle
occupies approximately the middle two-thirds of the
vertical space in the window (don't worry about
how much of the horizontal space it occupies).paintComponent()
's code by changing a 6 to a 5,
and it will draw a triangular fleet of 15 cars (5 rows)
that fills approximately the same vertical area
of the window. You should be able to
replace the 6 by any reasonably small integer and
get a similar effect.
(3 points)
Complete Exercise P3.5 from Big Java. Call the class
AutoMileage instead of Car, since we already have a
Car
class for
the previous problem. Also use JUnit to implement the required
AutoMileageTest
class.
This exercise doesn’t involve graphics. You’ll just implement and test an
AutoMileage
class that models fuel economy. The objective is to practice with the “How To: Implement a Class” steps from
Session 5.
We will grade your Wiki contributions using ANGEL. Turn-in your programming work by committing it to your SVN repository. Once again, the programming part of this assignment is due on Friday at 8:05 AM