Esempio n. 1
0
  @Test
  public void testAddMoney() {
    Money money = new Money(0);
    Money moneyOne = new Money(1.0);
    Money moneyPointOne = new Money(0.1);
    Money moneyMinusOne = new Money(-1.0);

    money.addMoney(moneyOne);
    assertEquals(1, money.getAmount(), 0.0001);
    money.addMoney(moneyPointOne);
    assertEquals(1.1, money.getAmount(), 0.0001);
    money.addMoney(moneyMinusOne);
    assertEquals(0.1, money.getAmount(), 0.0001);
  }
Esempio n. 2
0
  private static void testingWhenPoundsAndPence() {
    Money m1, m2, m3, m4;

    m1 = new Money(9, 64); // valid False
    m2 = new Money(0, 0); // valid true
    m3 = new Money(99, 164); // valid true
    m4 = new Money(100, 10); // valid false

    Money[] mAr = new Money[] {m1, m2, m3, m4};

    for (Money money : mAr) {
      // System.out.println(money.getValidMoney());

      // System.out.println(money.getCurrentMoney());
      // System.out.println("\r\n");
    }

    m1.addMoney(1, 50);
    System.out.println(m1.toString());
  }