package com.example.Models.Program;

import java.util.ArrayDeque;
import java.util.Deque;

public class GenericStack<T> implements IStack<T> {
    private Deque<T> stack;

    public GenericStack() {
        stack = new ArrayDeque<T>();
    }

    public Deque<T> getStack(){
        return stack;
    }

    public T pop() {
        return stack.pop();
    }

    public void push(T value) {
        stack.push(value);
    }

    public boolean isEmpty() {
        return stack.isEmpty();
    }

    public String toString() {
        var sb = new StringBuilder();
        for (var item : stack) {
            sb.append(item);
            sb.append("\n");
        }
        return sb.toString();
    }
    
}
