Created
June 8, 2020 21:53
-
-
Save asolntsev/4beeb8236c9ee0eb8eea5831659e5117 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AccountTest { | |
public static void main(String[] args) { | |
Account account = new Account("111-22-33-4444"); | |
System.out.println("Остаток на счету " + account.number + ": " + account.getBalance()); | |
account.pay(3); | |
System.out.println("Остаток на счету " + account.number + ": " + account.getBalance()); | |
} | |
} | |
public class Account { | |
public final String number; | |
private int balance = 0; | |
public Account(String number) { | |
this.number = number; | |
} | |
public int getBalance() { | |
return balance; | |
} | |
public void pay(int amount) { | |
balance = balance - amount; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment