@@ -0,0 +1,2299 @@
+package ru.matevosyan;%0A%0Aimport java.util.NoSuchElementException;%0A%0A/**%0A * Stack class.%0A * Created on 23.05.2017.%0A * @author Matevosyan Vardan%0A * @version 1.0%0A */%0A%0Apublic class Stack%3CE%3E implements IStack%3CE%3E %7B%0A%0A    private Node%3CE%3E top;%0A    private int size = 0;%0A%0A    /**%0A     * Constructor.%0A     */%0A%0A    public Stack () %7B%0A%0A    %7D%0A%0A    /**%0A     * Create to add value to a list.%0A     * @param value is value that type which you declare in generics.%0A     */%0A%0A    @Override%0A    public E push(E value) %7B%0A        addElement(value);%0A        return value;%0A    %7D%0A%0A%0A    /**%0A     * Remove value from top passing index.%0A     * @return value that type specify in generic.%0A     */%0A%0A    @Override%0A    public E pop() %7B%0A        E element;%0A        Node%3CE%3E becomeTop;%0A        if (size == 0) %7B%0A            throw new NoSuchElementException(%22No such element%22);%0A        %7D else %7B%0A            element = peek();%0A%0A            becomeTop = top.next;%0A            top = becomeTop;%0A%0A%0A        %7D%0A%0A        return element;%0A    %7D%0A%0A%0A    /**%0A     * Create to get the last value from list.%0A     * @return value that type that was declare in generic diamonds.%0A     * @throws IllegalArgumentException if is not correct index size.%0A     * @throws ArrayIndexOutOfBoundsException if index is bigger than actual.%0A     */%0A%0A    @Override%0A    public E peek() throws IllegalArgumentException %7B%0A%0A        if (size == 0) %7B%0A            throw new NoSuchElementException(%22Noo such element%22);%0A        %7D else if (size %3C 0) %7B%0A            throw new IllegalArgumentException(%22illegal argument%22);%0A        %7D%0A%0A        return top.item;%0A    %7D%0A%0A    /**%0A     * linkLast assign LinkedList Node to the last Node in the list and if it is the first value assign as first too.%0A     * @param elementValue is value.%0A     */%0A%0A    private void addElement(E elementValue) %7B%0A        Node%3CE%3E topNode = top;%0A        Node%3CE%3E newNode = new Node%3C%3E(elementValue);%0A        top = newNode;%0A%0A        if (topNode != null) %7B%0A            newNode.next = topNode;%0A        %7D%0A%0A        size++;%0A    %7D%0A%0A    /**%0A     * Class Node describe Stack as LinkedList entry.%0A     * @param %3CE%3E parameter that defined when create an instance of a class.%0A     */%0A%0A    private static class Node%3CE%3E %7B%0A        E item;%0A        Node%3CE%3E next;%0A%0A        Node(E element) %7B%0A            this.item = element;%0A        %7D%0A    %7D%0A%0A%7D

add Stack.java