Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class a{
- private List<Integer> list;
- private boolean odd;
- private boolean deleted;
- public a a = this;
- public a () {
- list = new ArrayList<Integer>();
- odd = true;
- deleted = false;
- }
- private a(a otherA) {
- this.list = otherA.list;
- this.odd = !otherA.odd;
- this.deleted = otherA.deleted;
- }
- private a cloneA () {
- return new a(this);
- }
- public a a(int value) {
- a = cloneA();
- if (deleted) {
- list.add(0, value);
- deleted = false;
- }
- else
- list.add(value);
- return this;
- }
- public int a() {
- deleted = true;
- int temp;
- temp = list.remove(list.size()-1);
- return temp;
- }
- public String toString() {
- a = cloneA();
- List<Integer> temp = new ArrayList<Integer>(list);
- if (odd) {
- Collections.sort(temp);
- }
- return temp.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement