Advertisement
Guest User

Untitled

a guest
May 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. public class LyyraCard {
  2.  
  3. private double balance;
  4.  
  5. public LyyraCard(double balanceAtStart) {
  6. balance += balanceAtStart;
  7. }
  8.  
  9. public String toString() {
  10. return "The card has " + balance + " euros";
  11. }
  12.  
  13. public void payEconomical() {
  14.  
  15. balance -= 2.50;
  16. if (balance < 0) {
  17. balance += 2.50;
  18. }
  19. }
  20.  
  21. public void payGourmet() {
  22. balance -= 4.00;
  23. if (balance < 0) {
  24. balance += 4.00;
  25. }
  26. }
  27.  
  28. public void loadMoney(double amount) {
  29. if (amount >= 0) {
  30. balance += amount;
  31. }
  32.  
  33. if (balance > 150) {
  34. balance = 150;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement