public void AddMoneyToCard(PaymentCard card, double sum) { // ... money = money + sum; card.AddMoney(sum); }
public void AddMoneyToCard(PaymentCard card, double sum) { if (this.money >= sum) { card.AddMoney(sum); this.money = this.money + sum; } }
public void AddMoneyToCard(PaymentCard card, double sum) { // ... card.AddMoney(sum); this.money = this.money + sum; }
public void TestCardAddMoney() { PaymentCard card = new PaymentCard(10); card.AddMoney(5); Assert.AreEqual(15, card.balance, "AddMoney should increase the balance by the amount!"); }
public void AddMoneyToCard(PaymentCard card, double sum) { if (money - sum >= 0) { money -= sum; card.AddMoney(sum); } }
public void AddMoneyToCard(PaymentCard card, double sum) { if (sum < 0) { return; } card.AddMoney(sum); this.money += sum; }
public void TestAddMoney() { { PaymentCard card = new PaymentCard(10); card.AddMoney(20); // Assert Assert.AreEqual("The card has a balance of 30 euros", card.ToString(), "Money should add up!"); } }
public void TestAddNegativeMoney() { { PaymentCard card = new PaymentCard(10); card.AddMoney(-5); // Assert Assert.AreEqual("The card has a balance of 10 euros", card.ToString(), "You cannot add negative money!"); } }
public void TestAddTooMuchMoney() { { PaymentCard card = new PaymentCard(10); card.AddMoney(200); // Assert Assert.AreEqual("The card has a balance of 150 euros", card.ToString(), "Balance should top up at 150!"); } }
public void AddMoneyToCard(PaymentCard card, double sum) { card.AddMoney(sum); }