Guest User

Untitled

a guest
Oct 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1.     import java.util.*;
  2.      
  3.      
  4.     public class Zbior<T>
  5.     {
  6.             public int liczba;
  7.             private T element;
  8.             private ArrayList<T> tab;
  9.            
  10.             public Zbior(T element)
  11.             {
  12.                     this.element = element;
  13.             }
  14.            
  15.             public Zbior (int liczba)
  16.             {
  17.                     this.liczba = liczba;
  18.                     tab = new ArrayList<T>();
  19.             }
  20.            
  21.             public T pobierzElement()
  22.             {
  23.                     return element;
  24.             }
  25.            
  26.             public void dodaj (int a)
  27.             {
  28.                     tab.add(a);
  29.             }
  30.            
  31.             public boolean pusty()
  32.             {
  33.                     if (tab.size()==0) return true;
  34.                     else return false;
  35.             }
  36.            
  37.             public int pierwszy()
  38.             {
  39.                     int a = tab.get(0);
  40.                     return a;
  41.             }
  42.            
  43.             public void usun_pierwszy()
  44.             {
  45.                     tab.remove(0);
  46.             }
  47.            
  48.            
  49.             public static void main(String[] args)
  50.             {
  51.                     Zbior<Integer> zb = new Zbior<Integer>(10);
  52.                     int j=0;
  53.                     for ( int i=0 ; i<5 ; ++i ) {
  54.                     j++;
  55.                     zb.dodaj(j);
  56.                     }
  57.                     while (!zb.pusty()) {
  58.                     System.out.println(zb.pierwszy());
  59.                     zb.usun_pierwszy();
  60.                     }
  61.      
  62.             }
  63.      
  64.     }
Add Comment
Please, Sign In to add comment