Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LyyraCard {
- private double balance;
- public LyyraCard(double balanceAtStart) {
- balance += balanceAtStart;
- }
- public String toString() {
- return "The card has " + balance + " euros";
- }
- public void payEconomical() {
- balance -= 2.50;
- if (balance < 0) {
- balance += 2.50;
- }
- }
- public void payGourmet() {
- balance -= 4.00;
- if (balance < 0) {
- balance += 4.00;
- }
- }
- public void loadMoney(double amount) {
- if (amount >= 0) {
- balance += amount;
- }
- if (balance > 150) {
- balance = 150;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement