|
||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Class Summary | |
---|---|
CommandLineProgram | This class simulates the functionality of a ConsoleProgram in an environment that lacks a graphics context. |
ConsoleProgram | This class is a standard subclass of Program that installs a console in the window. |
DialogProgram | This class is a standard subclass of Program that takes its input from a IODialog object. |
GraphicsProgram | This class is a standard subclass of Program whose principal window is used for drawing graphics. |
Program | This class is the superclass for all executable programs in the acm.program package. |
ProgramMenuBar | This class standardizes the menu bars used in the ACM program package. |
This package provides a set of classes that simplify the creation of programs. The package includes five abstract classes, each of which uses a particular paradigm for input and output, as follows:
Program | This class is the root of the program hierachy and defines a program in which input and output are performed using the system console, which is redirected to the standard Java I/O streams System.in and System.out. |
ConsoleProgram | This class is similar to Program but fills the program frame with an interactive console (as defined in the IOConsole class in the acm.io package). |
DialogProgram | This class extends the basic functionality of the Program class so that input operations are performed using the IODialog class in the acm.io package. |
CommandLineProgram | This class is similar to ConsoleProgram but uses System.in and System.out instead of an IOConsole. This class is typically used only for Java programs that are invoked from a command line and make no use of Javas graphical capabilities. |
The principal advantages of using the Program class are:
In most environments, the only thing students need to do to create a new program is to define a Program subclass that implements a runmethod. For example, the following class definition creates a traditional, stream-oriented program that reads in two integers and computes their sum:
public class Add2 extends ConsoleProgram { public void run() { println("This program adds two numbers."); int n1 = readInt("Enter n1: "); int n2 = readInt("Enter n2: "); int total = n1 + n2; println("The total is " + total + "."); } }
|
||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |