head 1.3;
access;
symbols
IT1FALL00:1.1;
locks; strict;
comment @# @;
1.3
date 2001.03.23.12.48.43; author dbc; state Exp;
branches;
next 1.2;
1.2
date 2001.01.29.12.38.02; author dbc; state Exp;
branches;
next 1.1;
1.1
date 2000.09.11.17.54.08; author dbc; state Exp;
branches;
next ;
desc
@@
1.3
log
@Modified Files:
hw2.html hw3.html
@
text
@
Writing a Java application with Swing components
You are asked to write a Java application to manipulate entries
in a text file. The program must have a Graphical User Interface using
Swing components.
Choose a meaningful interpretation for the entries stored in your
file. They might be names and addresses, or titles and bibliographic
information, or something more imaginative.
Each file entry should consist of a "key" string (e.g. a person's
name or ID, a book's author or ISBN, etc) and one or more
strings representing associated data fields.
You may choose to lay out these fields in your text
file on consecutive lines, e.g.
key
data1
data2
key
data1
data2
...
Your program should be able to read the whole text file and store all
entries in internal data structures of your design. One convenient
possibility may be to store the keys in a
javax.swing.DefaultListModel and to store the data
fields in objects stored in a java.util.HashMap. The
program should also be able to save the modified data structures back
to the text file in the original format.
The graphical user interface should have at least
- A scrollable list component for selecting entries. The list should
display the key strings for your file entries.
- Text fields and/or text areas for displaying, entering and
modifying data fields in your file entries.
- Buttons to add and
delete entries, and a means of modifying existing entries.
Try to add one or two other features relevant to your chosen
application.
Development Platform
You may be able to develop and run your Swing-based program on
sirah or the other course hosts. However this is only likely
to work if you are logging in from a computer that can display
remote X-Windows based applications--perhaps a UNIX workstation or
a PC running Hummingbird Exceed. Even then
you may still have problems displaying the remote graphical application
if there is a firewall between you and sirah.
So in general I recommend you develop your GUI application locally on
your PC or workstation instead.
If necessary (and allowed), you can download Java software from
SDK 1.2
or
SDK 1.3.
Please let me know if this is impractical for you.
I will accept software developed with any version of Java that includes
the Swing set.
Submission of your Homework
Your submission should consist of files including
-
A description of your program and the format of your data file,
preferably in Microsoft Word,
HTML, or plain text format,
- all Java source code, and
- an example data file.
You may optionally include javadoc documentation as .html
files. However this cannot be submitted in place of your main document.
On sirah you will find a directory called
/home/project/it1spring01/homework2/uid where
uid is your login ID. To submit Assignment 2,
please copy your files into this directory.
Grading
For this assignment, there will be a total of 20 points.
Grading criteria are similar to
Assignment 1.
Some points will be assigned on the basis of apparent effort and
uniqueness, and on the extent to which your application presents an
attractive and intuitive GUI.
Useful resources
Simple Swing examples
You will find most of the Swing components you are likely to need
illustrated in the
examples
from the lectures.
Simple reading and writing of text files
Since this wasn't covered in class, there is an example that reads
lines in a text file, and writes them back to another text file, in
here.
Simple use of collection classes
I have added a few extra slides on Vector and
Hashmap to the online lectures on the Java language.
See slides 71 to 76.
The Standard API classes
Including Swing, see
the Java 2 API specification.
Please send questions to Bryan Carpenter at dbc@@csit.fsu.edu.
@
1.2
log
@Modified Files:
hw1.html hw2.html
@
text
@d66 1
a66 1
sirah or the other course hosts. This is only likely
d69 1
a69 1
a PC running Hummingbird Exceed (and even then
d71 1
a71 1
if there is a firewall between you and sirah).
d73 2
a74 2
In general I recommend you develop GUI applications locally on
your PC or workstation.
d117 1
a117 1
The Standard API classes
d119 4
a122 3
Including Swing, see
the Java 2 API specification.
d130 7
a136 1
Simple Swing examples
d138 3
a140 4
You will find most of the Swing components you are likely to need
illustrated in the
examples
from the lectures.
@
1.1
log
@*** empty log message ***
@
text
@d3 2
a4 1
Programming for the Web: Homework 1
d9 1
a9 1
CIS 6930-01
Fall 2000
d11 2
a12 1
Assignment #2
d14 1
a16 78
Writing a Java application with class structure
There are two types of Java programs: applications and applets. An
applet is a web-based Java program embedded in an
HTML document. An application, on the other hand, is not
web-based. It is developed and run at the command line, much like a C
program.
Your first Java programming assignment is to write an application that
uses a class. The
goal is to start by giving you some practice with Java syntax and making
sure that you understand the class concept.
Before starting this assignment, you should should become familiar with
the Java programming
environment on sirah.
You may also use Java compilers on other systems if your prefer, or a
programming environment such as J++ or Cafe'. But if you use a programming
environment, do not use it to generate code for you. Also see the tutorial
materials for links to download an editor such as JavaEdit or TextPad for
use on a PC.
Writing the programs
Choose one of the following two sets of programs to write.
Choice 1: Writing and Testing a class Candy
Design and implement a class to represent pieces of candy. There will
be three instance variables to represent properties of the candy:
- String shape; // this may take values such as "square", "round" or "blob".
- Color c;
- String flavor; // values such as "vanilla", "chocolate", or "yuck".
Write a constructor method that takes three arguments that are used as
values to initialize the instance variables.
You should also write the following public methods.
- three "set" methods - one to assign each instance variable
- either three "get" methods to return the values of the instance
variables, or a method called "toString" that returns a string
describing the three properties of the candy.
- a method called "combine" which takes two arguments of type Candy and
returns a result of type Candy. This method should combine the properties
of the two arguments to return a new third candy. You can decide how to
combine them. For combining shapes and flavors, you can arbitrarily pick
a result shape and flavor, and in at least
one case you should refuse to combine incompatible shapes and
flavors by returning an exception. For combining colors, you could average
together the red, blue and green values of the two colors. (Check the
API Color class to see how to find out the RBG values of a Color.)
- You may design additional methods if needed by your test application
program below.
You must also write a test program for this
class:
Design an application that prompts the user to type in the shape, color,
and flavor of at least two pieces of candy. Create an instance of the
Candy class for each one. Combine the two pieces to get a third piece of
candy and either use the "get" methods or the "toString" method to print
out a description of the result.
Show a couple of runs of the program. Be sure to demonstrate a case
of successfully combining candies and also one which doesn't because the
combine gives an Exception.
d18 1
a18 1
a19 8
Choice 2: Writing and Testing a class DataSets
Design and implement a class to represent a set of data, that is a number
of experimental numbers representing some value. You will need an
instance variable to keep the data:
d21 29
a49 4
Write a constructor method that takes two arguments: an int n that is
used to create the data array to be of length n, and an array of doubles
of length n. After creating the data array, the constructor should copy
the argument array to the data array to initialize it.
d51 1
a51 1
You should also write the following public methods.
d53 82
a134 36
- a method that returns data.length.
- a method that computes the arithmetic mean (average value)
of the array values and returns it.
- a method to compute and return the standard deviation of the values of
the array. Here is a definition of the mean (called mu in the diagram) and
standard deviation for an array of length n:
where the notation "sigma x" is to be interpreted as summing all the elements
of the array and the notation "sigma x squared" means to first square each
element of the array and then sum them.
- a method combine that takes two data sets and produces a third one.
You should combine the two datasets only if the arrays have the same
length and give an exception otherwise. When the arrays are the same
length, you can combine them by averaging together each pair of array
elements.
- You may design additional methods if needed by your test application
program below.
You must also write a test program for this
class.
Design an application that prompts the user to type in at least two
sets of double values. Create an instance of the
DataSet class for each one. Compute the mean and standard deviation of
each dataset and print the results. Then combine the two DataSets to get
a third one and print out its mean and standard deviation.
Show a couple of runs of the program. In a case where you
refuse to combine some
datasets, be sure to demonstrate that part.
a135 32
What to put on the homework page as the submission of your homework
Submit your assignment by linking the description of your program, a
link to the Java source code and a small
file showing sample output run (like my .run files) to your homework page.
For how to write a description of your homework and document your program,
and other information, please see these
homework guidelines.
Grading
For this assignment, there will be a total of 15 points. These will be
separated into partial points of 5 and 10 as follows:
- 5 points are for the assignment description, comments in the code,
and documentation in general.
- 10 points are for writing Java code in a good style that is easy to
understand, that your programs meet the requirements and produce nice
output. Some of the points in this partial will be for effort and
uniqueness.
a141 2
@