1 24 25 package com.mckoi.database; 26 27 import java.util.ArrayList ; 28 29 38 39 public final class UserManager { 40 41 45 private ArrayList user_list; 46 47 50 UserManager() { 51 user_list = new ArrayList (); 52 } 53 54 57 synchronized void userLoggedIn(User user) { 58 if (!user_list.contains(user)) { 59 user_list.add(user); 60 } 61 else { 62 throw new Error ("UserManager already has this User instance logged in."); 63 } 64 } 65 66 69 synchronized void userLoggedOut(User user) { 70 user_list.remove(user); 71 } 72 73 76 public synchronized int userCount() { 77 return user_list.size(); 78 } 79 80 84 public synchronized User userAt(int n) { 85 return (User) user_list.get(n); 86 } 87 88 } 89 | Popular Tags |