Comp 101 Lab6: Running around the screen
Due Friday April 18th at 11:59pm.
Introduction:
The time has come ladies and gentlemen for you all to write a graphical
application on your own from start to finish. You will write a complex
shape class, and move it around the screen.
Objectives:
- Create a JFrame/generic window
- Do basic graphics in java using a drawing panel
- Create a more complex shape object which draws itself.
- Work with a Timer object
- implement an interface
Assignment Specifications
First create a folder called lab6 and do all of your work in that folder.
You are to write a Java program that brings up a Frame window with
drawing in it. Your program has to follow the UML specification found
in the diagram below. You may add any additional methods or classes
that you need to, however, you must implement the three non-Java
library classes from the diagram below along with the methods and
instance variables in those three classes.
- You will need to implement the three classes here:
- ComplexShape
- this
can be any complex shape such as the car that we looked at in class or
any other shape. The only requirements on its appearance is that it
consist of at least4 different graphics dwaw or fill methods and that it be appropriate for public display.
- Drawing panel
- This
class should use the "extends JPanel" syntactic Magic. Also this is the
class which will implement to ActionListener interface. You will therefore
have to implement the two methods, paintComponent (which will probably
just call the draw method in ComplexShape) and actionPerformed which
will be called once each timer tick. (hint: think about the repaint
method that I talked about in class)
- The constructor is where
you will implement part of the knows-a relationship - make sure to
check your notes about it since your book doesn't cover this
relationship.
- Lab6
- This class should contain your main method
- This
class will be where you create your JFrame and create and add your
DrawingPanel to it. You will also create your timer here and tell the
timer that your DrawingPanel object will be its listener.
Submitting
Include a readme file with
- Your name
- How do I run your program? What should I expect to see in it.
- What did you do and why? did you add any more methods? what were they?
- Any errors or incomplete parts of your program
Then zip up your lab6 directory and submit as usual.