Raizekas

Untitled

Mar 14th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.68 KB | None | 0 0
  1. /**
  2.  * Your preamble here!
  3.  *
  4.  * @author: Yongjae Park (1531330)
  5.  */
  6.  
  7. package uk.ac.warwick.java.cs126.services;
  8.  
  9. import uk.ac.warwick.java.cs126.models.User;
  10.  
  11. import java.util.Date;
  12.  
  13. public class UserStore implements IUserStore
  14. {
  15.    
  16.     private User[] array;
  17.     private int size;
  18.     private int capacity;
  19.     private int extension;
  20.    
  21.     public UserStore()
  22.     {
  23.         this.array = new User[capacity];
  24.         this.size = 0;
  25.         this.capacity = 100;
  26.         this.extension = 50;
  27.     }
  28.    
  29.     public boolean addUser(User user)
  30.     {
  31.         // TODO
  32.         private int j = 0;
  33.        
  34.         if(size >= capacity)
  35.         {
  36.             capacity += extension;
  37.            
  38.             private User[] array2;
  39.             array2 = new User[capacity];
  40.             array2 = this.array;
  41.            
  42.             this.array = new User[capacity];
  43.             this.array = array2;
  44.         }
  45.        
  46.         for(int i=0;i<size;i++)
  47.         {
  48.             if(user = this.array[i])
  49.             j++;   
  50.         }
  51.        
  52.         if(j == 1)
  53.             return false;
  54.         else
  55.         {
  56.             this.array[size] = user;
  57.             size++;
  58.             return true;
  59.         }
  60.     }
  61.    
  62.     public User getUser(int uid)
  63.     {
  64.         // TODO
  65.         for(int i=0;i<size;i++)
  66.         {
  67.             if(this.array[i].getId() = uid)
  68.                 return this.array[i];
  69.         }
  70.     }
  71.    
  72.     public User[] getUsers()
  73.     {
  74.         // TODO
  75.         private User[] array2;
  76.         array2 = new User[size];
  77.        
  78.         for(int i=0;i<size;i++)
  79.         {
  80.             array2[i] = this.array[size - 1 - i];
  81.         }
  82.         return array2;
  83.     }
  84.    
  85.     public User[] getUsersContaining(String query)
  86.     {
  87.         // TODO
  88.         private User[] array2;
  89.         array2 = new User[size];
  90.        
  91.         for(int i=0;i<size;i++)
  92.         {
  93.            
  94.         }
  95.         return null;
  96.     }
  97.    
  98.     public User[] getUsersJoinedBefore(Date dateBefore)
  99.     {
  100.         // TODO
  101.         private User[] array2;
  102.         array2 = new User[size];
  103.        
  104.         for(int i=0;i<size;i++)
  105.         {
  106.            
  107.         }
  108.         return null;
  109.     }
  110. }
Add Comment
Please, Sign In to add comment