Untitled

 avatar
unknown
java
a year ago
429 B
6
Indexable
public class User {

    private int moneyOfUser;

    public User(int moneyOfUser) {
        this.moneyOfUser = moneyOfUser;
    }

    public int getAmountOfMoney() {
        return this.moneyOfUser;
    }

    public void pay(int price){
        if (price <= moneyOfUser){
            moneyOfUser -= price;
        } else {
            System.out.println(" you can not buy this item! ");
        }
    }
}
Editor is loading...
Leave a Comment