From 2ab2cdd3d454ff92c0f2439877c91dee85cdcdab Mon Sep 17 00:00:00 2001 From: BinHong Lee Date: Tue, 7 Jun 2016 00:22:10 -0700 Subject: [PATCH] UserFactory Bug fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Declared users as ArrayList - Fixed false declaration method of newUser(String, int) - Renamed new and old to newUser and oldUser due to ‘new’ unusable --- UserFactory.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/UserFactory.java b/UserFactory.java index e45afe3..6ef5ab3 100644 --- a/UserFactory.java +++ b/UserFactory.java @@ -7,7 +7,7 @@ import java.util.*; class UserFactory { - private List users = new List; + private List users = new ArrayList(); private int id; public UserFactory() @@ -15,7 +15,7 @@ class UserFactory id = 0; } - public User newUser(String name; int limit) + public User newUser(String name, int limit) { User temp = new User(name, id, limit); users.add(temp); @@ -55,15 +55,15 @@ class UserFactory 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++) { User temp = users.get(i); - if(temp.getId() == old.getId()) + if(temp.getId() == oldUser.getId()) { - users.set(i, new); + users.set(i, newUser); } } }