Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.NoSuchElementException;
  3.  
  4. public class FIFO implements Queue {
  5.     ArrayList Jens = new ArrayList();
  6.     private int störstaJens;
  7.    
  8.     public FIFO() {
  9.         störstaJens = 0;
  10.     }
  11.    
  12.    
  13.     public void add(Object arg0) {
  14.         Jens.add(arg0);
  15.         if(Jens.size() > störstaJens)
  16.         {
  17.             störstaJens = Jens.size();
  18.         }
  19.     }
  20.  
  21.     public Object first() throws NoSuchElementException {
  22.         if(Jens.size() < 0)
  23.         {
  24.             throw new NoSuchElementException();
  25.         }
  26.         return Jens.get(0);
  27.     }
  28.  
  29.     public boolean isEmpty() {
  30.         return Jens.isEmpty();
  31.     }
  32.  
  33.     public int maxSize() {
  34.         return störstaJens;
  35.     }
  36.  
  37.     public void removeFirst() throws NoSuchElementException {
  38.         if(Jens.size() > 0)
  39.         {
  40.         Jens.remove(0);
  41.         }
  42.         else
  43.         {
  44.             throw new NoSuchElementException();
  45.         }
  46.     }
  47.  
  48.     public int size() {
  49.         return Jens.size();
  50.     }
  51.  
  52.     public String toString() {
  53.         return "";
  54.     }
  55.    
  56.     public boolean equals(Object f) {
  57.        
  58.         if(f instanceof FIFO)
  59.             {
  60.             if(this.size() == ((FIFO) f).size())
  61.                 {
  62.                 for(int i = 0; i <= Jens.size(); i++)
  63.                     {
  64.                     if(this.Jens.get(i) != null && ((FIFO) f).Jens.get(i) != null)
  65.                         {
  66.                         System.out.println("Hax!");
  67.                         }
  68.                     }
  69.                 }
  70.             {
  71.             return true;
  72.             }
  73.        
  74.         }
  75.         return false;
  76.     }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement