/* Resource simulation - Knut Ekker, knut@neti.no January 1996 */ import java.awt.*; public class resource extends java.applet.Applet implements Runnable { int wx, wy, yoff,xpts[],ypts[],nx,harvest,origo, OtherHarv, FertRes; int OrigResource, Resource, Growth, MaxResource, PctFert, count, pause1; double x0,xmin,xmax,dx,ymin,ymax,dy,xscale,yscale,tmin,t,dt; double width, vwidth, vx; Thread kicker = null; Button Restart = new Button("Restart"); Button Pause = new Button("Pause"); Button Stop = new Button("Stop Simulation"); Choice C = new Choice(); public void init() { pause1 = 10000; wx = size().width; wy = size().height; resize(wx,wy); setBackground(Color.white); nx = wx / 2; xpts = new int[nx]; ypts = new int[nx]; yoff = 50; count = 0; origo = yoff + 250; OrigResource = 50000; MaxResource = 2*OrigResource; Growth = 12; /* % growth of resource */ PctFert = 22; /* % of resource that may reproduce */ OtherHarv = 2; /* % of total resource harvested by other nations */ harvest = 350; wy -= yoff; InitSimulation(); Panel p = new Panel(); p.setLayout(new FlowLayout()); p.add(Pause); p.add(Restart); p.add(Stop); C.addItem("Harvest 250 tons"); C.addItem("Harvest 300 tons"); C.addItem("Harvest 350 tons"); C.addItem("Harvest 400 tons"); C.addItem("Harvest 450 tons"); C.select ("Harvest 350 tons"); p.add(C); add("North",p); Restart.disable(); C.disable(); } public void pause(int t) { for (int x=0;x