|
|
Resources to make teaching Java faster, more effective and more fun.
|
Quick Links |
|
|
The hsa package
Introduction
The hsa package consists of three applications and nine classes.
The applications make marking easier and provide some utilities
for users moving between different Java environments.
The classes make it easier for users to begin writing programs
that explore the basic concepts of computer science before coming
to terms with the input and output methods of the Java class
library.
To ensure the easiest possible transition from using the hsa
package to using only the Java class library, wherever possible we
have made the graphics methods in the Console class identical to
those in the Java Graphics class. The print and println methods of
the Console, Stdout, and TextOutputFile are also the same as those
in the Java PrintWriter class. In a number of cases the classes in the
hsa package contain extra methods.
To use the hsa classes, the following line must appear in the
class header:
import hsa.*;
If available, example programs using all the classes in the hsa
package can be found in the package labeled
Default package for Holt Software in the Holt Software
project.
-
Submit
-
A Java application program used to submit student's assignments for
marking.
This brings up dialog boxes to allow the user to enter the name of the
program to be submitted, the names of the Java text files that make up
the program, and the names of the test data files. It then prints the
Java text files, the input files, and the output produced from running
the program.
-
PrintFiles
-
A Java application program used to print Java files. It can paragraph
(indent) the file, bold keywords, and italicize identifiers in the
printout if requested.
-
PrettyPrint
-
A Java application program to indent (paragraph) Java programs. This
can help catch missing curly braces as well as improve program
legibility.
This application can also be used to indent programs for systems
where tabs stops mean a different number of spaces (in VisualAge
for Java tabs are four spaces, in Notepad, tabs are eight spaces)
or to change the size of a standard indent.
-
Console
-
The Console window can hold 25 lines of 80 column text. The user can
input data directly in the Console window and the output of the program
appears there too. Formatted text output is provided. It supports all the
basic Java Graphics class methods plus two more to draw stars and maple
leaves (suitable for flags).
The Console class window has three buttons. The "Save" button saves the
contents of the screen as a ".bmp" (Windows Bitmap) file. The "Print"
button prints out the contents of the window. The "Quit" button quits
the program immediately. It gives visual notification when the program
is finished execution by changing the label in the Quit button to "Close".
-
TextConsole
-
The TextConsole window is a 25x80 window used for text output. As the
output scrolls off the top of the window, a scroll bar is activated that
allows users to view all output from the program. The TextConsole class
differs from the Console class in that all text output is kept and can
be saved or printed.
The user can input data directly into the Console window. The output of
the program also appears there. Formatted text output is provided.
The TextConsole class window has three buttons. The "Save" button saves
all output sent to the window to a text file. The "Print"
button prints out all of the output. The "Quit" button quits
the program immediately. It gives visual notification when the program
is finished execution by changing the label in the Quit button to "Close".
-
Stdin
-
This is a non-instantiated class to allow users to read all the
Java primitive data types from standard input before they have
learned about exception handling and the intricacies of the Java
primitive wrapper classes. It also makes it possible to read
several primitives from one line of input without
having to know the StringTokenizer class.
-
Stdout
-
This is a non-instantiated class to allow users to output formatted
data to standard output without having to learn the
java.text.NumberFormat class. Users can write data to fixed length
fields and with a fixed number of decimal places.
-
TextInputFile
-
This class makes it easier to read from text files. It allows the
user to read any Java primitive data type from a text file and
does all the conversions, string tokenizing, and exception handling
automatically.
-
TextOutputFile
-
This class makes it easier to write to text files. It's major
convenience is that it handles formatted output. Users can specify
field length when outputting primitive data type as well as the
number of decimal places when outputting real numbers.
-
FatalError
-
This is a class to display fatal errors. When instantiated, it
displays a window with a specified message and a button labeled
"Quit". When the button is pressed, the program immediately exits.
Helpful for users who want to add error checking to their program but
are not yet familiar with Frames and the rest of the Java class library.
-
Message
-
This is a class to display messages. When instantiated, it displays a
window with a specified message and a button labeled "OK". When the
button is pressed, the program continues execution.
-
Status
-
A quick way of displaying changing status messages without having to
learn about Frames, and so on.
[ Java Home ] *
[ Top of Page ] *
[ Feedback ]