コード例 #1
0
ファイル: GeneralTest.java プロジェクト: pawelpaszki/ppaszki
 /** addQualifications test */
 @Test
 public void testAddQualification() {
   assertEquals(doctor1.getQualifications().size(), 0);
   doctor1.getQualifications().add(qualification1);
   assertEquals(doctor1.getQualifications().size(), 1);
   doctor1.getQualifications().add(qualification2);
   assertEquals(doctor1.getQualifications().size(), 2);
 }
コード例 #2
0
ファイル: ESTCaller.java プロジェクト: mrsiva26/TTES
  /**
   * An equivalent to the make_pm_wave shell script
   *
   * @param db The layout of the processed database
   * @param baseNameArray The array of basenames of the .wav files to process
   */
  public void make_pm_wave(String[] baseNameArray, String pitchmarksDirName, String pitchmarksExt) {

    System.out.println("---- Calculating the pitchmarks...");

    String cmdLine = null;

    /* For each file (or each basename): */
    for (int i = 0; i < baseNameArray.length; i++) {

      /* Make the command lines and launch them */
      /* - Scaling + resampling: */
      cmdLine =
          ESTDIR
              + "/bin/ch_wave -scaleN 0.9 -F 16000 "
              + "-o tmp"
              + baseNameArray[i]
              + db.getProp(db.WAVEXT)
              + " "
              + db.getProp(db.WAVDIR)
              + baseNameArray[i]
              + db.getProp(db.WAVEXT);
      General.launchProc(cmdLine, "Pitchmarks ", baseNameArray[i]);

      /* Ensure the existence of the target pitchmark directory */
      File dir = new File(pitchmarksDirName);
      if (!dir.exists()) {
        System.out.println("Creating the directory [" + pitchmarksDirName + "].");
        dir.mkdir();
      }

      /* - Pitchmarks extraction: */
      cmdLine =
          ESTDIR
              + "/bin/pitchmark -min 0.0057 -max 0.012 -def 0.01 -wave_end -lx_lf 140 -lx_lo 111 -lx_hf 80 -lx_ho 51 -med_o 0 -fill -otype est "
              + "-o "
              + pitchmarksDirName
              + baseNameArray[i]
              + pitchmarksExt
              + " tmp"
              + baseNameArray[i]
              + db.getProp(db.WAVEXT);
      General.launchProc(cmdLine, "Pitchmarks ", baseNameArray[i]);

      /* - Cleanup the temporary file: */
      cmdLine = "rm -f tmp" + baseNameArray[i] + db.getProp(db.WAVEXT);
      General.launchProc(cmdLine, "Pitchmarks ", baseNameArray[i]);
    }
    System.out.println("---- Pitchmarks done.");
  }
コード例 #3
0
ファイル: Initialisation.java プロジェクト: Kedzio/Shitenno
  /* Constructors */
  public Initialisation() {
    // Lecture des fichiers XML grâce à JDom
    this.hashBonus = new JDom("src/fichierxml/Bonus.xml").initialisationJeu("bonus");
    this.hashGeneral = new JDom("src/fichierxml/General.xml").initialisationJeu("general");
    this.hashKokus = new JDom("src/fichierxml/Kokus.xml").initialisationJeu("kokus");
    this.hashProvince = new JDom("src/fichierxml/Province.xml").initialisationJeu("province");
    this.hashTitre = new JDom("src/fichierxml/Titre.xml").initialisationJeu("titre");
    this.hashTroupes = new JDom("src/fichierxml/Troupes.xml").initialisationJeu("troupes");

    // Affichage des résultats d'initialisation
    System.out.println("*** Les généraux ***");
    for (General g : this.hashGeneral) {
      System.out.println(g.toString());
    }

    System.out.println("\n*** Les Titres ***");
    for (Titre t : this.hashTitre) {
      System.out.println(t.toString());
    }

    System.out.println("\n*** Le paquet Troupes (mélangé) ***");
    this.llctroupe = initialisationPaquetTroupe();
    for (CarteTroupe ct : this.llctroupe) {
      System.out.println(ct.toString());
    }

    System.out.println("\n*** Le paquet Kokus (mélangé) ***");
    this.llkokus = initialisationPaquetKokus();
    for (Kokus k : this.llkokus) {
      System.out.println(k.toString());
    }

    System.out.println("\n*** Les Tuiles Bonus (mélangées) ***");
    this.lltbonus = initialisationTuileBonus();
    for (TuileBonus tb : this.lltbonus) {
      System.out.println(tb.toString());
    }

    System.out.println("\n*** Les Provinces ***");
    initialisationFinaleProvince();
    ajoutTroisTuileBonus(hashProvince, lltbonus);
    for (Province p : this.hashProvince) {
      System.out.println("\n" + p.toString());
      for (TuileBonus tb : p.getLltuilebonus()) {
        System.out.println(tb.toString());
      }
    }
  }
コード例 #4
0
ファイル: Dedicated.java プロジェクト: dutchcoin/topguw
  // TODO : delete
  public static ArrayList<String[]> findSysInfo(ArrayList<String[]> enTableau) {
    ArrayList<String[]> lesSi = new ArrayList<String[]>();
    String tempFn = "";

    /*
     * INDEX 0 : FRAME NUMBER
     * INDEX 1 : FRAME NUMBER MODULO 102
     */
    for (int i = 0; i < enTableau.size(); i++) {
      String[] temp = new String[2];
      // Si fn % 102 == 32,47 -> on ajoute
      if (enTableau.get(i).length > 2
          && General.isInteger(enTableau.get(i)[1])
          && (Integer.parseInt(enTableau.get(i)[1]) % 102 >= 32
              && Integer.parseInt(enTableau.get(i)[1]) % 102 <= 47)
          && !(tempFn.equals(enTableau.get(i)[1]))) {
        tempFn = enTableau.get(i)[1];
        temp[0] = enTableau.get(i)[1];
        if (Integer.parseInt(enTableau.get(i)[1]) % 102 == 35
            || Integer.parseInt(enTableau.get(i)[1]) % 102 == 39
            || Integer.parseInt(enTableau.get(i)[1]) % 102 == 43
            || Integer.parseInt(enTableau.get(i)[1]) % 102 == 47) {
          temp[1] =
              String.valueOf(Integer.parseInt(enTableau.get(i)[1]) % 102) + "\nFound end of frame";
        } else {
          temp[1] = String.valueOf(Integer.parseInt(enTableau.get(i)[1]) % 102);
        }

        lesSi.add(temp);
      }
    }
    return lesSi;
  }
コード例 #5
0
ファイル: Dedicated.java プロジェクト: dutchcoin/topguw
  /**
   * Search for potential SI position after a ciphering mode command
   *
   * @return potential position
   */
  public static ArrayList<String[]> getEncryptedSi() throws Exception {

    int localDedicatedChannelFn = 0;

    ArrayList<String[]> cipheredSi = new ArrayList<>();

    if (systemInfo == null || cipherModCommand == null) {
      throw new Exception(
          START_LINE
              + "Error : you have to find SI cleartext and Ciphering Mode Command position before.\n");
    } else {
      for (int i = 0; i < systemInfo.size(); i++) {
        for (int j = 0; j < dedicatedChannelTab.size(); j++) {

          if (dedicatedChannelTab.get(j).length
                  == 4 // check the frame is correct (not an error or other thing)
              && General.isInteger(dedicatedChannelTab.get(j)[1])
              // current frame is not an unecrypted SI 5
              && Integer.parseInt(dedicatedChannelTab.get(j)[1])
                  != Integer.parseInt(systemInfo.get(i)[0])
              // if frames(unencrypted and possible encrypted) are in the same place in the multi
              // frame
              && ((Integer.parseInt(dedicatedChannelTab.get(j)[1])
                          - Integer.parseInt(systemInfo.get(i)[0]))
                      % 204
                  == 0)) {

            for (int a = 0; a < cipherModCommand.size(); a++) {
              // the frame is after a ciphering mod command
              if (localDedicatedChannelFn != Integer.parseInt(dedicatedChannelTab.get(j)[1])
                  // the frame is encrypted
                  && isParityErr(dedicatedChannelTab.get(j)[1])) {
                System.out.println("one found");
                String[] temp = new String[4];
                /*
                 * ind 0 : SI plaintext Frame Number
                 * ind 1 : SI plaintext Frame Number % 102
                 * ind 2 : SI Ciphered possible position
                 * ind 3 : SI Ciphered possible position % 102 -
                 */

                localDedicatedChannelFn = Integer.parseInt(dedicatedChannelTab.get(j)[1]);
                temp[0] = systemInfo.get(i)[0];
                temp[1] =
                    "fn[" + Integer.toString(Integer.parseInt(systemInfo.get(i)[0]) % 102) + "]";
                temp[2] = dedicatedChannelTab.get(j)[1];
                temp[3] =
                    "fn["
                        + Integer.toString(Integer.parseInt(dedicatedChannelTab.get(j)[1]) % 102)
                        + "]";
                cipheredSi.add(temp);
              }
            }
          }
        }
      }
    }

    return cipheredSi;
  }
コード例 #6
0
 // 计算并返回将领应该增加的体力,基本算法就是体力越低,回复越快,等级越高,恢复越慢,但暂时先不这样
 public static int getGeneralStrengthIncrement(General general) {
   // int level = general.getLevel();//获得将军等级
   int strength = general.getStrength(); // 获得将军体力
   int increment = BASIC_STRENGTH_INCREMENT; // 计算出增量
   if (strength + increment > general.maxStrength) { // 如果不用加那么多就已经完全恢复
     increment = general.maxStrength - strength;
   }
   return increment;
 }
コード例 #7
0
 public boolean updateState(Landscape scape) {
   while (this.country.getWealth() > 0) {
     // hire generals
     for (Object c : this.country.CityToList()) {
       // if city has not already hired generals:
       if (!((City) c).ALREADY_HIRED_GENERAL)
         new General(
             ((City) c).getX(),
             ((City) c).getY(),
             "Nomen" + SimObject.rand.nextInt(60),
             this.country);
       ((City) c).ALREADY_HIRED_GENERAL = true;
     }
     // "enrich" generals with soldiers
     for (Object g : this.country.GeneralToList()) {
       ((General) g)
           .addSoldiers(Soldiers.ALL_UNITS.get(SimObject.rand.nextInt(Soldiers.ALL_UNITS.size())));
       // if general hasnt moved yet
       if (((General) g).size() >= 19 && !((General) g).HAS_MOVED) {
         // select a random enemy city as enemy:
         int selection = SimObject.rand.nextInt(2);
         City c =
             (City)
                 this.enemy[selection]
                     .CityToList()
                     .get(SimObject.rand.nextInt(this.enemy[selection].CityToList().size()));
         ((General) g).setEnemy(c);
         ((General) g).destino_x = c.x;
         ((General) g).destino_y = c.y;
         // make general move to location
         // while((int)((General)g).x!=(int)(((General)g).destino_x) &&
         // (int)((General)g).y!=(int)(((General)g).destino_y)){
         // ((General)g).moveToDestination();
         // }
         new Running.GeneralToLocation((General) g);
       }
     }
     break; // TODO:break out of the while loop?
   }
   Running.windows.repaint();
   return (this.isAlive && !(this.defeat) && this.country.isAlive);
 }
コード例 #8
0
  private boolean isPlayer(Entity entity) {
    boolean result = false;

    if (General.getPlayer(entity.getEntityId()) != null) {
      result = true;
    } else {
      result = false;
    }

    return result;
  }
コード例 #9
0
 public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
   if (event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK) {
     if ((isPlayer(event.getEntity())) && (isPlayer(event.getDamager()))) {
       PolygoniaPlayer ezp = General.getPlayer(event.getEntity().getEntityId());
       Polygonia zone = ezp.getCurrentZone();
       if (zone != null) {
         if (!zone.hasPVP()) {
           event.setCancelled(true);
         }
       }
     }
   }
 }
コード例 #10
0
ファイル: GeneralTest.java プロジェクト: pawelpaszki/ppaszki
 /** toString test */
 @Test
 public void testToString() {
   assertEquals(
       doctor1.toString(),
       "\nDoctor's full name: Bobby Bob"
           + "\nDate of Birth: 1960/6/10"
           + "\nGender: male"
           + "\nAddress: The Quay, Waterford"
           + "\nContact Number: 12345678"
           + "\nQualified in Ireland: true"
           + "\n\nQualifications: \n"
           + "\nComplaints:\n"
           + "No Complaints have been recorded");
 }
コード例 #11
0
ファイル: GeneralTest.java プロジェクト: pawelpaszki/ppaszki
 /** get, setComplaints, getComplaintsCounrt test */
 @Test
 public void testGetAndSetComplaintsAndComplaintsCount() {
   assertEquals(doctor1.getComplaints().size(), 0);
   doctor1.getComplaints().add(complaint1);
   assertEquals(doctor1.getComplaints().size(), 1);
   doctor1.getComplaints().add(complaint2);
   assertEquals(doctor1.getComplaints().size(), 2);
   assertEquals(doctor1.getComplaintsCount(), 2);
 }
コード例 #12
0
ファイル: ESTCaller.java プロジェクト: mrsiva26/TTES
  /**
   * An equivalent to the make_mcep shell script
   *
   * @param db The layout of the processed database
   * @param baseNameArray The array of basenames of the .wav files to process
   */
  public void make_mcep(
      String[] baseNameArray,
      String correctedPitchmarksDirName,
      String correctedPitchmarksExt,
      String mcepDirName,
      String mcepExt) {

    System.out.println("---- Calculating the Mel-Cepstrum coefficents...");

    String cmdLine = null;

    /* For each file (or each basename): */
    for (int i = 0; i < baseNameArray.length; i++) {

      /* Ensure the existence of the target mel cepstrum directory */
      File dir = new File(mcepDirName);
      if (!dir.exists()) {
        System.out.println("Creating the directory [" + mcepDirName + "].");
        dir.mkdir();
      }

      /* Make the command line */
      cmdLine =
          ESTDIR
              + "/bin/sig2fv "
              + "-window_type hamming -factor 2.5 -otype est_binary -coefs melcep -melcep_order 12 -fbank_order 24 -shift 0.01 -preemph 0.97 "
              + "-pm "
              + correctedPitchmarksDirName
              + baseNameArray[i]
              + correctedPitchmarksExt
              + " -o "
              + mcepDirName
              + baseNameArray[i]
              + mcepExt
              + " "
              + db.getProp(db.WAVDIR)
              + baseNameArray[i]
              + db.getProp(db.WAVEXT);
      // System.out.println( cmdLine );
      /* Note: parameter "-delta melcep" has been commented out in the original script.
       * Refer to the EST docs on http://www.cstr.ed.ac.uk/projects/speech_tools/manual-1.2.0/
       * for the meaning of the command line parameters. */

      /* Launch the relevant process */
      System.out.println(baseNameArray[i]); // some feedback is always nice
      General.launchProc(cmdLine, "Mel-Cepstrum ", baseNameArray[i]);
    }
    System.out.println("---- Mel-Cepstrum coefficients done.");
  }
コード例 #13
0
ファイル: ESTCaller.java プロジェクト: mrsiva26/TTES
  /**
   * An equivalent to the make_lpc shell script
   *
   * @param db The layout of the processed database
   * @param baseNameArray The array of basenames of the .wav files to process
   */
  public void make_lpc(
      String[] baseNameArray,
      String correctedPitchmarksDirName,
      String correctedPitchmarksExt,
      String lpcDirName,
      String lpcExt) {

    System.out.println("---- Calculating the LPC coefficents...");

    String cmdLine = null;

    /* For each file (or each basename): */
    for (int i = 0; i < baseNameArray.length; i++) {

      /* Ensure the existence of the target directory */
      File dir = new File(lpcDirName);
      if (!dir.exists()) {
        System.out.println("Creating the directory [" + lpcDirName + "].");
        dir.mkdir();
      }

      /* Make the command line */
      cmdLine =
          ESTDIR
              + "/bin/sig2fv "
              + "-window_type hamming -factor 3 -otype est_binary -preemph 0.95 -coefs lpc -lpc_order 16 "
              + "-pm "
              + correctedPitchmarksDirName
              + baseNameArray[i]
              + correctedPitchmarksExt
              + " -o "
              + lpcDirName
              + baseNameArray[i]
              + lpcExt
              + " "
              + db.getProp(db.WAVDIR)
              + baseNameArray[i]
              + db.getProp(db.WAVEXT);
      // System.out.println( cmdLine );

      /* Launch the relevant process */
      General.launchProc(cmdLine, "LPC ", baseNameArray[i]);
    }
    System.out.println("---- LPC coefficients done.");
  }
コード例 #14
0
ファイル: Dedicated.java プロジェクト: dutchcoin/topguw
  /**
   * Check if a frame number is linked to a parity error (cannot decode)
   *
   * @param fn the frame number
   * @return true if the frame seems unable to be decoded by airprobe
   */
  public static boolean isParityErr(String fn) {

    // read dedicated channel (xS) line by line
    ArrayList<String> temp = General.readFile(file.getAbsolutePath() + "_" + timeslot + "S");

    // and check if e found a parity error linked to the fn
    for (int i = 0; i < temp.size(); i++) {
      if (General.RGX_PARITY.matcher(temp.get(i)).matches()) {
        Matcher recup_err = General.RGX_PARITY.matcher(temp.get(i));
        if (recup_err.find()) {
          if (recup_err.group(1).equals(fn)) ;
          return true;
        }
      }
    }

    return false;
  }
コード例 #15
0
ファイル: ExtraArrays.java プロジェクト: UnderMybrella/Omnis
 @SuppressWarnings("unchecked")
 public static <T> T[][] deepCopyOf(T[][] array, Class<? extends T> clazz) {
   int secondLength = 0;
   for (T[] layer : array) if (layer.length > secondLength) secondLength = layer.length;
   T[][] copy = (T[][]) Array.newInstance(clazz, array.length, secondLength);
   for (int i = 0; i < array.length; i++) {
     T[] copyArray = (T[]) Array.newInstance(clazz, secondLength);
     for (int j = 0; j < copyArray.length; j++) {
       T obj = null;
       if (array[i][j] instanceof Cloneable) obj = General.unsafeClone(array[i][j]);
       else if (array[i][j] instanceof String) obj = array[i][j];
       else if (clazz.isPrimitive()) obj = array[i][j];
       copyArray[j] = obj;
     }
     copy[i] = copyArray;
   }
   return copy;
 }
コード例 #16
0
  private void revertToWeb() {

    final Runnable r =
        new Runnable() {
          public void run() {
            if (!mHaveReverted) {
              mHaveReverted = true;
              LinkHandler.onLinkClicked(AlbumListingActivity.this, mUrl, true);
              finish();
            }
          }
        };

    if (General.isThisUIThread()) {
      r.run();
    } else {
      AndroidApi.UI_THREAD_HANDLER.post(r);
    }
  }
コード例 #17
0
ファイル: Dedicated.java プロジェクト: dutchcoin/topguw
  /**
   * Get Bursts from a frame number
   *
   * @param fn the frame number
   * @return an array with at least one burst from the frame number (if other bursts are missing in
   *     the dump), else 4 bursts are returned ind 0 first burst from the frame ind 1 a5/1 fn from
   *     the bursts ind 2 second burst from the frame ind 3 a5/1 fn from the bursts ... etc
   */
  public static String[] getBurstsFromFn(String fn) {

    String[] bursts = new String[8];
    for (int i = 0; i < 8; i++) bursts[i] = "no exist";

    int integerFn = Integer.parseInt(fn);
    boolean finish = false;

    for (int i = 0; finish == false && i < dedicatedChannelTab.size(); i++) {
      String[] line = dedicatedChannelTab.get(i);
      // check element from array is a frame burst
      if (line.length == 4
          && line[0].length() == 2
          && General.isInteger(line[1])
          && (Integer.parseInt(line[1]) <= 2715647 || Integer.parseInt(line[1]) > 0)
          && line[0].charAt(0) == 'C') {
        if (Integer.parseInt(line[1]) == integerFn - 3) {
          // add the burst
          bursts[0] = line[3];
          // add a5/1 fn
          bursts[4] = line[2].substring(0, line[2].length() - 1);
        } else if (Integer.parseInt(line[1]) == integerFn - 2) {
          bursts[1] = line[3];
          bursts[5] = line[2].substring(0, line[2].length() - 1);
        } else if (Integer.parseInt(line[1]) == integerFn - 1) {
          bursts[2] = line[3];
          bursts[6] = line[2].substring(0, line[2].length() - 1);
        } else if (Integer.parseInt(line[1]) == integerFn) {
          bursts[3] = line[3];
          bursts[7] = line[2].substring(0, line[2].length() - 1);
          finish = true;
        } else {
          // DO NOTHING
        }
      }
    }
    return bursts;
  }
コード例 #18
0
 /** Shows description of every commander type. */
 private void showCommanderHelp() {
   System.out.println(Priest.getDescription());
   System.out.println(General.getDescription());
   System.out.println(Berserker.getDescription());
 }
コード例 #19
0
ファイル: GeneralTest.java プロジェクト: pawelpaszki/ppaszki
  /** getters and setters test */
  @Test
  public void testSettersAndGetters() {
    // valid name
    assertEquals(doctor1.getName(), "Bobby Bob");
    doctor1.setName("New valid name");
    assertNotEquals(doctor1.getName(), "Bobby Bob");
    assertEquals(doctor1.getName(), "New valid name");

    // invalid name
    assertEquals(invalidDoctor.getName(), "!birth cert needed !");
    invalidDoctor.setName("AB");
    assertNotEquals(invalidDoctor.getName(), "AB");
    assertEquals(invalidDoctor.getName(), "!birth cert needed !");

    assertEquals(anotherInvalidDoctor.getName(), "This is way too long");
    anotherInvalidDoctor.setName("New tooooooooooo long name");
    assertNotEquals(anotherInvalidDoctor.getName(), "New tooooooooooo long name");
    assertEquals(anotherInvalidDoctor.getName(), "This is way too long");

    // valid dateOfBirth
    assertEquals(doctor1.dateOfBirth.get(GregorianCalendar.YEAR), 1960);
    assertEquals(doctor1.dateOfBirth.get(GregorianCalendar.MONTH), 5);
    assertEquals(doctor1.dateOfBirth.get(GregorianCalendar.DAY_OF_MONTH), 10);
    doctor1.setDateOfBirth(1950, 10, 15);
    assertEquals(doctor1.dateOfBirth.get(GregorianCalendar.YEAR), 1950);
    assertEquals(doctor1.dateOfBirth.get(GregorianCalendar.MONTH), 9);
    assertEquals(doctor1.dateOfBirth.get(GregorianCalendar.DAY_OF_MONTH), 15);
    assertNotEquals(doctor1.dateOfBirth.get(GregorianCalendar.YEAR), 1960);
    assertNotEquals(doctor1.dateOfBirth.get(GregorianCalendar.MONTH), 5);
    assertNotEquals(doctor1.dateOfBirth.get(GregorianCalendar.DAY_OF_MONTH), 10);

    // invalid dateOfBirth
    assertEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.YEAR), 1915);
    assertEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.MONTH), 11);
    assertEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.DAY_OF_MONTH), 31);
    invalidDoctor.setDateOfBirth(1900, 10, 15);
    assertNotEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.YEAR), 1900);
    assertNotEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.MONTH), 9);
    assertNotEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.DAY_OF_MONTH), 15);
    assertEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.YEAR), 1915);
    assertEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.MONTH), 11);
    assertEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.DAY_OF_MONTH), 31);

    // valid gender
    assertEquals(doctor1.getGender(), "male");
    doctor1.setGender("female");
    assertNotEquals(doctor1.getGender(), "male");
    assertEquals(doctor1.getGender(), "female");

    // invalid gender
    assertEquals(invalidDoctor.getGender(), "male");
    invalidDoctor.setGender("unknown");
    assertNotEquals(invalidDoctor.getGender(), "unknown");
    assertEquals(invalidDoctor.getGender(), "male");

    // valid address
    assertEquals(doctor1.getAddress(), "The Quay, Waterford");
    doctor1.setAddress("The Quay, Wexford");
    assertNotEquals(doctor1.getAddress(), "The Quay, Waterford");
    assertEquals(doctor1.getAddress(), "The Quay, Wexford");

    // invalid address
    assertEquals(doctor1.getAddress(), "The Quay, Wexford");
    doctor1.setAddress("abc");
    assertNotEquals(doctor1.getAddress(), "abc");
    assertEquals(doctor1.getAddress(), "The Quay, Wexford");

    assertEquals(invalidDoctor.getAddress(), "to be confirmed");
    invalidDoctor.setAddress(
        "1234567890123456789012345678901234567890123456789012345678901234567890");
    assertNotEquals(
        invalidDoctor.getAddress(),
        "1234567890123456789012345678901234567890123456789012345678901234567890");
    assertEquals(invalidDoctor.getAddress(), "to be confirmed");

    // valid contactNumber
    assertEquals(doctor1.getContactNumber(), 12345678);
    doctor1.setContactNumber(123456789);
    assertNotEquals(doctor1.getContactNumber(), 12345678);
    assertEquals(doctor1.getContactNumber(), 123456789);

    // invalid contactNumber
    assertEquals(doctor1.getContactNumber(), 123456789);
    doctor1.setContactNumber(12345);
    assertNotEquals(doctor1.getContactNumber(), 12345);
    assertEquals(doctor1.getContactNumber(), 123456789);

    // qualifiedInIreland
    assertEquals(doctor1.isQualifiedInIreland(), true);
    doctor1.setQualifiedInIreland(false);
    assertNotEquals(doctor1.isQualifiedInIreland(), true);
    assertEquals(doctor1.isQualifiedInIreland(), false);

    assertEquals(invalidDoctor.isQualifiedInIreland(), false);
    invalidDoctor.setQualifiedInIreland(true);
    assertEquals(invalidDoctor.isQualifiedInIreland(), true);
    assertNotEquals(invalidDoctor.isQualifiedInIreland(), false);
  }
コード例 #20
0
ファイル: GeneralTest.java プロジェクト: pawelpaszki/ppaszki
 /** calculateRegistrationFee test */
 @Test
 public void testcalculateRegistrationFee() {
   assertEquals(doctor1.calculateRegistrationFee(), 194, 0.1);
   assertEquals(invalidDoctor.calculateRegistrationFee(), 410, 0.1);
 }
コード例 #21
0
ファイル: GeneralTest.java プロジェクト: pawelpaszki/ppaszki
 /** set and getQualifications test */
 @Test
 public void testSetAndGetQualifications() {
   assertEquals(doctor1.getQualifications().size(), 0);
   doctor1.setQualifications(newQualifications);
   assertEquals(doctor1.getQualifications().size(), 2);
 }
コード例 #22
0
 @Override
 public void onBackPressed() {
   if (General.onBackPressed()) super.onBackPressed();
 }
コード例 #23
0
ファイル: GeneralTest.java プロジェクト: pawelpaszki/ppaszki
  /** constuctor test */
  @Test
  public void testGeneralConstructor() {
    // valid name
    assertEquals(doctor1.getName(), "Bobby Bob");
    assertEquals(doctor1.dateOfBirth.get(GregorianCalendar.YEAR), 1960);
    assertEquals(doctor1.dateOfBirth.get(GregorianCalendar.MONTH), 5);
    assertEquals(doctor1.dateOfBirth.get(GregorianCalendar.DAY_OF_MONTH), 10);
    assertEquals(doctor1.getGender(), "male");
    assertEquals(doctor1.getAddress(), "The Quay, Waterford");
    assertEquals(doctor1.getContactNumber(), 12345678);
    assertEquals(doctor1.isQualifiedInIreland(), true);

    // invalid name
    assertEquals(invalidDoctor.getName(), "!birth cert needed !");
    assertEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.YEAR), 1915);
    assertEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.MONTH), 11);
    assertEquals(invalidDoctor.dateOfBirth.get(GregorianCalendar.DAY_OF_MONTH), 31);
    assertEquals(invalidDoctor.getGender(), "male");
    assertEquals(invalidDoctor.getAddress(), "to be confirmed");
    assertEquals(invalidDoctor.getContactNumber(), 999999999);
    assertEquals(invalidDoctor.isQualifiedInIreland(), false);

    assertEquals(anotherInvalidDoctor.getName(), "This is way too long");
    assertEquals(anotherInvalidDoctor.dateOfBirth.get(GregorianCalendar.YEAR), 1915);
    assertEquals(anotherInvalidDoctor.dateOfBirth.get(GregorianCalendar.MONTH), 11);
    assertEquals(anotherInvalidDoctor.dateOfBirth.get(GregorianCalendar.DAY_OF_MONTH), 31);
    assertEquals(anotherInvalidDoctor.getGender(), "male");
    assertEquals(
        anotherInvalidDoctor.getAddress(),
        "123456789012345678901234567890123456789012345678901234567890");
    assertEquals(anotherInvalidDoctor.getContactNumber(), 999999999);
    assertEquals(anotherInvalidDoctor.isQualifiedInIreland(), false);
  }