You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

package org.poopki.duckdns.user_db.Array;
public class Account {
private int m_Balance;
private int MAX_BALANCE = 2147483647;
public Account(int Balance){ // Account Balance 초기화
m_Balance = Balance;
}
public boolean setBalance(Long Amount){ // 잔액 설정
if(Amount<MAX_BALANCE) { // 잔고가 MAX_BALANCE 이하일경우
m_Balance = Amount.intValue(); // Amount만큼 설정
return true;
}else{
return false;
}
}
public int getBalance(){ return m_Balance; } //잔액 return
public boolean credit(Long Amount){ // 입금
if(m_Balance+Amount < MAX_BALANCE) { // 잔고가 MAX_BALANCE 이하일경우
m_Balance += Amount.intValue(); // Amount만큼 현재 잔고에서 더하기
return true;
}
else{
return false;
}
}
public boolean withdraw(Long Amount){ // 출금
if(m_Balance >= Amount){ // 잔고가 MAX_BALANCE 이하일경우
m_Balance -= Amount.intValue(); // Amount만큼 현재 잔고에서 빼기
return true;
}
return false;
}
}