Two errors in deaf Grandma - Pine
Was completing the pine exercise for Def Grandma and thought would try and take it a little further and abstract it to remove as much duplication as possible. 

Hope my logic with this isn't too bizzare just tried to separate things into functions. But now if I type 

    Bye

The program exits immediately without proceeding to the exitPlan function.
Any advice welcome.

    puts 'Say something nice to Grandma.'
    puts 'You may need to shout > '
    speak = gets.strip
    counter = 0
    
    def speaks(speak)
        if speak != 'Bye'
            talk()
        else
            exitPlan()
        end
    end
    
    def talk()
        if speak == speak.downcase
            puts 'Huh Speak up Sonny'
            counter -= 1 
        else
            year = rand(1930..1951)
            puts 'No not Since ' + year.to_s
            counter -= 1
        end
            if counter < 0 
                counter = 0 # don't want counter going below zero.
                end
            puts 'Say something nice to Grandma'
            speaks()
    end
    
    def exitPlan()
        counter += 1
        unless counter == 3
            puts 'Say something nice to Grandma'
            speaks()
        else
            puts 'good night Sonny'
        end
    end


Two errors in deaf Grandma - Pine
===

Was completing the pine exercise for Def Grandma and thought would try and take it a little further and abstract it to remove as much duplication as possible. 

Hope my logic with this isn't too bizzare just tried to separate things into functions. But now if I type 

    Bye

The program exits immediately without proceeding to the exitPlan function.
Any advice welcome.

    puts 'Say something nice to Grandma.'
    puts 'You may need to shout > '
    speak = gets.strip
    counter = 0
    
    def speaks(speak)
        if speak != 'Bye'
            talk()
        else
            exitPlan()
        end
    end
    
    def talk()
        if speak == speak.downcase
            puts 'Huh Speak up Sonny'
            counter -= 1 
        else
            year = rand(1930..1951)
            puts 'No not Since ' + year.to_s
            counter -= 1
        end
            if counter < 0 
                counter = 0 # don't want counter going below zero.
                end
            puts 'Say something nice to Grandma'
            speaks()
    end
    
    def exitPlan()
        counter += 1
        unless counter == 3
            puts 'Say something nice to Grandma'
            speaks()
        else
            puts 'good night Sonny'
        end
    end

