home *** CD-ROM | disk | FTP | other *** search
- /*
- * Title: Conversing Applets
- * Type: Applet
- * Source: Mediator.java
- * Application Description:
- * The Conversing Applets project provides a simple and effective way
- * to allow applets to communicate within the same "environment", i.e.
- * within the same browser page.
- *
- * This is done using a Mediator class as the background manager and
- * other visible classes which display results. The Mediator class uses
- * static variables to keep track of all the events taking place in
- * these visible applets.
- *
- * In this example, two visible applets are used along with the one
- * Mediator class. The Developer and Client class generate text strings which
- * represent conversation. The Mediator object(s) take those text
- * strings and distribute them to the other applet (Developer to Client and
- * Client to Developer).
- *
- * The result is two distinct applet objects transmitting data back and
- * forth. This sort of project can be very useful in developing more
- * interesting Web pages as well as Web page applets which gather
- * information about usage, etc. The Mediator class concept can be
- * built upon to meet the needs of more specific Java-based Web
- * applications.
- */
-
- /**
- * The main Mediator class
- */
-
- class Mediator
- {
- //Random number indices
- public static int theNumber;
- public static int oldNumber;
-
- //The information is distributed via these static Strings
- public static String developerTalk;
- public static String clientTalk;
-
- /**
- * Generate a random number
- */
-
- public int genRandom()
- {
- int temp = (int)(Math.random() * 100);
- return temp;
- }
-
- /**
- * Returns the statement of the developer
- */
-
- public String getDeveloperTalk()
- {
- return developerTalk;
- }
-
- /**
- * Sets the statement of the developer
- */
-
- public void setDeveloperTalk(String s)
- {
- developerTalk = s;
- }
-
- /**
- * Returns the statement of the client
- */
-
- public String getClientTalk()
- {
- return clientTalk;
- }
-
- /**
- * Sets the statement of the client
- */
-
- public void setClientTalk(String s)
- {
- clientTalk = s;
- }
- }
-