You are on page 1of 7

EXPO CLASS VERSION 12/19/2008 Leon and John Schram The concept and implementation of the original set

of Expo class methods was created by John L. M. Schram (the Son), who is called John Schram. The Expo class was created to teach programming skills to students in introductory computer science courses. Use of the Expo class eliminates many program steps that are tedious and frustrating for beginning students. Program input is simplified and graphics commands are more intuitive. Many additional graphics commands are added to allow for interesting displays with minimal effort. Since the creation of the initial bulk of the Expo class, John L. A. Schram (the father), who is called Leon Schram, has added some additional methods. Both John Schram and Leon Schram are computer science teachers at John Paul II High School in Plano, Texas. 1 2 3 4 5 center(java.lang.String str) Displays centered text on an 80 column text screen. cube(double number) Returns the "cube" of number, which is number raised to the 3rd power. cubeRoot(double number) Returns the cubeRoot (3rd root) of number. delay(int n) Pauses the output for a specified number of milliseconds (1/1000ths of a second).

displayGUI(boolean temp) Displays a boolean (true or false) value in a GUI window. The window will stay on the screen until the user clicks "OK". 6 7 displayGUI(char temp) Displays a char in a GUI window. The window will stay on the screen until the user clicks "OK".

displayGUI(double temp) Displays a double (real number) in a GUI window. The window will stay on the screen until the user clicks "OK". 8 9 displayGUI(int temp) Displays an int (integer) in a GUI window. The window will stay on the screen until the user clicks "OK". displayGUI(java.lang.String text) Displays a String in a GUI window. The window will stay on the screen until the user clicks "OK".

10 drawArc(java.awt.Graphics g, int centerX, int centerY, int hRadius, int vRadius, int start, int finish) Draws and arc which looks like a curve. An ARC is a "piece" of an OVAL. The first 5 parameters (g and 4 ints) are the same as drawOval. There are 2 additional parameters for the starting degree value and finishing degree of the arc. 11 drawBurst(java.awt.Graphics g, int centerX, int centerY, int radius, int numLines) Draws a certain number of lines (numLines) in a burst like pattern. The lines are evenly spaced and drawn from the center of a circle to its edge. The size of the circle is specified by the radius parameter. 12 drawCircle(java.awt.Graphics g, int centerX, int centerY, int radius) Draws an open circle. The user specifies the x,y coordinate of the center of the circle as well as the radius value. /var/www/apps/conversion/current/tmp/scratch29885/89529463.doc Page 1

13

drawGrid(java.awt.Graphics g, int w, int h, int s) Draws a Cartesian grid with X-axis and Y-axis. The graph will be the size specified by w(width) and h(height). The final parameter (s) indicates the spacing and effectively scales the graph. 14 drawLine(java.awt.Graphics g, int x1, int y1, int x2, int y2) Draws the line segment connecting coordinates x1,y1 and x2,y2.

15 drawOval(java.awt.Graphics g, int centerX, int centerY, int hRadius, int vRadius) Draws an open oval. The user specifies the x,y coordinate of the center of the oval as well as the horizontal and vertical radii values. 16 17 drawPixel(java.awt.Graphics g, int x, int y) Draws a single pixel at the specified x,y location. drawPoint(java.awt.Graphics g, int x, int y) Draws a 3 pixel X 3 pixel "point" whose center is at the specified x,y location.

18 drawQuad(java.awt.Graphics g, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) Draws an open irregular quadrilateral using the four sets of provided coordinates. 19 drawQuadrant1(java.awt.Graphics g, int w, int h, int s) Draws a "Quadrant I" of a Cartesian grid with X-axis and Y-axis. The graph will be the size specified by w(width) and h(height). The final parameter (s) indicates the spacing and effectively scales the graph. 20 drawRandomBurst(java.awt.Graphics g, int centerX, int centerY, int radius, int numLines) Draws a certain number of random lines in a burst like pattern. The lines have random colors, random lengths and are drawn in random directions. The parameters are the same as drawBurst. 21 drawRectangle(java.awt.Graphics g, int x1, int y1, int x2, int y2) Draws an open rectangle. The upper-left-hand corner is specified by x1,y1 and the lower-right-hand corner is specified by x2, y2. 22 drawRegularPolygon(java.awt.Graphics g, int centerX, int centerY, int radius, int sides) Draws an open regular polygon with a specified number of sides. The center of this polygon is specified by centerX,centerY and its size is specified by radius (As in the radius of the circle the regular polygon would fit inside). 23 drawRoundedRectangle(java.awt.Graphics g, int x1, int y1, int x2, int y2, int radius) Draws an open rectangle with rounded corners. The first 5 parameters (g and 4 ints) are the same as drawRect. The final parameter "radius" specifies the pixels used in the rounded corner. 24 drawSpiral(java.awt.Graphics g, int centerX, int centerY, int radius) Draws a spiral. The center of the spiral is specified with the centerX,centerY parameters. The radius parameter determines the size of the spiral (It is actually the radius of the circle that the spiral would fit inside). 25 drawStar(java.awt.Graphics g, int centerX, int centerY, int radius, int points) Draws an open star with a specified number of points. The center of this star is specified by centerX,centerY and its size is specified by radius (As in the radius of the circle the star would fit inside).

/var/www/apps/conversion/current/tmp/scratch29885/89529463.doc

Page 2

26 drawThickArc(java.awt.Graphics g, int centerX, int centerY, int hRadius, int vRadius, int start, int finish, int thickness) Draws a "thick" arc which will look like a thick curved line. The parameters are the same as drawArc, except there is an extra parameter at the end for the thickness. 27 drawThickBurst(java.awt.Graphics g, int centerX, int centerY, int radius, int numLines, int thickness) Draws a certain number of "thick" lines in a burst like pattern. The parameters are the same as drawBurst, except there is an extra parameter at the end for the thickness. 28 drawThickCircle(java.awt.Graphics g, int centerX, int centerY, int radius, int thickness) Draws a "thick" circle. The user specifies the x,y coordinate of the center of the circle as well as the radius value. The thickness is specified in the last parameter. 29 drawThickLine(java.awt.Graphics g, int x1, int y1, int x2, int y2, int thickness) Draws a "thick" line segment connecting coordinates x1,y2 and x2,y2. The thickness is specified in the last parameter. 30 drawThickOval(java.awt.Graphics g, int centerX, int centerY, int hRadius, int vRadius, int thickness) Draws a "thick" oval. The user specifies the x,y coordinate of the center of the oval as well as the horizontal and vertical radii values. The thickness is specified in the last parameter. 31 drawThickQuad(java.awt.Graphics g, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int thickness) Draws an "thick" open irregular quadrilateral using the four sets of provided coordinates. The parameters are the same as drawQuad, except there is an extra parameter at the end for the thickness. 32 drawThickRandomBurst(java.awt.Graphics g, int centerX, int centerY, int radius, int numLines, int thickness) Draws a certain number of random "thick" lines in a burst like pattern. The "thick" lines have random colors, random lengths and are drawn in random directions. The parameters are the same as drawRandomBurst, except there is an extra parameter at the end for the thickness. 33 drawThickRectangle(java.awt.Graphics g, int x1, int y1, int x2, int y2, int thickness) Draws a "thick" open rectangle. The parameters are the same as drawRectangle, except there is an extra parameter at the end for the thickness. 34 drawThickRegularPolygon(java.awt.Graphics g, int centerX, int centerY, int radius, int sides, int thickness) Draws a "thick" regular polygon with a specified number of sides. The parameters are the same as drawRegularPolygon, except there is an extra parameter at the end for the thickness. 35 drawThickRoundedRectangle(java.awt.Graphics g, int x1, int y1, int x2, int y2, int radius, int thickness) Draws an "thick" open rectangle with rounded corners. The parameters are the same as drawRoundedRectangle, except there is an extra parameter at the end for the thickness. 36 drawThickSpiral(java.awt.Graphics g, int centerX, int centerY, int radius, int thickness) Draws a "thick" spiral. The parameters are the same as drawSpiral, except there is an extra parameter at the /var/www/apps/conversion/current/tmp/scratch29885/89529463.doc Page 3

end for the thickness. 37 drawThickStar(java.awt.Graphics g, int centerX, int centerY, int radius, int points, int thickness) Draws a "thick" star with a specified number of points. The parameters are the same as drawBurst, except there is an extra parameter at the end for the thickness. 38 drawThickTriangle(java.awt.Graphics g, int x1, int y1, int x2, int y2, int x3, int y3, int thickness) Draws an "thick" open irregular triangle using the three sets of provided coordinates. The parameters are the same as drawTriangle, except there is an extra parameter at the end for the thickness. 39 drawTriangle(java.awt.Graphics g, int x1, int y1, int x2, int y2, int x3, int y3) Draws an open irregular triangle using the three sets of provided coordinates. 40 41 42 43 44 45 46 47 48 49 enterBoolean() Allows input of a boolean (true or false) from the keyboard in a text window. enterBooleanGUI(java.lang.String prompt) Allows input of a boolean (true or false) from the keyboard using a GUI window. enterChar() Allows input of a char from the keyboard in a text window. enterCharGUI(java.lang.String prompt) Allows input of a char from the keyboard using a GUI window. enterDouble() Allows input of a double (real number) from the keyboard in a text window. enterDoubleGUI(java.lang.String prompt) Allows input of a double (real number) from the keyboard using a GUI window. enterInt() Allows input of an int (integer) from the keyboard in a text window. enterIntGUI(java.lang.String prompt) Allows GUI input of an int (integer) from the keyboard. enterString() Allows input of a String from the keyboard in a text window. enterStringGUI(java.lang.String prompt) Allows input of a String from the keyboard using a GUI window.

50 fillArc(java.awt.Graphics g, int centerX, int centerY, int hRadius, int vRadius, int start, int finish) Draws a "solid" arc which will look either like a pie wedge or Pac-man. A FILLED ARC is a "piece" of a SOLID OVAL. The first 5 parameters (g and 4 ints) are the same as drawOval. There are 2 additional parameters for the starting degree value and finishing degree of the arc. 51 fillCircle(java.awt.Graphics g, int centerX, int centerY, int radius) Draws a solid "filled in" circle. The user specifies the x,y coordinate of the center of the circle as well as the radius value. 52 fillOval(java.awt.Graphics g, int centerX, int centerY, int hRadius, Page 4

/var/www/apps/conversion/current/tmp/scratch29885/89529463.doc

int vRadius) Draws a solid "filled in" oval. The user specifies the x,y coordinate of the center of the oval as well as the horizontal and vertical radii values. 53 fillQuad(java.awt.Graphics g, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) Draws an solid "filled-in" irregular quadrilateral using the four sets of provided coordinates. 54 fillRectangle(java.awt.Graphics g, int x1, int y1, int x2, int y2) Draws a solid "filled in" rectangle. The upper-left-hand corner is specified by x1,y1 and the lower-righthand corner is specified by x2, y2. 55 fillRegularPolygon(java.awt.Graphics g, int centerX, int centerY, int radius, int sides) Draws a solid "filled in" regular polygon with a specified number of sides. The center of this polygon is specified by centerX,centerY and its size is specified by radius (As in the radius of the circle the regular polygon would fit inside). 56 fillRoundedRectangle(java.awt.Graphics g, int x1, int y1, int x2, int y2, int radius) Draws a solid "filled in" rectangle with rounded corners. 57 fillStar(java.awt.Graphics g, int centerX, int centerY, int radius, int points) Draws a solid "filled in" star with a specified number of points. The center of this star is specified by centerX,centerY and its size is specified by radius (As in the radius of the circle the star would fit inside). 58 fillTriangle(java.awt.Graphics g, int x1, int y1, int x2, int y2, int x3, int y3) Draws an solid "filled-in" irregular triangle using the three sets of provided coordinates. 59 60 61 getRandomColor() Returns a random Color object which can be any of the 16,000,000+ possible colors. graphHorizontalLine(java.awt.Graphics g, double yIntercept) Draws a horizontal line which crosses the Cartesian grid and goes through the specified y-intercept. graphLine(java.awt.Graphics g, double slope, double yIntercept) Draws a line across the Cartesian grid using a slope in decimal form and a y-intercept.

62 graphLine(java.awt.Graphics g, double mathX1, double mathY1, double mathX2, double mathY2) Draws a line across the Cartesian grid. The line will go through the 2 points specified in the parameters. 63 graphLine(java.awt.Graphics g, int slopeNumerator, int slopeDenominator, double yIntercept) Draws a line across the Cartesian grid using a slope in fraction form (with an integer numerator and an integer denominator) and a y-intercept. 64 graphLineSegment(java.awt.Graphics g, double mathX1, double mathY1, double mathX2, double mathY2) Draws a line "segment" on the Cartesian grid. The line will start at coordinate(mathX1,mathY1) and finish at coordinate (mathX2,mathY2). 65 graphPoint(java.awt.Graphics g, double mathX, double mathY) Plots a point on the Cartesian grid. Page 5

/var/www/apps/conversion/current/tmp/scratch29885/89529463.doc

66 graphPoint(java.awt.Graphics g, double mathX, double mathY, java.lang.String label) Plots a labeled point on the Cartesian grid. 67 graphQuadratic(java.awt.Graphics g, double a, double b, double c) Draws a parabala on the Cartesian grid. The parabola will represent the equation: y = ax^2 + bx + c a, b, & c correspond to the parameters of the same name. 68 graphVerticalLine(java.awt.Graphics g, double xIntercept) Draws a vertical line which crosses the Cartesian grid and goes through the specified x-intercept.

69 heading(java.lang.String name, java.lang.String lab, java.lang.String date, java.lang.String points) Creates a heading for a program that is to be printed and turned in. 70 71 72 73 74 75 76 77 pause() Pauses the output and waits for the user to press the [enter] key. random(int min, int max) Returns a "true" random integer in the [min..max] range, inclusive. rightJustify(java.lang.String str) Displays right-justified text on an 80 column text screen. root(double number, double x) Returns the xth root of number. seedRandom(int min, int max) Returns a "seeded" random integer in the [min..max] range, inclusive. setBackground(java.awt.Graphics g, java.awt.Color bgColor) Sets the entire background to a single color. setColor(java.awt.Graphics g, java.awt.Color bgColor) Allows the user to change the color, using a Color object.

setColor(java.awt.Graphics g, int colorNum) Allows the user to change to one of 15 predefined colors using a single integer. This is especially useful in programs where you want to change from one color to a contrasting color quickly. 78 setColor(java.awt.Graphics g, int red, int green, int blue) Allows the user to change the color, using 3 int values representing the amount of red, green and blue. This allows for more than 16 million different color combinations. 79 80 setRandomColor(java.awt.Graphics g) Sets the current color to a random color value which can be any of the 16,000,000+ possible colors.

skip(int n) Utility method that will skip a certain number of blank lines on a text output screen. This is used to space out text output. 81 82 83 spaces(int n) Returns a certain number of spaces. Useful when lining up output. square(double number) Returns the "square" number, which is the number multiplied times itself. startSeed(double s) Page 6

/var/www/apps/conversion/current/tmp/scratch29885/89529463.doc

Provides the initial value of the "seeded" random integers.

/var/www/apps/conversion/current/tmp/scratch29885/89529463.doc

Page 7

You might also like