module CStack
    use CPath,Only:Path
    implicit none    
    public 
    
    type, public :: Stack
        type(Path) :: List
        contains
        procedure :: Clear => Clear 
        procedure :: Push => Push 
        procedure :: Pop => Pop 
        procedure :: DoesHave => DoesHave 
    end type Stack
    contains  
    
    subroutine Clear(this)
        implicit none
        class(Stack), intent(inout) :: this
        call this%List%MakeNull()
    end subroutine
    
    subroutine Push(this, value)
        implicit none
        class(Stack), intent(inout) :: this
        integer, intent(in) :: value
        call this%List%Add(value)
    end subroutine
    
    subroutine Pop(this)
        implicit none
        class(Stack), intent(inout) :: this
        call this%List%Remove(this%List%Length())  
    end subroutine
    
    logical function DoesHave(this, value) 
        implicit none
        class(Stack), intent(in) :: this
        integer, intent(in) :: value
        DoesHave = this%List%Find(value)
    end function
    
end module CStack