Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: Understand the concept of method decomposition. Design and implement a Pig Latin translator using Java. Create a UML diagram to represent the class structure

Objective:
Understand the concept of method decomposition.
Design and implement a Pig Latin translator using Java.
Create a UML diagram to represent the class structure and interactions.
Instructions:
Design and implement a Pig Latin translator from scratch.
The translator should convert English sentences to Pig Latin using the following rules:
For words that begin with a vowel (a, e, i, o, u), add "yay" to the end of the
word. (eg
item itemvay)
For words that begin with consonants or consonant blends, move the leading
consonants to the end of the word and add "ay".(eg
book-- ookbav,
table-- abletax
chair airchay
Here are some of the consonant blends
(bl),(sc),(br),(sh),(ch)(sk),(cl),(sl),(cr),(sn),(dr),
(sm),(dw),(sp),(fl),(sq),(fr),(st),(gl),(sw),
(gr),(th),(kl),(tr),(ph),(tw),(pl),(wh),
(pr),(wr)
Ensure that the solution is decomposed into appropriate methods and classes.
Maintain the original case of the letters in the translated words.
You may use the following methods from the String class for your implementation:
charAt(int index): Returns the character at the specified index.
substring(int begin/ndex): Returns a new string that is a substring of this string.
substring(int beginlndex, int endindex): Returns a new string that is a substring
of this string.
startsWith(String prefix): Tests if this string starts with the specified prefix.
tolowerCase(): Converts all characters in the string to lowercase.Objective:
Understand the concept of method decomposition.
Design and implement a Pig Latin translator using Java.
Create a UML diagram to represent the class structure and interactions.
Instructions:
Design and implement a Pig Latin translator from scratch.
The translator should convert English sentences to Pig Latin using the following rules:
For words that begin with a vowel (a,e,4,0,u, add "yay" to the end of the
word. (eg
item iteroax)
For words that begin with consonants or consonant blends, move the leading
consonants to the end of the word and add "ay".(eg
book oakbay
table-- abletay
chair airchay
Here are some of the consonant blends
("bl"),("sc"),("br")("sh"),("ch")("sk"),("cl"),("sl"),("cr"),("s"),("dr"),
("sm"),("dV"),("s"),("ll"),("sq"),("fr"),("st"),("g,"),("sw"),
("gr"),("th"),("kl"),("tr"),("ph"),("tv"),("pl"),("wh"),
("pr"),("Wr"))
Ensure that the solution is decomposed into appropriate methods and classes.
Maintain the original case of the letters in the translated words.
You may use the following methods from the String class for your implementation:
charAt(int index): Returns the character at the specified index.
Iint begiplpdex): Returns a new string that is a substring of this string.
substringlint begiolddex, int endindex): Returns a new string that is a substring
of this string.
startsWith(String prefix): Tests if this string starts with the specified prefix.
tol-yerGse): Converts all characters in the string to lowercase.
snlit/String regex): Splits this string around matches of the given regular
expression.
You may also use the hasNext) method of the Scanner class to read individual words
from the sentence.
Implement edge case checks for:
Handling unknown characters gracefully
Empty strings or strings with only spaces.
Single-letter words (ask to enter a valid word)
After each translation, the user should be prompted whether they want to translate
another sentence or quit.
Tasks:
Task 1: Design the Classes and Methods.
Identify the classes and methods required to implement the Pig Latin translator.
Create a class diagram (UML) representing the design of your solution.
Task 2: Implement the Classes and Methods.
Write Java code to implement the classes and methods designed.
Ensure that the methods are properly decomposed and each performs a single,
clear function.
Task 3: Test the Pig Latin Translator.
Write a main method to read input sentences from the user and translate them
into Pig Latin.
Test the program with various sentences to ensure correctness.
Task 4: Handle Edge Cases.
Ensure the program handles edge cases as specified in the instructions.
Submission:
Submit the Java code for the Pig Latin translator.
Include the UML diagram in the document or as a separate file.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions