Giter Site home page Giter Site logo

speaking-grandma's Introduction

Speak to Grandma

Objectives

  1. Control flow by using if, elsif, and else statements.
  2. Manipulate strings correctly.
  3. Evaluate the type case of a string.

Instructions

  1. Fork and clone this lab.
  2. Run the test suite using either the rspec or learn test command. You'll be coding your solution in grandma.rb.
  3. Write a speak_to_grandma method.
    • The method should take in a string argument containing a phrase and check to see if the phrase is written in all uppercase: if it isn't, then grandma can't hear you. She should then respond with (return) HUH?! SPEAK UP, SONNY!.
    • If you shout at her (i.e. call the method with a string argument containing a phrase that is all uppercase, then she can hear you (or at least she thinks that she can) and should respond with (return) NO, NOT SINCE 1938!.
    • However, if the phrase is exactly equal to: "I LOVE YOU GRANDMA!", then Grandma is very pleased and definitely hears that! and should repond with (return) I LOVE YOU TOO PUMPKIN!

A few things to think about:

  • You'll need to use if, elsif, and else statements to implement the logic of grandma responding with the appropriate string based on whether or not you speak to her in all uppercase, and/or whether you express your love.
  • Think about how we can check to see if a string is all uppercase. Reference the information below on manipulating strings.
  • Think about the response as a return value.

Manipulating Strings

One of the things you'll need to determine is if the argument that the speak_to_grandma method takes in is formatted a certain way (all uppercase).

There are many methods on the String class that manipulate strings. Let's take a look at a few:

"Hello World".upcase
#=> "HELLO WORLD"
"Hello World".reverse
#=> "dlroW olleH" 
"Hello World".downcase
#=> "hello world" 
"Hello World".capitalize
#=> "Hello world" 
"Hello World".swapcase
#=> "hELLO wORLD" 

Which one can we use to check that the argument string (i.e. what you're saying to Grandma) is all uppercase? You can use the comparison operator (==) to determine if the string you pass into your method call as an argument matches ("is equal to") that same string, but in uppercase form.

On that same note, we can also use the comparison operator to check and see if the string matches "I LOVE YOU GRANDMA!"

speaking-grandma's People

Contributors

ahimmelstoss avatar annjohn avatar aviflombaum avatar deniznida avatar fislabstest avatar fs-lms-test-bot avatar ihollander avatar kthffmn avatar lizbur10 avatar loganhasson avatar markedwardmurray avatar matbalez avatar maxwellbenton avatar mendelb avatar morgvanny avatar sarogers avatar sophiedebenedetto avatar timothylevi avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

speaking-grandma's Issues

Missing third case

The Readme.md indicates that if the value passed as an argument is "I LOVE YOU GRANDMA!", the return value should be "I LOVE YOU TOO PUMPKIN!". That functionality is missing from the grandma.rb file in the solution.

Make this lab a bit more challenging?

Can we add an elsif branch? Maybe by using the if branch to check for a specific phrase or (to practice scope) checking if the method has been called twice in a row with all caps?

introduce the idea of string transformation

in the readme of this lab there must be examples of different ways transform a string.

Setup the Mechanic

"Hello World".upcase
"Hello World".reverse
"Hello World". downcase
"Hello World".capitalize
"Hello World".swapcase

The Challenge

You're grandma can't hear and when you speak to her, if you aren't shouting, she doesn't hear you, etc...

My IDE has not been functioning

This is what appears everytime I try to use IDE. However; Sandbox has been working.
What do I need to do?

[23:10:10] ~
// ♥ learn open speaking-grandma-onl01-seng-pt-052620
Looking for lesson...
Forking lesson...
Cloning lesson...
There was a problem cloning this lesson. Retrying...
Opening the lesson…please do not refresh the pageCloning lesson...
There was a problem cloning this lesson. Retrying...
Cloning lesson...
Cloning lesson...
Cannot clone this lesson right now. Please try again.
[23:10:22] ~
// ♥ [23:10:23] ~
// ♥ learn open speaking-grandma-onl01-seng-pt-052620
Looking for lesson...
Forking lesson...
Cloning lesson...
There was a problem cloning this lesson. Retrying...
Opening the lesson…please do not refresh the pageCloning lesson...
There was a problem cloning this lesson. Retrying...
Cloning lesson...
Cloning lesson...
Cannot clone this lesson right now. Please try again.
[23:10:32] ~
// ♥ [23:10:34] ~
// ♥ learn open speaking-grandma-onl01-seng-pt-052620
Looking for lesson...
Forking lesson...
Cloning lesson...
There was a problem cloning this lesson. Retrying...
Opening the lesson…please do not refresh the pageCloning lesson...
There was a problem cloning this lesson. Retrying...
Cloning lesson...
Cloning lesson...
Cannot clone this lesson right now. Please try again.
[23:10:44] ~
// ♥ [23:10:46] ~
// ♥ learn open speaking-grandma-onl01-seng-pt-052620
Looking for lesson...
Forking lesson...
Cloning lesson...
There was a problem cloning this lesson. Retrying...
Opening the lesson…please do not refresh the pageCloning lesson...
There was a problem cloning this lesson. Retrying...
Cloning lesson...
Cloning lesson...
Cannot clone this lesson right now. Please try again.
[23:10:56] ~
// ♥ [23:11:02] ~
// ♥ learn open speaking-grandma-onl01-seng-pt-052620
Looking for lesson...
Forking lesson...
Cloning lesson...
There was a problem cloning this lesson. Retrying...
Opening the lesson…please do not refresh the pageCloning lesson...
There was a problem cloning this lesson. Retrying...
Cloning lesson...
Cloning lesson...
Cannot clone this lesson right now. Please try again.
[23:11:12] ~
// ♥ [23:11:21] ~
// ♥ learn open speaking-grandma-onl01-seng-pt-052620
Looking for lesson...
Forking lesson...
Cloning lesson...
There was a problem cloning this lesson. Retrying...
Opening the lesson…please do not refresh the pageCloning lesson...
There was a problem cloning this lesson. Retrying...
Cloning lesson...
Unable to open the lesson…please move on to the next lessonCloning lesson...
Unable to open the lesson…please move on to the next lessonCannot clone this lesson right now. Please try again.
[23:11:30] ~
// ♥ Unable to open the lesson…please move on to the next lessonUnable to open the lesson…please move on to the next lesson[23:11:38] ~
// ♥ learn open speaking-grandma-onl01-seng-pt-052620
Looking for lesson...
Forking lesson...
Cloning lesson...
There was a problem cloning this lesson. Retrying...
Unable to open the lesson…please move on to the next lessonCloning lesson...
There was a problem cloning this lesson. Retrying...
Cloning lesson...
Cloning lesson...
Cannot clone this lesson right now. Please try again.
[23:11:48] ~
// ♥

Add in one more set of tests

Want to make sure they are checking for all upcase/downcase not just those specific strings so check for like "WHAT" and "hello"

Readme fixes

remove tags table, add objectives, instructions.

**We discuss string manipulation here but this belongs in it's own discussion earlier in the course. I suggested earlier moving Data Types readme to beginning of second unit or end of first unit. That would be a good place for discussion of string and string manipulation. Then, we could include a refresher here if we want.

fork didnt work after completion of lab

the fork never turned green even after success on the rest of the lab. hit the fork button in github and no luck. waited for over 12 hours for this to update and still not forked yet. I am out of ideas.

Consistency in 'speaking-grandma' lab and previous lesson

Hello! - Perhaps it was only , but I was a bit confused between how we were taught to output conditional statements in 'About Ruby conditionals' and its followup lab 'speaking-grandma'.

The original code I had written to solve for the lab was as follows:

def speak_to_grandma(phrase)
  if "#{phrase}" == "#{phrase}".upcase
    puts "NO, NOT SINCE 1938!"
  else
    puts "HUH?! SPEAK UP, SONNY!"
  end
end

Please note the puts in the above. When I would run the code in my terminal using ruby grandma.rb and try running the test manually (i.e copying and pasting the exact phrases directly from the grandma_spec.rb and running them as the method's argument), I'd get exactly the desired results. Because everything in the previous lesson required string output be prefaced with "puts" or "print", I thought this was necessary.

After nearly thirty minutes of trying to solve this, I finally tried it without the puts and as below:

def speak_to_grandma(phrase)
  if "#{phrase}" == "#{phrase}".upcase
    "NO, NOT SINCE 1938!"
  else
    "HUH?! SPEAK UP, SONNY!"
  end
end

This time it worked! (Yay!).

I'm just running this by you in case others are having similar issues between the examples in the previous lesson and the requirements to pass the test. I will definitely read the tests more carefully next time, as well.

Thanks and I hope this helps!

BeGreative

pull and pass aint working

i passed the local tests and submitted the pull request but it aint showing up on learn

UPDATE: it's working now

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.