FHTW Berlin |
The laboratory project for next week, the Scribble, will introduce you to AWT programming. The application that you will build is a line-drawing scribbler program.
This time you will not be provided with a Main class. Instead, you will be supplied with some of the basic component types that you will need to make your program work. You will also be given a smart repository that knows how to keep track of and draw lines -- but not (yet) which lines to manage.
Your job will be to glue these pieces together to provide a working Scribble application. This assignment emphasizes the following topics :
You should read through this entire assignment and complete the Lab preparation section before lab next week.
A writeup of the finger exercises should always be turned in along with your completed laboratory next week. Use the time this week to get them done.
Using the Java AWT Quick Reference appendix or Sun's online Java Applications Programmer Interface (API) documentation, answer the following questions. For each question, give both the answer to the question and the way that you found this answer.
[CHECK-IN] [TURN-IN]
These are the only things that you need to program this week! The rest is just design and preparation for the lab!
This week's finger exercises are designed to help you with the lab assignment, and you have to do them before you begin your lab. You need to write them up explicitly for check-in. (You do not need to do the bonus exercises (at all), though.)
If you want to take a look at what the Scribble will look like and what your basic functionality should be like, take a look at a working demo at the www.cs101.org site.You download scribble.jar and type java -jar scribble.jar in a shell.
Your job in lab will be to implement (and possibly extend) that behaviour.
We have provided you with several support classes:
You should familiarize yourself with all three of these classes. Be especially certain that you understand the division of labor among instances of these classes!
Note that these links point to documentation for the classes, not to their code. You should not need to look at the code itself. However, you should be familiar with the interfaces provided by each of these three classes and how they interrelate. For example:
[CHECK-IN]
Your first task in lab will be to define a standalone Java program. In order to do this, you will need to create a class with a public static void main( String[] args ) method. (The main method is the method called by default when the virtual java machine starts running your code.) Figure out how to do this. Think about a simple way to test this functionality.
[CHECK-IN]
Next, you'll need to connect your main method to this assignment by having it create a Whiteboard. Your next pre-lab task is therefore to figure out how to write this class. Bring your design with you to lab. If you want to test it, how would you do it? What do you expect to see at this stage?? Don't program it, just design it!
After the previous steps, you will have designed code that should run and create something that looks like a Scribbler. The definition so far, though, doesn't do much in the way of drawing. The most important problem here is in the SmartCanvas: it doesn't handle any Events. You will need to to fix this. Your next pre-lab task is to figure out what events to handle and how to handle them.
[CHECK-IN]
Design this code and bring it with you to lab. This does not mean that you program it at home, but that you plan how you will be doing it! You may wish to have several stages here, too. (Some suggestions are included in the lab section, below.)
In order to run this code, how will you need to change your startup code?
[CHECK-IN] [TURN-IN]
The final thing that you should bring to lab is a plan of the stages in which you will write and test your code. Be very wary of a design plan in which you write more than a few lines of code without testing them. You should never build too much without seeing it run. This design plan should include an explicit (written) list of steps in which you will build and test your code. You may want to read through the additional suggestions in the In the Lab section, in Lab 13.Note that a plan is NOT the code! It is just a plan of what you want to try in the lab. You will write the code next week.
When you arrive at lab, you should have answers to the questions in the lab preparation, your finger exercises, a copy of your code design and your development plan ready so that I can check you into lab.