Answered step by step
Verified Expert Solution
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 ayeg
book ookbav,
table abletax
chair airchay
Here are some of the consonant blends
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:
charAtint index: Returns the character at the specified index.
substringint beginndex: Returns a new string that is a substring of this string.
substringint beginlndex, int endindex: Returns a new string that is a substring
of this string.
startsWithString 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 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 ayeg
book oakbay
table abletay
chair airchay
Here are some of the consonant blends
blscbrshchskclslcrsdr
smdVsllsqfrstgsw
grthkltrphtvplwh
prWr
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:
charAtint 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.
startsWithString prefix: Tests if this string starts with the specified prefix.
tolyerGse: Converts all characters in the string to lowercase.
snlitString 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.
Singleletter 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 : 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 : 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 : 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 : 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started