Newer
Older
CactusServer / src / main / java / cactusServer / models / Accounts.java
package cactusServer.models;

import javax.inject.Singleton;

import cactusServer.entities.Account;

import java.util.ArrayList;

@Singleton
public class Accounts {
	private static Accounts theInstance = null;
	private ArrayList<Account> accounts = new ArrayList<Account>();

	public Accounts() {
		if (theInstance == null) {
			theInstance = this;
		}
	}

	public static Accounts getInstance() {
		if (theInstance == null) {
			theInstance = new Accounts();
		}
		return theInstance;
	}

	public Account createAcount(String userID,String userName) {
		System.out.println(userName);

		Account newAccount = new Account(userID, userName);
		accounts.add(newAccount);

		System.out.println(userID);

		return newAccount;
	}

	public void createAccount(String userId) {
		Account newAccount = new Account(userId, "user" + userId);
		accounts.add(newAccount);
		System.out.println(accounts.size());
	}

	public ArrayList<Account> getAccountList() {
		return this.accounts;
	}

	public Account getAcount(String userID) {
		Account editAccount = accounts.get(Integer.valueOf(userID));
		return editAccount;
	}

	public Accounts getAccount() {
		Account ac = new Account();
		return new Accounts();
	}
	
	public String deleteAccount(int userID) {
		accounts.remove(userID);
		return "complated remove account";
	}

	public ArrayList<Account> getAccounts() {
		return accounts;
	}

	public void setAccounts(ArrayList<Account> accounts) {
		this.accounts = accounts;
	}

}