( benz | 2024. 12. 19., cs – 15:00 )

Bar nyilvan asch kollega is meg tudja tenni, de bemasolom ide a dekompilalt kodot.

import java.applet.Applet;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.util.Random;

public class alcsnow extends Applet implements Runnable {
  Thread mainThread;
  
  Image offScrn;
  
  Graphics offGrph;
  
  Random rand;
  
  int stopFlag;
  
  long stopTime;
  
  int[] snowX;
  
  int[] snowY;
  
  int snows;
  
  int wind;
  
  int threadSleep;
  
  Dimension dim;
  
  Image[] gAlc;
  
  MediaTracker mt;
  
  public void init() {
    this.rand = new Random();
    this.dim = size();
    this.offScrn = createImage(this.dim.width, this.dim.height);
    this.offGrph = this.offScrn.getGraphics();
    String str = getParameter("snows");
    if (str == null) {
      this.snows = 100;
    } else {
      this.snows = Integer.valueOf(str).intValue();
    } 
    if (this.snows > 500)
      this.snows = 500; 
    str = getParameter("threadsleep");
    if (str == null) {
      this.threadSleep = 80;
    } else {
      this.threadSleep = Integer.valueOf(str).intValue();
    } 
    if (this.threadSleep < 10) {
      this.threadSleep = 10;
    } else if (this.threadSleep > 1000) {
      this.threadSleep = 1000;
    } 
    this.snowX = new int[this.snows];
    this.snowY = new int[this.snows];
    for (byte b = 0; b < this.snows; b++) {
      this.snowX[b] = this.rand.nextInt() % this.dim.width / 2 + 
        this.dim.width / 2;
      this.snowY[b] = this.rand.nextInt() % this.dim.height / 2 + 
        this.dim.height / 2;
    } 
    str = getParameter("graphic");
    if (str == null) {
      str = getParameter("graph");
      if (str == null) {
        str = getParameter("grph");
        if (str == null)
          str = "tento1.gif"; 
      } 
    } 
    this.mt = new MediaTracker(this);
    this.gAlc = new Image[1];
    this.gAlc[0] = getImage(getDocumentBase(), str);
    this.mt.addImage(this.gAlc[0], 0);
    try {
      this.mt.waitForID(0);
    } catch (InterruptedException interruptedException) {
      return;
    } 
    this.stopFlag = 0;
  }
  
  public void start() {
    if (this.mainThread == null) {
      this.mainThread = new Thread(this);
      this.mainThread.start();
    } 
  }
  
  public void stop() {
    this.mainThread = null;
  }
  
  public void run() {
    while (this.mainThread != null) {
      try {
        Thread.sleep(this.threadSleep);
      } catch (InterruptedException interruptedException) {
        return;
      } 
      repaint();
    } 
  }
  
  public void paint(Graphics paramGraphics) {
    this.offGrph.setColor(Color.black);
    this.offGrph.fillRect(0, 0, this.dim.width, this.dim.height);
    this.offGrph.drawImage(this.gAlc[0], 0, 0, this);
    drawBackSnow();
    paramGraphics.drawImage(this.offScrn, 0, 0, null);
  }
  
  public void update(Graphics paramGraphics) {
    paint(paramGraphics);
  }
  
  public void drawBackSnow() {
    this.offGrph.setColor(Color.white);
    for (byte b = 0; b < this.snows; b++) {
      this.offGrph.fillRect(this.snowX[b], this.snowY[b], 1, 1);
      this.snowX[b] = this.snowX[b] + this.rand.nextInt() % 2 + this.wind;
      this.snowY[b] = this.snowY[b] + (this.rand.nextInt() % 6 + 5) / 5 + 1;
      if (this.snowX[b] >= this.dim.width)
        this.snowX[b] = 0; 
      if (this.snowX[b] < 0)
        this.snowX[b] = this.dim.width - 1; 
      if (this.snowY[b] >= this.dim.height || 
        this.snowY[b] < 0) {
        this.snowX[b] = Math.abs(this.rand.nextInt() % this.dim.width);
        this.snowY[b] = 0;
      } 
    } 
    switch (this.rand.nextInt() % 100) {
      case -2:
        this.wind = -2;
        return;
      case -1:
        this.wind = -1;
        return;
      case 0:
        this.wind = 0;
        return;
      case 1:
        this.wind = 1;
        return;
      case 2:
        this.wind = 2;
        return;
    } 
  }
}