home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / enxle1f6 / src / games / battle / shared / comm / whoinfo.java < prev   
Encoding:
Java Source  |  1996-08-14  |  1.5 KB  |  74 lines

  1. /*
  2.  * @(#)WhoInfo.java
  3.  */
  4.  
  5. package games.Battle.shared.comm;
  6.  
  7. import games.Rating.Rating;
  8.  
  9. import java.io.*;
  10. import java.util.*;
  11.  
  12. /**
  13.  * WhoInfo is a specialized PlayerInfo packet that avoids setting the 
  14.  * password. It provides a convenient way to tell each player about other
  15.  * players without compromising the security of the passwords. 
  16.  *
  17.  * @version 1.00
  18.  * @author  Alex Nicolaou
  19.  * @author  Jay Steele
  20.  */
  21.  
  22. public class WhoInfo extends PlayerInfo
  23. {
  24.     /**
  25.      * Constructs a WhoInfo packet from a PlayerInfo packet, stripping 
  26.      * the password in the process.
  27.      * @param p is the player info packet.
  28.      */
  29.     public WhoInfo(PlayerInfo p) {
  30.         this.handle = p.handle; 
  31.         this.name = p.name;
  32.         this.mail = p.mail;
  33.         this.pass = new String("");
  34.         this.wizard = p.wizard;
  35.         this.rating = p.rating;
  36.     }
  37.  
  38.     /**
  39.      * Constructs an empty packet  ready to be read in from an inputstream.
  40.      */
  41.     public WhoInfo() {
  42.     }
  43.  
  44.     /**
  45.      * Resets the info in the who packet based on the PlayerInfo packet.
  46.      */
  47.     public void setInfo(PlayerInfo p) {
  48.         this.handle = p.handle; 
  49.         this.name = p.name;
  50.         this.mail = p.mail;
  51.         this.pass = new String("");
  52.         this.wizard = p.wizard;
  53.         this.rating = p.rating;
  54.     }
  55.  
  56.     /**
  57.      * Return a string suitable for display to the end user.
  58.      */
  59.     public String toString() {
  60.         String s;
  61.         s = handle;
  62.         if (wizard)
  63.             s = s + " !\t";
  64.         else
  65.             s = s + "  \t";
  66.         if (handle.length() < 7)
  67.             s = s + "\t";
  68.         s = s + rating + "\t" + name;
  69.         if (mail.length() > 1)
  70.             s = s + " (" + mail + ")";
  71.         return s;
  72.     }
  73. }
  74.