Lab Review -- 11/6
You should not have a partner for this lab. For each, if you know how to do it and could without any effort at
all, just go on to the next one; on the other hand, if it seems at all difficult, do it!
- Write a Java application
that outputs the word Greetings to the output window when it runs.
- Write a Java application
that opens an AWT Frame with a TextField and a button. When you push the Button it writes,
"Greetings!" in the TextField.
- Write a Java application
that opens an AWT Frame with 2 TextFields. When you enter a name (say Gail) in the first, it writes,
"Hi, Gail!" in the second.
- Write a Java application
that opens an AWT Frame with 3 TextFields and a Button. Make the Button have a + on it. When you push the Button, input the numbers from the first two TextFields and output their sum to the third
- Write a prototype ATM machine: one account only, everything done in one class. Let the user display their balance, or withdraw as much as they want.
- Write an Account class with a single int variable to store the Balance. Rewrite the
prototype to use an Account variable instead of a local balance variable (yes, that means you will
need accessors to get and set the balance).
- Write an ATM
program that will manage three bank accounts. Each account will have a name and a balance.
Allow users to display their current balances and withdraw as much (simulated) money as they
want with a graphical user interface (GUI). Include some way to switch between the three accounts. (hint: look at Chapter 3!)
- Write a
Circle class with three variables, x, y and r. Write accessors for all three. Create a Frame with two Buttons. Create a Circle and display it using public void paint(Graphics).
- Write a FilledCircle class that extends Circle. A FilledCircle should use fillOval instead of drawOval in paint. Just write one method, void paint(Graphics) in FilledCircle. Test your class by changing the Circle in the previous to a FilledCircle and see that it still works.
- Add a Color variable to your FilledCircle class so that FilledCircles can be any color. If you want to change the color, you will need an accessor. Test it.
- Write an application to draw two eyes on the screen. For simplicity you need only
draw the iris and pupil. Make the iris the exact same color as yours. The distance between the two
eyes and the size of the pupil relative to the iris should be adjustable by the user.
- Write an method to report the score in a tennis game. Its signature should be:
String reportScore(int, int); test it on every combination of 0-3 for server and 0-3 for receiver.
- Add buttons that will allow each player to score, and make sure it still works.
- Write a boolean gameOver(int, int) method that will return true just if a tennis game is over (i.e.
one player or the other has at least 4 points and is at least 2 ahead
- Write a boolean simpleScore(int, int) method that will return true just both paramaters are less than or
equal to 3.
- Write a String notSoSimpleScoring(int, int) method that will return "deuce" if the parameters are equal,
"advantage server" if the first parameter is bigger than the second, and "advantage receiver" if the second is
bigger than the first.
- put those all together to make a complete tennis program!