/home/caleb/ASDV-Java/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCard.java
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;

/**
 *
 * @author caleb
 */
public class WildCard {
    
    public static double max(GenericStack<? extends Number> stack) {
        double max = Double.MIN_VALUE;
        
        while (!stack.isEmpty()) {
            double value = stack.pop().doubleValue();
            if (value > max) {
                max = value;
            }
        }
        return max;
    }
    
    public static void main(String[] args) {
        GenericStack<Integer> intStack = new GenericStack<>();
        intStack.push(1);
        intStack.push(2);
        intStack.push(-2);
        System.out.print("The max number is " + max(intStack));
    }
}