CSE 250 - Spring 2009 - Banner
UB -
University at Buffalo, The State University of New York Computer Science and Engineering
  • CSE 250 - Spring 2009
CSE 250 - Spring 2009 - Navigation
CSE 250 - Spring 2009 - Announcements

In-lab Exercise 2
Last modified: February 15 2009 03:35:36 PM

CSE 250 - Spring 2009 - In-lab Exercise 2

This exercise must be completed individually.

Pig Latin translator

You are responsible for writing two functions and a user interface for this assignment. The two functions should have a header file named PigLatin.h and a source file named PigLatin.cpp. Their functionalities are described below.

string toPigLatin(string word)

This function takes in a word - a word is sequence of characters with no whitespace characters, no numbers, and no special characters (only the 26 letters of the English alphabet). If a word does not meet this criteria, throw an exception. Otherwise, translate the word into pig latin using the following rules:

  • If a word begins with a vowel, simply append the letters "ay" to the end of the word. Exception: if the word already ends in ay (away), nothing is done.
  • If a word begins with a consonant, move all consonants preceeding the first vowel to the end of the word and append "ay" to the end. (Example: straight becomes aightstray)

 

string breakUpAndTranslate(string text)

This function takes in a string of text and breaks it up into words so that the words can be passed into the function above and translated. It forms the new Pig Latin string and returns it to the caller. Delimiters that separate words are any whitespace and the special characters .,?!;:@#$%^&*()-_+={}[]|\"<>/~` Numbers should also not be included in words. All special characters should be placed back in the pig latin string in the same places they were before the translation. The single apostrophe is an exception because of the way it is used in English. Since the rules for this would be hard to define, you can assume for this exercise that your input strings will not contain the single apostrophe.

 

User Interface

The user interface for this assignment should prompt the user for the string they would like translated and provide the translation to pig latin of the entered string. There should be a way for the user to quit the program by doing something with the user interface to tell the program to end. The user interface should be created in a file named Exercise2Driver.cpp.

The names of your methods must follow the above exactly. To test your code, we will be writing a testing program that expects this interface. If you code doesn't work with our testing program, you will receive no credit.


What to submit

You should ensure that all your files are in a directory named Exercise2. Zip up your Exercise2 directory to make a file called Exercise2.zip. You should submit the file Exercise2.zip using the electronic submission command submit_cse250.


Due Date

The files that need to be submitted are due to be turned in by 11:59:59pm on Monday, February 9th. Note, there will be a new assignment next week and the week after, so plan your work on this assignment accordingly.

CSE 250 - Spring 2009 - Footer

Page maintained by Adrienne Decker

Contact: adrienne@cse.buffalo.edu | 130 Bell Hall | (716)645-3180 x 161