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 {
|
public abstract class World {
|
||||||
protected Canvas theCanvas;
|
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) {
|
public boolean bigBang(int width, int height, double s) {
|
||||||
if (width <= 0)
|
if (width <= 0)
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
|
@ -20,15 +28,51 @@ public abstract class World {
|
||||||
+ s);
|
+ s);
|
||||||
theCanvas = new Canvas(width,height);
|
theCanvas = new Canvas(width,height);
|
||||||
return bigBangO(s);
|
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);
|
*@param s is the message to be displayed
|
||||||
public abstract World onTick();
|
*@return true, if it succeeds in stopping the clock and displaying the message
|
||||||
public abstract World onKeyEvent(String ke);
|
*After the end of time, events no longer trigger calls
|
||||||
public abstract boolean draw();
|
*to onTick or onKeyEvent (see below). The canvas remains visible.
|
||||||
public abstract boolean erase();
|
*/
|
||||||
|
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