Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by HrishithaM ( 5 years ago )
public class UserDatabase {
public final static int CAPACITY = 5;
User[] users = new User[CAPACITY];
public User[] getAllUsers(){
return users;
}
public void addUser (User u) {
int id = u.getId();
users[id] = u
}
public void addUser(int id) {
if (id<0 || id >= users.length) {
System.out.println("Over capacity. The maximum capacity is " + UserDatabase.CAPACITY);
return;
}
users[id] = user;
}
public User getUserById(int id) {
if (id<0 || id>= users.length ) {
return null;
}
return users[id];
}
public User getUserByUserName(String userName) {
for (User u: users) {
if (u.getUserName().equals(userName)) {
return user;
}
return null;
}
}
public boolean userExists(User user) {
for (User u: users) {
String un = user.getUserName();
String pw = user.getPassword();
if (u.getUserName().equals(un) && u.getPassword().equals(pw)){
return true;
}
}
return false;
}
}
Revise this Paste
Children: 116646