Graphics for free Academic Article uri icon

abstract

  • Students find computer graphics one of the most interesting topics in computer science. Unfortunately, writing programs with graphics requires understanding concepts that are usually beyond the scope of an introductory computer science course. For example, in Windows 95, a program that uses graphics must have an event loop that dispatches messages to the appropriate handler. Event loops, messages and handlers are well beyond the grasp of someone just learning about variables! As a result, programming assignments for introductory courses tend to use no graphics, or simple ANSI graphics (see, e.g. Feldman and Koffman [1]). These programs compare unfavorably to the graphics of games most students are accustomed to using, and motivation to program in an introductory course may be lost.Ideally, we would like to be able to have students write programs that have more appealing interfaces, yet do not require a large amount of additional conceptual complexity. In fact, the best case would be to have the student write a program as if it were a simple text-based program, and have the compiler automatically add a graphical interface. Languages that provide overloading, such as Ada 95, allow us to accomplish precisely that.This paper describes a library, Graphics_110 (named in honor of our introductory course), which, using overloading, replaces the standard I/O libraries in Ada 95: Ada.Text_IO, Ada.Float_Text_IO, and Ada.Integer_Text_IO. By following a simple contract and replacing calls to the standard libraries with calls to Graphics_110, the student obtains a program, with a Windows-style interface without ever having to worry about the implementation details. Although we use Ada 95 for this paper, the ideas extend to any programming language that provides subtypes and overloading.The next section describes the "contract" the programmer must follow to use the library and the third section describes the implementation of Graphics_110. In each section, we describe how Graphics_110 was used with a battleship game implemented in our introductory course. The final section presents conclusions and ideas for future work.

author list (cited authors)

  • Carlisle, M. C.

publication date

  • January 1, 1998 11:11 AM