Example #1
0
  public void readValues(String directory) {
    try {
      FileReader fReader = new FileReader(directory);
      @SuppressWarnings("resource")
      BufferedReader bReader = new BufferedReader(fReader);
      String line;
      String[] values;
      /* Read k param */
      k = Integer.parseInt(bReader.readLine());

      /* Read magazine coords */
      values = bReader.readLine().split(" ");
      numberOfCities = 0;
      magazine.city = new City(Integer.parseInt(values[0]), Integer.parseInt(values[1]));
      numberOfCities++;

      cities.clear();
      /* Read rest of cities */
      while ((line = bReader.readLine()) != null) {
        values = line.split(" ");
        cities.add(new City(Integer.parseInt(values[0]), Integer.parseInt(values[1])));
        numberOfCities++;
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 /**
  * Testing that the {@link Magazine#hashCode} method of the {@link Magazine} class works correctly
  *
  * @see Magazine#hashCode()
  * @see Magazine
  */
 @Test
 public void testHash() {
   Magazine mag1 = new Magazine("Title", "Publisher", of(2015), 22_274_096, pubFreqOf(MONTHLY));
   Magazine mag2 = new Magazine("Title", "Publisher", of(2015), 22_274_096, pubFreqOf(MONTHLY));
   assertThat(mag1.hashCode(), is(equalTo(mag2.hashCode())));
 }
Example #3
0
 public void notifyAllObservers() {
   for (Magazine magazine : magazines) {
     magazine.update();
   }
 }
  /**
   * Testing that the {@link Magazine#getPublisher} method of the {@link Magazine} class returns the
   * expected value
   *
   * @see Magazine#getPublisher()
   * @see Magazine
   */
  @Test
  public void testGetPublisher() {

    Magazine mag = new Magazine("Title", "Publisher", of(2015), 22_274_096, pubFreqOf(MONTHLY));
    assertThat(mag.getPublisher(), is(equalTo("Publisher")));
  }