Giter Site home page Giter Site logo

piglatin's Introduction

Pig Latin

Pig Latin is a language game where words are "translated" according to the following rules:

  1. For words that are all consonants, simply add "ay" to the end of the word. Thus, "try" becomes "tryay".
  2. For words that begin with vowels, simply add "way" to the end of the word. Thus, "a" becomes "away"; "at" becomes "atway"; "ermine" becomes "ermineway."
  3. For words beginning with "qu," move the "qu" to the end of the word and add ay. Thus "question" becomes "estionquay".
  4. For words that begin with consonants, move the leading consonant(s) to the end of the word and add "ay." Thus, "ball" becomes "allbay"; "button" becomes "uttonbay"; "star" becomes "arstay"; "three" becomes "eethray";

Note that this assignment does not use graphics. Just like Old MacDonald and the Google Billboard, you will push to the master branch, not gh-pages

Suggested steps to complete this assignment

  1. Fork and clone down this repository.
  2. Run the program. You should see the following output:
    there are 8 lines
    beastay
    doughay
    happyay
    questionay
    staray
    threeay
    eagleay
    tryay
  3. You need to finish the two methods findFirstVowel and pigLatin so that the program will correctly translate the words into Pig Latin.
  4. Start by completing the custom codingbat problem int findFirstVowel(String sWord). It returns the position of the first 'a', 'e', 'i', 'o' or 'u'. If the word contains no vowels (like "try"), the method should return -1.
  5. Now, modify the pigLatin() method to implement all four rules of pig latin shown above. Rule 1 has already been implemented for you. When you've implemented all four rules correctly, the output should be:
    eastbay
    oughday
    appyhay
    estionquay
    arstay
    eethray
    eagleway
    tryay
  6. Submit the URL of your finished PigLatin repository to the school loop drop box.

Comparing letters of a String

There are two ways to compare one letter of a String, 'charAt' and 'substring':
sWord.charAt(0) == 'a' will test if the first letter of sWord is an 'a' sWord.substring(0,1).equals('a') will also test if the first letter of sWord is an 'a'

Extensions

If you have extra time, you could try to modify the program to convert entire passages of English to Pig Latin, like the one below.

The Lowell Hymn:

With heads bared we stand,
In tribute to thee,
Our Alma-Mater Lowell,
All true to thee we'll be.

Unfurled red and white,
None shall thee decry,
They name we love,
Oh Lowell High.

The Lowell Hymn in Pig Latin:

Ithway eadshay aredbay eway andstay,
Inway ibutetray otay eethay,
Ourway Alma-Materway Owelllay,
Allway uetray otay eethay e'llway ebay.

Unfurledway edray andway itewhay,
Onenay allshay eethay ecryday,
Eythay amenay eway ovelay,
Ohway Owelllay Ighhay.

piglatin's People

Contributors

simart avatar

Watchers

James Cloos 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.