home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / VCSAMPL.BIN / Developer.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-09-08  |  3.1 KB  |  97 lines

  1. import java.applet.Applet;
  2. import java.awt.Container;
  3. import java.awt.Label;
  4. import java.awt.LayoutManager;
  5. import java.awt.TextField;
  6.  
  7. public class Developer extends Applet implements Runnable {
  8.    Mediator myMediator;
  9.    String label;
  10.    String response;
  11.    int theNumber;
  12.    Thread developerThread;
  13.    Label top;
  14.    Label developer;
  15.    TextField developerTalk;
  16.    Label client;
  17.    TextField clientTalk;
  18.  
  19.    public void init() {
  20.       this.myMediator = new Mediator();
  21.       ((Container)this).setLayout((LayoutManager)null);
  22.       ((Applet)this).resize(452, 110);
  23.       this.top = new Label("I'm a Developer");
  24.       this.top.reshape(0, 0, 113, 24);
  25.       ((Container)this).add(this.top);
  26.       this.developer = new Label("Developer says:");
  27.       this.developer.reshape(0, 35, 109, 24);
  28.       ((Container)this).add(this.developer);
  29.       this.developerTalk = new TextField(18);
  30.       this.developerTalk.setEditable(false);
  31.       this.developerTalk.reshape(130, 36, 307, 24);
  32.       ((Container)this).add(this.developerTalk);
  33.       this.client = new Label("The Client just said:");
  34.       this.client.reshape(0, 70, 126, 24);
  35.       ((Container)this).add(this.client);
  36.       this.clientTalk = new TextField(18);
  37.       this.clientTalk.setEditable(false);
  38.       this.clientTalk.reshape(130, 68, 309, 24);
  39.       ((Container)this).add(this.clientTalk);
  40.    }
  41.  
  42.    public void start() {
  43.       this.developerThread = new Thread(this);
  44.       this.developerThread.start();
  45.    }
  46.  
  47.    public void run() {
  48.       Thread developerThread = Thread.currentThread();
  49.  
  50.       while(true) {
  51.          try {
  52.             Thread.sleep(2000L);
  53.          } catch (Exception e) {
  54.             System.out.println(e);
  55.          }
  56.  
  57.          Mediator.oldNumber = Mediator.theNumber;
  58.          Mediator.theNumber = this.myMediator.genRandom();
  59.          this.checkWithMediator();
  60.          this.takeAction();
  61.       }
  62.    }
  63.  
  64.    public synchronized void checkWithMediator() {
  65.       int index = Mediator.theNumber;
  66.       if (index < 10) {
  67.          this.label = "Have you seen Visual Caf├⌐?";
  68.       } else if (index <= 20 && index >= 10) {
  69.          this.label = "What's that?";
  70.       } else if (index <= 30 && index > 20) {
  71.          this.label = "Visual Caf├⌐ is Great!";
  72.       } else if (index <= 40 && index > 30) {
  73.          this.label = "Visual Caf├⌐ really helps.";
  74.       } else if (index <= 50 && index > 40) {
  75.          this.label = "I can make anything with Visual Caf├⌐.";
  76.       } else if (index <= 60 && index > 50) {
  77.          this.label = "The Visual Caf├⌐ compiler is sooo FAST!";
  78.       } else if (index <= 70 && index > 60) {
  79.          this.label = "Debugging in Visual Caf├⌐ is easy.";
  80.       } else if (index <= 80 && index > 70) {
  81.          this.label = "I see where you're going";
  82.       } else if (index <= 90 && index > 80) {
  83.          this.label = "Check out the snazzy class editor.";
  84.       } else if (index <= 100 && index > 90) {
  85.          this.label = "Thank you!";
  86.       }
  87.  
  88.       this.myMediator.setDeveloperTalk(this.label);
  89.       this.response = this.myMediator.getClientTalk();
  90.    }
  91.  
  92.    public void takeAction() {
  93.       this.developerTalk.setText(this.label);
  94.       this.clientTalk.setText(this.response);
  95.    }
  96. }
  97.