Untitled
unknown
java
2 years ago
429 B
8
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