Giter Club home page Giter Club logo

morse_translator's Introduction

Morse Translator

Setup

  • Fork this Repository
  • Clone YOUR fork
  • Compete the activity below
  • Push your solution to your fork
  • Submit a pull request from your repository to the turingschool-examples repository
    • Make sure to put your name in your PR!

Activity

Morse Code translates a character into a sequence of dots and dashes. For example, morse code translates the letter "a" to ".-". Your job is to write a program that can translate English words to Morse Code.

For this Activity, you will be adding to the provided MorseTranslator class. You can make any changes to the class you like. For your convenience, the MorseTranslator class includes a Hash with the translations of English characters, numbers, and spaces to Morse Code.

You should be using Test Driven Development when completing the following iterations.

You should be committing code every 20 minutes.

Iteration 1

Use TDD to add a method to the MorseTranslator class called translate that takes a String as an argument and returns a String of the translation to morse code. For this iteration, the translate method only needs to handle lower case letters and spaces.

A MorseTranslator should respond to the following interaction pattern:

  pry(main)> require './lib/morse_translator'
  #=> true

  pry(main)> morse_translator = MorseTranslator.new
  #=> #<MorseTranslator:0x007fa1ab98cac0>

  pry(main)> morse_translator.translate("hello world")
  #=> "......-...-..--- .-----.-..-..-.."

Iteration 2

Use TDD to update the MorseTranslator class's translate method to be able to translate upper case letters and numbers. An upper case letter should have the same translation as a lower case letter.

A MorseTranslator should respond to the following interaction pattern:

  pry(main)> require './lib/morse_translator'
  #=> true

  pry(main)> morse_translator = MorseTranslator.new
  #=> #<MorseTranslator:0x007fa1ab98cac0>

  pry(main)> morse_translator.translate("hello world")
  #=> "......-...-..--- .-----.-..-..-.."

  pry(main)> morse_translator.translate("Hello World")
  #=> "......-...-..--- .-----.-..-..-.."

  pry(main)> morse_translator.translate("There are 3 ships")
  #=> "-......-.. .-.-.. ...-- ..........--...."

Iteration 3

Use TDD to create a Message class with the following criteria:

  • A Message takes two arguments upon initialization
    • The first argument is the message text represented as a String containing upper and lower case letters, numbers, and spaces
    • The second argument is a MorseTranslator object
  • A Message has getter methods called text and translator for reading the arguments
  • A Message has a method called translation that takes no arguments and returns the text translated to Morse Code

A Message should respond to the following interaction pattern:

pry(main)> require './lib/message'
#=> true

pry(main)> require './lib/morse_translator'
#=> true

pry(main)> morse_translator = MorseTranslator.new
#=> #<MorseTranslator:0x00007f928008a3f8...>

pry(main)> message = Message.new("There are 3 ships", morse_translator)
#=> #<Message:0x00007f927f3f57a0...>

pry(main)> message.translation
#=> "-......-.. .-.-.. ...-- ..........--...."

Iteration 4

Update your MorseTranslator class so that it responds to the following interaction pattern:

  pry(main)> morse_translator = MorseTranslator.new
  #=> #<MorseTranslator:0x007fa1ab98cac0...>

  pry(main)> morse_translator.morse_to_eng(".... . .-.. .-.. ---  .-- --- .-. .-.. -..")
  #=> "hello world"

morse_translator's People

Contributors

prestonjarnagin avatar brianzanti avatar

Watchers

James Cloos avatar  avatar

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.