Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.LinkedList;
- public class Customer {
- private String name;
- private int uID;
- private int pIN;
- private LinkedList<Account> accounts;
- public static int customerCount = 0;
- public Customer(String name, int pIN) {
- this.name = name;
- this.uID = customerCount++;
- this.pIN = pIN;
- this.accounts = new LinkedList<Account>();
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getuID() {
- return uID;
- }
- public void setuID(int uID) {
- this.uID = uID;
- }
- public int getpIN() {
- return pIN;
- }
- public void setpIN(int pIN) {
- this.pIN = pIN;
- }
- public LinkedList<Account> getAccounts() {
- return accounts;
- }
- public void setAccounts(LinkedList<Account> accounts) {
- this.accounts = accounts;
- }
- public boolean changePIN(int newPIN, int oldPIN) {
- if(oldPIN == this.getpIN()) {
- this.setpIN(newPIN);
- return true;
- } else {
- return false;
- }
- }
- public void showAccounts() {
- for(int i = 0; i < this.accounts.size(); i++) {
- System.out.println(accounts.get(i));
- }
- }
- public void addAccount(Account x) {
- this.accounts.add(x);
- }
- public Account findAccount(String type) {
- for(int i = 0; i < this.accounts.size(); i++) {
- if(type.equalsIgnoreCase(accounts.get(i).getType())) {
- return accounts.get(i);
- }
- }
- return null;
- }
- public int getCustomerCount() {
- return customerCount;
- }
- public void setCustomerCount(int customerCount) {
- Customer.customerCount = customerCount;
- }
- }
- //By Jonathan Baird
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement