|
|
@ -7,15 +7,23 @@ import java.util.UUID; |
|
|
|
public class AccountArray { |
|
|
|
public class AccountArray { |
|
|
|
private static Map<UUID, Account> m_AccountArray = new HashMap<UUID, Account>(); |
|
|
|
private static Map<UUID, Account> m_AccountArray = new HashMap<UUID, Account>(); |
|
|
|
|
|
|
|
|
|
|
|
public boolean transfer(UUID Src, UUID Des, int Amount){ // 송금 method
|
|
|
|
public int transfer(UUID Src, UUID Des, Long Amount){ // 송금 method
|
|
|
|
Account m_Src = m_AccountArray.get(Src); |
|
|
|
Account m_Src = m_AccountArray.get(Src); |
|
|
|
Account m_Des = m_AccountArray.get(Des); |
|
|
|
Account m_Des = m_AccountArray.get(Des); |
|
|
|
|
|
|
|
|
|
|
|
if(m_Src.withdraw(Amount)){ //인출 성공시 입금
|
|
|
|
if(m_Src.withdraw(Amount)){ //인출 성공시 입금
|
|
|
|
m_Des.credit(Amount); |
|
|
|
if(m_Des.credit(Amount)) |
|
|
|
return true; |
|
|
|
{ |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
m_Src.credit(Amount); |
|
|
|
|
|
|
|
return 2; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
return 3; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int getAccountInfo(UUID uuid) { // DB backup시 account 정보 접근 method
|
|
|
|
public int getAccountInfo(UUID uuid) { // DB backup시 account 정보 접근 method
|
|
|
@ -27,8 +35,8 @@ public class AccountArray { |
|
|
|
m_AccountArray.put(uuid, new Account(Amount)); |
|
|
|
m_AccountArray.put(uuid, new Account(Amount)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setAccountInfo(UUID uuid, int Amount) { |
|
|
|
public boolean setAccountInfo(UUID uuid, Long Amount) { |
|
|
|
Account m_Account = m_AccountArray.get(uuid); |
|
|
|
Account m_Account = m_AccountArray.get(uuid); |
|
|
|
m_Account.setBalance(Amount); |
|
|
|
return m_Account.setBalance(Amount); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|