svn: r6897
This commit is contained in:
parent
719a85b1e9
commit
1162acb990
19
collects/htdch/draw/Makefile
Normal file
19
collects/htdch/draw/Makefile
Normal file
|
@ -0,0 +1,19 @@
|
|||
DRAW = /Users/matthias/plt/collects/htdch/
|
||||
|
||||
FILES = \
|
||||
World \
|
||||
Canvas
|
||||
|
||||
doc:
|
||||
javadoc -classpath $(DRAW) $(addsuffix .java, $(FILES)) -d docs -breakiterator
|
||||
|
||||
compile:
|
||||
|
||||
run:
|
||||
|
||||
test:
|
||||
|
||||
clean:
|
||||
rm -rf *~ *.class docs/
|
||||
|
||||
|
|
@ -2,6 +2,14 @@ package draw;
|
|||
|
||||
public abstract class World {
|
||||
protected Canvas theCanvas;
|
||||
|
||||
/**
|
||||
*@author Matthias Felleisen, Kathy Gray
|
||||
*@param width positive int, the width of the visible canvas
|
||||
*@param height positive int, the height of the visible canvas
|
||||
*@param s positive double, the rate at which the clock ticks per second
|
||||
*@return true if the world is created without obstacle
|
||||
*/
|
||||
public boolean bigBang(int width, int height, double s) {
|
||||
if (width <= 0)
|
||||
throw new RuntimeException(
|
||||
|
@ -20,15 +28,51 @@ public abstract class World {
|
|||
+ s);
|
||||
theCanvas = new Canvas(width,height);
|
||||
return bigBangO(s);
|
||||
};
|
||||
private native boolean bigBangO(double s);
|
||||
};
|
||||
private native boolean bigBangO(double s);
|
||||
|
||||
// --------------------------------------------------------
|
||||
// --------------------------------------------------------
|
||||
|
||||
public native boolean endOfTime(String s);
|
||||
public native World endOfWorld(String s);
|
||||
public abstract World onTick();
|
||||
public abstract World onKeyEvent(String ke);
|
||||
public abstract boolean draw();
|
||||
public abstract boolean erase();
|
||||
/**
|
||||
*@param s is the message to be displayed
|
||||
*@return true, if it succeeds in stopping the clock and displaying the message
|
||||
*After the end of time, events no longer trigger calls
|
||||
*to onTick or onKeyEvent (see below). The canvas remains visible.
|
||||
*/
|
||||
public native boolean endOfTime(String s);
|
||||
|
||||
/**
|
||||
*@param s is the message to be displayed
|
||||
*@return the last World, if it succeeds in stopping the clock and displaying the message
|
||||
*After the end of the world, events no longer trigger calls
|
||||
*to onTick or onKeyEvent (see below). The canvas remains visible.
|
||||
*/
|
||||
public native World endOfWorld(String s);
|
||||
|
||||
/**
|
||||
*@return the new world
|
||||
*The method is invoked for every tick of the clock. Its purpose is to create a
|
||||
* World whose differences with this one represent what happened during the amount
|
||||
* of time it takes the clock to tick.
|
||||
*/
|
||||
public abstract World onTick();
|
||||
|
||||
/**
|
||||
*@param ke the String representing the key that was pressed
|
||||
*@return the new world
|
||||
*The method is invoked for every keyboard event associated with the canvas.
|
||||
* Its purposes is to create a World whose differences with this one represent
|
||||
* what happens due to the user's use of the keyboard.
|
||||
*/
|
||||
public abstract World onKeyEvent(String ke);
|
||||
|
||||
/**
|
||||
*@return true, if the method succeeds in printing this world ('s canvas)
|
||||
*/
|
||||
public abstract boolean draw();
|
||||
|
||||
/**
|
||||
*@return true, if the method succeeds in erasing this world ('s canvas)
|
||||
*/
|
||||
public abstract boolean erase();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user