Programming Assignment 3

Date Due: October 18, 2000

 

 

Assignment - #4.6 on page 218

 

Write an applet that displays a graphical seating chart for a dinner party.  Create a class called Diner that stores a person’s name, gender, and location at the dinner table.  A diner object is graphically represented as a circle, color coded by gender, with the person’s name printed in the circle.

 

 

Requirements

 

You must at least do the following things for this program to receive full credit:

 

The assignment must be an applet, not an application, with your class name being your lastname, all lowercase.  For example, the first line of a program I did would be

                public class kappers extends Applet

 

You will also create a class called Diner, that you will save in another java file, Diner.java, and import into your main class.

The Diner class must have the following:

- four private member variables for storing a person’s name, gender and table x and y location.

- a public member constant for the person’s circle size

- two constructors, one default that sets the guest name to your own at some default location, and one that takes four parameters (String name, char gender, int x_location, int y_location)

- a Paint method that takes a Graphics object as a parameter, that draws a circle representing a guest with the given name, at the given location, in the correct gender color (Hint: import java.awt.* in your Diner class so you can use Graphics as a parameter to your Paint method)

 

Your main class will create at least 5 Diner objects, one of which will use the default constructor, the others use the other constructor.

 

Comment your code – name and SSN are a must!!

 

 

Be sure to follow all instructions above, as I will be testing your code with my own main class, too, to test that you followed directions.

 

 

Deliverables

 

Turn in a hard copy (print out) of your program to me in class the night the program is due.  You must also send your program to me electronically, to my email address (kathleen@cs.ucf.edu).  The subject line of your program should be Assignment #3 – emails without this subject will be returned.  This is so I can distinguish them from questions you may have.  You will be emailing me both your .java files and a .html file, so that I can compile and run them on my own.  Do NOT just send me an html file or a url link – I need to be able to compile your code.

 

Be sure to name your class, your .java file, and your .html file all the same name as your lastname, all lowercase!!