Browse Source

UserFactory Bug fixes

- Declared users as ArrayList
- Fixed false declaration method of newUser(String, int)
- Renamed new and old to newUser and oldUser due to ‘new’ unusable
master
BinHong Lee 8 years ago
parent
commit
2ab2cdd3d4
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      UserFactory.java

+ 5
- 5
UserFactory.java View File

@@ -7,7 +7,7 @@ import java.util.*;


class UserFactory class UserFactory
{ {
private List<User> users = new List<User>;
private List<User> users = new ArrayList<User>();
private int id; private int id;


public UserFactory() public UserFactory()
@@ -15,7 +15,7 @@ class UserFactory
id = 0; id = 0;
} }


public User newUser(String name; int limit)
public User newUser(String name, int limit)
{ {
User temp = new User(name, id, limit); User temp = new User(name, id, limit);
users.add(temp); users.add(temp);
@@ -55,15 +55,15 @@ class UserFactory
throw new NullPointerException(); throw new NullPointerException();
} }


public void update(User old, User new)
public void update(User oldUser, User newUser)
{ {
for (int i = 0; i < users.size(); i++) for (int i = 0; i < users.size(); i++)
{ {
User temp = users.get(i); User temp = users.get(i);


if(temp.getId() == old.getId())
if(temp.getId() == oldUser.getId())
{ {
users.set(i, new);
users.set(i, newUser);
} }
} }
} }


Loading…
Cancel
Save