![]() |
Lehrer Nussbaumer - JAVA (eine kleine Einführung ;) |
|---|
GrundlagenGUIEingabeAusgabeApplikationenApplets
ServletsBeispieleSpieleIDEsSkriptumJAVA-DOCS----------------- letzte Änderung: 09 December 2021 ----------------- Lehrer Nussbaumers Seite ... in Arbeit ... |
Logistisches WachstumIm so genannten Verhulst-Modell werden das lineare und das beschränkte Wachstum berücksichtigt. Dies spiegelt sich in der (vereinfachten) Formel x(t+1)=r.x(t).[1 - x(t)]wider. Beispiel:Code:import java.awt.*;
import java.awt.event.*;
/**
*
* @author nus
*/
public class LogwachsAppl extends java.applet.Applet implements ActionListener {
public TextField eingabe;
public Button ok;
/** Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
setBackground(Color.white);
setLayout(new FlowLayout());
Label was = new Label("a: ");
add(was);
eingabe = new TextField("2.5",6);
add(eingabe);
ok = new Button("ok");
add(ok);
ok.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == ok) repaint();
}
public double verhulst(double x, double a) {
return a*x*(1-x);
}
public void paint(Graphics bs) {
double ys=0.01;
double yz=0.01;
double a = Double.parseDouble(eingabe.getText());
for (double x=0.01;x<3.5;x+=0.01) {
ys = verhulst(ys,a);
bs.setColor(Color.blue);
bs.fillRect((int)(x*100+25),400-(int)(ys*400),2,2);
bs.setColor(Color.red);
bs.drawLine((int)(x*100+24), 400 - (int)(yz*400),(int)(x*100+25),400 - (int)(ys*400));
yz=ys;
}
}
}
|