Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Account {
- private int number;
- private double balance;
- public Account(int number) {
- this(number, 0.0);
- }
- public Account(int number, double balance) {
- this.number = number;
- this.balance = balance;
- }
- public void setNumber(int number) {
- this.number = number;
- }
- public int getNumber() {
- return number;
- }
- public void setBalance(double balance) {
- this.balance = balance;
- }
- public double getBalance() {
- return balance;
- }
- public void deposit(double amount) {
- setBalance(this.balance + amount);
- }
- public void withdraw(double amount) {
- setBalance(this.balance - amount);
- }
- public String toString() {
- return String.format("Account %d with amount %.2f", getNumber(),
- getBalance());
- }
- } // end of Account
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement