Skip to content

Instantly share code, notes, and snippets.

@asolntsev
Created June 8, 2020 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asolntsev/4beeb8236c9ee0eb8eea5831659e5117 to your computer and use it in GitHub Desktop.
Save asolntsev/4beeb8236c9ee0eb8eea5831659e5117 to your computer and use it in GitHub Desktop.
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