package edu.vtc.clacky;

import java.util.ArrayList;

public class StackOperations {
    
    /**
     * Duplicates the item at position 0 in 'stack' so that it also appears in position 1. All
     * other items are moved up. For example if the stack contains 10 11 12 13 14 a call to
     * dup(stack) produces 10 10 11 12 13 14.
     * 
     * If the stack is empty there is no effect.
     * 
     * @param stack The stack to manipulate.
     */
    public static void dup(ArrayList<Integer> stack)
    {
        
    }
    
    
    /**
     * Duplicates the items at positions 0 to n-1 in 'stack.' All other items are moved up. For
     * example if the stack contains 10 11 12 13 14 a call to dup(stack, 3) produces 10 11 12
     * 10 11 12 13 14.
     * 
     * If 'n' is larger than the stack size, the stack is first extended with a suitable number
     * of zeros.
     * 
     * @param stack The stack to manipulate.
     * @param n The number of stack positions to duplicate.
     */
    public static void dup(ArrayList<Integer> stack, int n)
    {
        
    }
    
    
    /**
     * Copies the item at position 'n' to position 0 and moves all items up. For example if the
     * stack contains 10 11 12 13 14 a call to pick(stack, 3) produces 13 10 11 12 13 14.
     * 
     * If 'n' is off the end of the stack, the stack is first extended with a suitable number
     * of zeros.
     * 
     * @param stack The stack to manipulate.
     * @param n The position of the item to be picked.
     */
    public static void pick(ArrayList<Integer> stack, int n)
    {
        
    }

    
    /**
     * The item at position 'distance' in 'stack' is moved to position 0. All items originally
     * in the range [0, 'distance') are moved up one place. For example if the stack contains
     * 10 11 12 13 14 a call to rollUp(stack, 3) produces 13 10 11 12 14.
     * 
     * If position 'distance' is off the end of the stack, zeros are first added as appropriate
     * to extend the stack to position 'distance.'
     *   
     * @param stack The stack to manipulate.
     * @param distance The position of the item to be brought into stack position 0.
     */
    public static void rollUp(ArrayList<Integer> stack, int distance)
    {
        
    }
    
    
    /**
     * The item at position 0 in 'stack' is moved to position 'distance.' All items originally
     * in the range (0, 'distance'] are moved down one place. For example if the stack contains
     * 10 11 12 13 14 a call to rollDown(stack, 3) produces 11 12 13 10 14.
     * 
     * If position 'distance' is off the end of the stack, zeros are first added as appropriate
     * to extend the stack to position 'distance.'
     * 
     * @param stack The stack to manipulate.
     * @param distance The position where the item at stack position 0 will be placed.
     */
    public static void rollDown(ArrayList<Integer> stack, int distance)
    {
        
    }
    
    
    /**
     * This method creates a populated ArrayList for purposes of testing.
     * 
     * @param elementCount The number of elements to create in the returned list.
     * @return A test list.
     */
    private static ArrayList<Integer> createTestList(int elementCount)
    {
        ArrayList<Integer> result = new ArrayList<>();
        
        for (int i = 0; i < elementCount; ++i) {
            result.add(10 + i);
        }
        return result;
    }
    
   
    // The main method...
    public static void main(String[] args)
    {
        ArrayList<Integer> stack;
        
        stack = createTestList(5);
        System.out.println("Testing dup(stack)...");
        System.out.println("    Before: " + stack);
        dup(stack);
        System.out.println("    After : " + stack);
        
        stack = createTestList(5);
        System.out.println("");
        System.out.println("Testing dup(stack, 3)...");
        System.out.println("    Before: " + stack);
        dup(stack, 3);
        System.out.println("    After : " + stack);
        
        // ... and similarly for the other methods.
    }
    
}
