Untitled

mail@pastecode.io avatar
unknown
java
2 months ago
429 B
2
Indexable
Never
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! ");
        }
    }
}
Leave a Comment