Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. public class a{
  2.     private List<Integer> list;
  3.     private boolean odd;
  4.     private boolean deleted;
  5.     public a a = this;
  6.  
  7.     public a () {
  8.         list = new ArrayList<Integer>();
  9.         odd = true;
  10.         deleted = false;
  11.     }
  12.  
  13.     private a(a otherA) {
  14.         this.list = otherA.list;
  15.         this.odd = !otherA.odd;
  16.         this.deleted = otherA.deleted;
  17.     }
  18.  
  19.     private a cloneA () {
  20.         return new a(this);
  21.     }
  22.  
  23.     public a a(int value) {
  24.         a = cloneA();
  25.  
  26.         if (deleted) {
  27.             list.add(0, value);
  28.             deleted = false;
  29.         }
  30.         else
  31.             list.add(value);
  32.  
  33.         return this;
  34.     }
  35.  
  36.     public int a() {
  37.         deleted = true;
  38.         int temp;
  39.         temp = list.remove(list.size()-1);
  40.         return temp;
  41.     }
  42.  
  43.     public String toString() {
  44.         a = cloneA();
  45.         List<Integer> temp = new ArrayList<Integer>(list);
  46.         if (odd) {
  47.             Collections.sort(temp);
  48.         }
  49.         return temp.toString();
  50.     }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement