diff options
author | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-05-13 22:08:44 +0000 |
---|---|---|
committer | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-05-13 22:08:44 +0000 |
commit | 1f3ba98ad6f6193349eb0e4111dff62e1cf28784 (patch) | |
tree | b802bcb53328e8e8296283cbaa0cb849658148cf /Register/src/com/essentials/register/payment/MethodiCo5.java | |
parent | c4099dfb2123fd2bd53378dcfd355b43c694677a (diff) | |
download | Essentials-1f3ba98ad6f6193349eb0e4111dff62e1cf28784.tar Essentials-1f3ba98ad6f6193349eb0e4111dff62e1cf28784.tar.gz Essentials-1f3ba98ad6f6193349eb0e4111dff62e1cf28784.tar.lz Essentials-1f3ba98ad6f6193349eb0e4111dff62e1cf28784.tar.xz Essentials-1f3ba98ad6f6193349eb0e4111dff62e1cf28784.zip |
Register included inside Essentials with different packagename to prevent recursion
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1443 e251c2fe-e539-e718-e476-b85c1f46cddb
Diffstat (limited to 'Register/src/com/essentials/register/payment/MethodiCo5.java')
-rw-r--r-- | Register/src/com/essentials/register/payment/MethodiCo5.java | 191 |
1 files changed, 191 insertions, 0 deletions
diff --git a/Register/src/com/essentials/register/payment/MethodiCo5.java b/Register/src/com/essentials/register/payment/MethodiCo5.java new file mode 100644 index 000000000..1927d9fcf --- /dev/null +++ b/Register/src/com/essentials/register/payment/MethodiCo5.java @@ -0,0 +1,191 @@ +package com.nijikokun.register.payment; + +import com.iConomy.iConomy; +import com.iConomy.system.Account; +import com.iConomy.system.BankAccount; +import com.iConomy.system.Holdings; +import com.iConomy.util.Constants; + +public class MethodiCo5 implements Method { + private iConomy iConomy; + + public MethodiCo5(iConomy iConomy) { + this.iConomy = iConomy; + } + + public iConomy getPlugin() { + return this.iConomy; + } + + public String getName() { + return "iConomy"; + } + + public String getVersion() { + return "5"; + } + + public String format(double amount) { + return this.iConomy.format(amount); + } + + public boolean hasBanks() { + return Constants.Banking; + } + + public boolean hasBank(String bank) { + return (!hasBanks()) ? false : this.iConomy.Banks.exists(bank); + } + + public boolean hasAccount(String name) { + return this.iConomy.hasAccount(name); + } + + public boolean hasBankAccount(String bank, String name) { + return (hasBank(bank)) ? false : this.iConomy.getBank(name).hasAccount(name); + } + + public MethodAccount getAccount(String name) { + return new iCoAccount(this.iConomy.getAccount(name)); + } + + public MethodBankAccount getBankAccount(String bank, String name) { + return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name)); + } + + public class iCoAccount implements MethodAccount { + private Account account; + private Holdings holdings; + + public iCoAccount(Account account) { + this.account = account; + this.holdings = account.getHoldings(); + } + + public Account getiCoAccount() { + return account; + } + + public double balance() { + return this.holdings.balance(); + } + + public boolean add(double amount) { + if(this.holdings == null) return false; + this.holdings.add(amount); + return true; + } + + public boolean subtract(double amount) { + if(this.holdings == null) return false; + this.holdings.subtract(amount); + return true; + } + + public boolean multiply(double amount) { + if(this.holdings == null) return false; + this.holdings.multiply(amount); + return true; + } + + public boolean divide(double amount) { + if(this.holdings == null) return false; + this.holdings.divide(amount); + return true; + } + + public boolean hasEnough(double amount) { + return this.holdings.hasEnough(amount); + } + + public boolean hasOver(double amount) { + return this.holdings.hasOver(amount); + } + + public boolean hasUnder(double amount) { + return this.holdings.hasUnder(amount); + } + + public boolean isNegative() { + return this.holdings.isNegative(); + } + + public boolean remove() { + if(this.account == null) return false; + this.account.remove(); + return true; + } + } + + public class iCoBankAccount implements MethodBankAccount { + private BankAccount account; + private Holdings holdings; + + public iCoBankAccount(BankAccount account) { + this.account = account; + this.holdings = account.getHoldings(); + } + + public BankAccount getiCoBankAccount() { + return account; + } + + public String getBankName() { + return this.account.getBankName(); + } + + public int getBankId() { + return this.account.getBankId(); + } + + public double balance() { + return this.holdings.balance(); + } + + public boolean add(double amount) { + if(this.holdings == null) return false; + this.holdings.add(amount); + return true; + } + + public boolean subtract(double amount) { + if(this.holdings == null) return false; + this.holdings.subtract(amount); + return true; + } + + public boolean multiply(double amount) { + if(this.holdings == null) return false; + this.holdings.multiply(amount); + return true; + } + + public boolean divide(double amount) { + if(this.holdings == null) return false; + this.holdings.divide(amount); + return true; + } + + public boolean hasEnough(double amount) { + return this.holdings.hasEnough(amount); + } + + public boolean hasOver(double amount) { + return this.holdings.hasOver(amount); + } + + public boolean hasUnder(double amount) { + return this.holdings.hasUnder(amount); + } + + public boolean isNegative() { + return this.holdings.isNegative(); + } + + public boolean remove() { + if(this.account == null) return false; + this.account.remove(); + return true; + } + } +} |