Computer Science 4957/5957 C# February 9, 2016 Homework 1 Due date: _________________ Purpose The purpose of this homework assignment is to gain some experience with a console applications in C#. Assignment First Step Create a class named PigLatin. The class should have a default constructor and a constructor that accepts a string parameter. It should have no attributes of its own, but it should use properties to represent the original string to be translated as well as counts and other values that might normally be private attributes of the class. The properties may be read-only, write-only, or read-write as appropriate. The class should have a public method named ToString that will return the Pig Latin translation of the original string input into the constructor or set using a property. The class may have other public (or private) methods as needed. The class should determine the number of word candidates and the number of words (see definitions below). It should have separate (probably private) methods to parse the string into an array (or List) of word candidates, to determine whether a word candidate is a word, to translate one word into Pig Latin, and so forth. Use the methods provided by the String class to avoid a brute force approach where possible. This class may do NO input or output. Rules The original string will be decomposed into word candidates that are separated by spaces. For example, if the original string is “ETSU won the game 38 – 10.” then the word candidates are ETSU, won, the, game, 38, -, 10.; note the period as part of the final word candidate. A word candidate is a word if all 3 of the following apply It is not null, empty, or blank It contains no non-letters such as digits, punctuation, or other special symbols It contains at least one vowel (a, e, i, o, u, or y). Note that a “word” need not actually be in the dictionary. For example, ETSU is considered a “word” by our definition. The ToString method should parse the string, converted to lower case, into an array of word candidates with no leading/trailing spaces in each candidate by invoking the appropriate methods. For each word candidate, if it is not a word, it remains unchanged. If the word candidate is a word, it is translated as follows. If its first vowel is in its first column and it is not a “y”, the translation is the original word followed by “yay”. If it starts with “y”, the translation is the rest of the word after the y followed by “yay”. If neither of the first two rules applies, the translation is the rest of the word starting with the first vowel followed by the part of the word preceding the first vowel followed by “ay”. Examples: string you are ball of try ingstray ouyay areyay allbay ofyay ytray ToString returns a string made up of the translations of all word candidates separated by spaces. For example, for the string “How are you”, ToString will return “owhay areyay ouyay”. Homework 1 - PigLatin Page 1 Computer Science 4957/5957 C# February 9, 2016 Homework 1 Due date: _________________ Second Step Name the driver program PigLatinDriver. Add code to the driver program that allows a user to enter one “phrase” at a time to be translated by the class. This action should be repeated until the user enters an empty string. One possible sample run might produce this output: Notes 1. Console colors such as in the example above can be set using the ForegroundColor and BackgroundColor properties of Console. 2. The ResetColors method may be used to set them back to original values. 3. The Title property of Console can be used to set a title for the console window. Make sure your assignment name and your name appear in the title for your output window. 4. Carefully observe the output above and be sure you understand why the results are as shown. 5. Each source code file in your project should begin with a block of comments including your name, course, section number, email address, and a brief description of the purpose of the file. 6. Use appropriate XML comments at the beginning of each method to document the method. 7. Make use of as many features of C# and Visual Studio as you can in completing this assignment since the purpose of the assignment is to become familiar and comfortable with them. Code snippets, properties, the debugger, regions, namespaces, optional/named parameters, and code refactoring are some features you should try. Submit Results Zip the entire folder containing your solution, project, source files, and so forth. Please delete the .exe files from the solution before zipping it, however, as the mail system will not allow an executable file to be transmitted. Give the resulting zipped file the name X957HW1yourname.zip where the “x” is either “4” or “5” depending on whether you are in the undergraduate or graduate section respectively. Submit the zipped file as an email attachment. Make sure one of the recipients is bailes@etsu.edu. Homework 1 - PigLatin Page 2