@Test
 public void OnlyCoffee() {
   Out.print("only coffee");
   CentralPerk house = new HouseBlend();
   Out.print(house.cost());
   // assertThat(actual, matcher)
   assertEquals(28.0, house.cost(), DELTA);
   CentralPerk espresso = new Espresso();
   assertEquals(32.0, espresso.cost(), DELTA);
 }
Exemple #2
0
  /**
   * Prints one Unicode property value per line, along with its aliases, if any, for the given
   * unicodeVersion.
   *
   * @param unicodeVersion The Unicode version to print property values and aliases for
   * @throws UnicodeProperties.UnsupportedUnicodeVersionException if unicodeVersion is not supported
   */
  private static void printUnicodePropertyValuesAndAliases(String unicodeVersion)
      throws UnicodeProperties.UnsupportedUnicodeVersionException {
    Pattern versionPattern = Pattern.compile("(\\d+)(?:\\.(\\d+))?(?:\\.\\d+)?");
    Matcher matcher = versionPattern.matcher(unicodeVersion);
    if (!matcher.matches()) {
      throw new UnicodeProperties.UnsupportedUnicodeVersionException();
    }
    String underscoreVersion =
        matcher.group(1) + (null == matcher.group(2) ? "_0" : "_" + matcher.group(2));

    String[] propertyValues;
    String[] propertyValueAliases;
    try {
      Class<?> clazz = Class.forName("jflex.unicode.data.Unicode_" + underscoreVersion);
      Field field = clazz.getField("propertyValues");
      propertyValues = (String[]) field.get(null);
      field = clazz.getField("propertyValueAliases");
      propertyValueAliases = (String[]) field.get(null);
    } catch (Exception e) {
      throw new UnicodeProperties.UnsupportedUnicodeVersionException();
    }
    SortedMap<String, SortedSet<String>> propertyValuesToAliases =
        new TreeMap<String, SortedSet<String>>();
    for (String value : propertyValues) {
      propertyValuesToAliases.put(value, new TreeSet<String>());
    }
    for (int i = 0; i < propertyValueAliases.length; i += 2) {
      String alias = propertyValueAliases[i];
      String value = propertyValueAliases[i + 1];
      SortedSet<String> aliases = propertyValuesToAliases.get(value);
      if (null == aliases) {
        aliases = new TreeSet<String>();
        propertyValuesToAliases.put(value, aliases);
      }
      aliases.add(alias);
    }
    for (Map.Entry<String, SortedSet<String>> entry : propertyValuesToAliases.entrySet()) {
      String value = entry.getKey();
      SortedSet<String> aliases = entry.getValue();
      Out.print(value);
      if (aliases.size() > 0) {
        for (String alias : aliases) {
          Out.print(", " + alias);
        }
      }
      Out.println("");
    }
  }
 private static void saveWords(String fileName, String[] words) {
   int MAX_LENGTH = 70;
   Out out = new Out(fileName);
   int length = 0;
   for (String word : words) {
     length += word.length();
     if (length > MAX_LENGTH) {
       out.println();
       length = word.length();
     }
     out.print(word);
     out.print(" ");
     length++;
   }
   out.close();
 }
 @Test
 public void withMilk() {
   Out.print("only coffee");
   CentralPerk house = new HouseBlend();
   house = new Milk(house);
   house = new Milk(house);
   house = new Mocha(house);
   assertEquals(28 + 5 + 5 + 7, house.cost(), DELTA);
 }
Exemple #5
0
 @Override
 public void plant() {
   Out.print("Pear is plantling");
 }
Exemple #6
0
  @Override
  public void harvest() {

    Out.print("Pear is harvested");
  }
Exemple #7
0
  @Override
  public void grow() {

    Out.print("Pear is growing");
  }
 /** Writes this failure case to a file. */
 public void toFile(String filename) {
   Out out = new Out(filename);
   out.print(this.toString());
   out.close();
 }
  // A method for printing out the information
  public static void output(String[] row) {
    // Finds the length of the first element
    int a = row[0].length();

    // Prints out the first element
    out.print(row[0].substring(a - 1, a));
    out.print(",");

    // Finds time length
    a = row[1].length();
    if (a > 17) out.print(row[1].substring(17, a));
    out.print(",");

    // Finds the down
    a = row[2].length();
    if (a > 17) out.print(row[2].substring(17, a));
    out.print(",");

    // Finds the ToGo length
    a = row[3].length();
    if (a > 17) out.print(row[3].substring(17, a));
    out.print(",");

    // Finds the possession
    a = row[4].length();
    if (a > 13) out.print(row[4].substring(13, a));
    out.print(",");

    // Parses the play
    String play = playparse(row[5]);
    out.print(play);
    out.print(",");

    // Finds the current score for first team
    a = row[6].length();
    if (a > 4) out.print(row[6].substring(4, a));
    out.print(",");

    // Finds the current score for the second team
    a = row[7].length();
    if (a > 4) out.print(row[7].substring(4, a));
    out.print(",");

    // Finds the EPB
    a = row[8].length();
    if (a > 4) out.print(row[8].substring(4, a));
    out.print(",");

    // Finds the EPA
    a = row[9].length();
    if (a > 4) out.print(row[9].substring(4, a));
    out.print(",");

    // Outputs the possession
    out.println(possession);
  }