Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Your preamble here!
- *
- * @author: Yongjae Park (1531330)
- */
- package uk.ac.warwick.java.cs126.services;
- import uk.ac.warwick.java.cs126.models.User;
- import java.util.Date;
- public class UserStore implements IUserStore
- {
- private User[] array;
- private int size;
- private int capacity;
- private int extension;
- public UserStore()
- {
- this.array = new User[capacity];
- this.size = 0;
- this.capacity = 100;
- this.extension = 50;
- }
- public boolean addUser(User user)
- {
- // TODO
- private int j = 0;
- if(size >= capacity)
- {
- capacity += extension;
- private User[] array2;
- array2 = new User[capacity];
- array2 = this.array;
- this.array = new User[capacity];
- this.array = array2;
- }
- for(int i=0;i<size;i++)
- {
- if(user = this.array[i])
- j++;
- }
- if(j == 1)
- return false;
- else
- {
- this.array[size] = user;
- size++;
- return true;
- }
- }
- public User getUser(int uid)
- {
- // TODO
- for(int i=0;i<size;i++)
- {
- if(this.array[i].getId() = uid)
- return this.array[i];
- }
- }
- public User[] getUsers()
- {
- // TODO
- private User[] array2;
- array2 = new User[size];
- for(int i=0;i<size;i++)
- {
- array2[i] = this.array[size - 1 - i];
- }
- return array2;
- }
- public User[] getUsersContaining(String query)
- {
- // TODO
- private User[] array2;
- array2 = new User[size];
- for(int i=0;i<size;i++)
- {
- }
- return null;
- }
- public User[] getUsersJoinedBefore(Date dateBefore)
- {
- // TODO
- private User[] array2;
- array2 = new User[size];
- for(int i=0;i<size;i++)
- {
- }
- return null;
- }
- }
Add Comment
Please, Sign In to add comment