package account;

import java.io.Serializable;
import java.util.LinkedList;

@SuppressWarnings("serial")
public class Account implements Serializable {
	private String accountNumber;
	private String name;
	private int balance;
	private boolean haveCard = false;
	private LinkedList<String> stateList = new LinkedList<String>();
	private int debt = 0;
	private boolean stolen = false;

	public Account(String accountNumber, String name) {
		this.accountNumber = accountNumber;
		this.name = name;
		this.balance = 0;
	}

	// getter & setter...

	public String getAccountNumber() {
		return accountNumber;
	}

	public String getName() {
		return name;
	}

	public int getBalance() {
		return balance;
	}

	public int getDebt() {
		return debt;
	}

	public LinkedList<String> getStateList() {
		return stateList;
	}

	public void addStateList(String state) {
		stateList.add(state);
	}

	// basic function...
	public boolean deposit(int money) {
		if (money <= 0)
			return false;
		balance += money;
		return true;
	}

	public boolean withdraw(int money) {
		if (balance < money)
			return false;
		balance -= money;
		return true;
	}

	public boolean transfer(String accountNumber, int money) {
		return withdraw(money);
	}

	// loan function
	public void loan(int money) {
		debt += money;
	}

	public boolean repay(int money) {
		if (debt < money)
			return false;
		debt -= money;
		return true;
	}

	public boolean repayOnAccount(int money) {
		boolean isDone = withdraw(money);
		if (isDone)
			debt -= money;
		return isDone;
	}

	// card function...
	public void lostReport() {
		stolen = true;
	}

	public void findReport() {
		stolen = false;
	}

	public boolean makeCard() {
		if (haveCard)
			return false; // if already have card

		haveCard = true;
		return true;
	}

	public boolean useCard(String state, int money) {
		if (!haveCard || stolen)
			return false;

		balance -= money;
		return true;
	}
}

@@ -224,43 +224,8 @@
 ce;%0A
-%09private boolean haveCard = false;%0A
 %09pri
@@ -312,41 +312,8 @@
 = 0;
-%0A%09private boolean stolen = false;
 %0A%0A%09p
@@ -441,24 +441,32 @@
 ce = 0;%0A%09%7D%0A%0A
+%09//%0A%09//%0A
 %09// getter &
@@ -476,17 +476,16 @@
 tter...%0A
-%0A
 %09public 
@@ -812,24 +812,32 @@
 state);%0A%09%7D%0A%0A
+%09//%0A%09//%0A
 %09// basic fu
@@ -1008,32 +1008,46 @@
 (balance %3C money
+ %7C%7C money %3C= 0
 )%0A%09%09%09return fals
@@ -1174,24 +1174,32 @@
 money);%0A%09%7D%0A%0A
+%09//%0A%09//%0A
 %09// loan fun
@@ -1212,20 +1212,23 @@
 %09public 
-void
+boolean
  loan(in
@@ -1238,16 +1238,50 @@
 oney) %7B%0A
+%09%09if(money %3C= 0)%0A%09%09%09return false;%0A
 %09%09debt +
@@ -1289,16 +1289,31 @@
  money;%0A
+%09%09return true;%0A
 %09%7D%0A%0A%09pub
@@ -1361,16 +1361,30 @@
  %3C money
+ %7C%7C money %3C= 0
 )%0A%09%09%09ret
@@ -1474,16 +1474,52 @@
 oney) %7B%0A
+%09%09if(debt %3C money)%0A%09%09%09return false;%0A
 %09%09boolea
@@ -1601,387 +1601,7 @@
 ;%0A%09%7D
-%0A%0A%09// card function...%0A%09public void lostReport() %7B%0A%09%09stolen = true;%0A%09%7D%0A%0A%09public void findReport() %7B%0A%09%09stolen = false;%0A%09%7D%0A%0A%09public boolean makeCard() %7B%0A%09%09if (haveCard)%0A%09%09%09return false; // if already have card%0A%0A%09%09haveCard = true;%0A%09%09return true;%0A%09%7D%0A%0A%09public boolean useCard(String state, int money) %7B%0A%09%09if (!haveCard %7C%7C stolen)%0A%09%09%09return false;%0A%0A%09%09balance -= money;%0A%09%09return true;%0A%09%7D
 %0A%7D%0A

delete unused function & variables