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.
44 lines
1.2 KiB
44 lines
1.2 KiB
2 years ago
|
package org.poopki.duckdns.user_db.Array;
|
||
3 years ago
|
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
import java.util.UUID;
|
||
|
|
||
|
public class AccountArray {
|
||
3 years ago
|
private static Map<UUID, Account> m_AccountArray = new HashMap<UUID, Account>();
|
||
3 years ago
|
|
||
3 years ago
|
public int transfer(UUID Src, UUID Des, Long Amount){ // 송금 method
|
||
3 years ago
|
Account m_Src = m_AccountArray.get(Src);
|
||
|
Account m_Des = m_AccountArray.get(Des);
|
||
|
|
||
3 years ago
|
if(m_Src.withdraw(Amount)){ //인출 성공시 입금
|
||
3 years ago
|
if(m_Des.credit(Amount))
|
||
|
{
|
||
|
return 1;
|
||
|
}
|
||
|
else{
|
||
|
m_Src.credit(Amount);
|
||
|
return 2;
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
return 3;
|
||
3 years ago
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
|
||
3 years ago
|
public int getAccountInfo(UUID uuid) { // DB backup시 account 정보 접근 method
|
||
3 years ago
|
Account m_Account = m_AccountArray.get(uuid);
|
||
|
return m_Account.getBalance();
|
||
|
}
|
||
|
|
||
3 years ago
|
public void putAccountInfo(UUID uuid, int Amount) { //AccountArray 생성
|
||
3 years ago
|
m_AccountArray.put(uuid, new Account(Amount));
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
public boolean setAccountInfo(UUID uuid, Long Amount) {
|
||
3 years ago
|
Account m_Account = m_AccountArray.get(uuid);
|
||
3 years ago
|
return m_Account.setBalance(Amount);
|
||
3 years ago
|
}
|
||
3 years ago
|
}
|