home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / unuy2wen / cybcerone / manif / fac.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  2.1 KB  |  101 lines

  1. // Fac.java
  2. // 15.03.96
  3. //
  4. // The faculte field in a manifestation
  5.  
  6. package cybcerone.manif;
  7.  
  8. import cybcerone.utils.Manif;
  9.  
  10. /** 
  11.  * Manif's (events) are sponsored by one of these faculties.
  12.  */
  13. class Fac {
  14.   static final int ALL       = 0;
  15.   static final int THEOLOGIE = 1;
  16.   static final int DROIT     = 2;
  17.   static final int LETTRES   = 3;
  18.   static final int SSP       = 4;
  19.   static final int HEC       = 5;
  20.   static final int SCIENCES  = 6;
  21.   static final int MEDECINE  = 7;
  22.   static final int SERVICES  = 8;
  23.   static final int AUTRES    = 9;
  24.  
  25.   private int code;
  26.  
  27.   Fac (int code) {
  28.     this.code = code;
  29.   }
  30.  
  31.   Fac (String facName) {
  32.     this (decode (facName));
  33.   }
  34.  
  35.   public int getFac () { return code; }
  36.  
  37.   private static int decode (String facName) {
  38.     facName = facName.toUpperCase ();
  39.  
  40.     if (facName.startsWith ("THE")) return (1);
  41.     else if (facName.startsWith ("DRO")) return (2);
  42.     else if (facName.startsWith ("LET")) return (3);
  43.     else if (facName.startsWith ("S.S")) return (4);
  44.     else if (facName.startsWith ("H.E")) return (5);
  45.     else if (facName.startsWith ("SCI")) return (6);
  46.     else if (facName.startsWith ("MED")) return (7);
  47.     else if (facName.startsWith ("SER")) return (8);
  48.     else if (facName.startsWith ("AUT")) return (9);
  49.     else return (0);
  50.   }
  51.  
  52.   /** returns true if this fac includes this manifestation */
  53.   boolean includes (Manif theManif) {
  54.     if (code == ALL)
  55.       return true;
  56.     else
  57.       return (code == decode (theManif.getFaculte ()));
  58.   }
  59.  
  60.   public String toString () {
  61.     String theCode;
  62.  
  63.     switch (code) {
  64.     case 0:
  65.       theCode = "ALL";
  66.       break;
  67.     case 1:
  68.       theCode = "THE";
  69.       break;
  70.     case 2:
  71.       theCode = "DRO";
  72.       break;
  73.     case 3:
  74.       theCode = "LET";
  75.       break;
  76.     case 4:
  77.       theCode = "SSP";
  78.       break;
  79.     case 5:
  80.       theCode = "HEC";
  81.       break;
  82.     case 6:
  83.       theCode = "SCI";
  84.       break;
  85.     case 7:
  86.       theCode = "MED";
  87.       break;
  88.     case 8:
  89.       theCode = "SER";
  90.       break;
  91.     case 9:
  92.       theCode = "AUT";
  93.       break;
  94.     default:
  95.       theCode = "UNKNOWN";
  96.     }
  97.  
  98.     return ("Fac[" + theCode + "]");
  99.   }
  100. }
  101.