CSC 241- Assignment 2
Part 1 -- Changeable Tank + test Applet (Due March 10th 1997)
Design the class changeableTank which is a subclass of
class displayableTank. Here are the capabilities that
you will build into this class:
- Write the following constructor:
public changeableTank (int x, int y, boolean big)
/* x,y -- where should the tank go, used for invoking the
displayableTank's constructor
big -- large or small (large is the size used in displayable tank,
and small is 1/4 of that)
*/
- Write the method that switches the size of a tank from small to large
or from large to small:
public void switchSize()
- Write the method that given a new x,y coordinate will reposition the
tank:
public void changePosition(int x, int y) {
Build an applet that demonstrates that it works, have the applet work
my Changeable Tank Applet .
Part 2 -- Tank Stack Applet (Due March 17th 1997)
You will build an applet that maintains a stack of tanks. Check my
Tank Stack Applet to see how your applet should
work.
- You need to have a panel that provides a text field, a button
for push and one for pop.
- You need to have a panel with buttons to let the user create
new tanks, add, and remove fluid. This panel should also have a
text field providing tank status information.
- When new tanks are created, they should be displayed in a reasonable
way, similar to Tank Applet .
- Tanks that have been placed on the stack need to be displayed. Each time
the paint method of the applet is invoked you need to pop them off the
stack and invoke their display method. Remember that if you get them
off the stack, and display them without keeping them somewhere and
restoring the stack later, you will lose the tanks.
- You need to make use of changeableTank class and
genStack that already exist in doing this assignment.
- Make your .html file similar to mine.