Question: Use Java USE java: Goals In this assignment you'll: (1) create your own class; (2) see how to generate new objects and interact with them
Use Java



USE java:
Goals In this assignment you'll: (1) create your own class; (2) see how to generate new objects and interact with them from code that lives outside of the class; (3) get some additional practice using the built in features of the Java API -- specifically methods belonging to Java's built in String class; (4) learn a pattern to obtain input from the keyboard. Set up Begin by launching Eclipse and starting a new Java project for your work. In this assignment, your code will consist of two classes: - PirateTrans1ator - SimpleLauncher The PirateTrans1ator class will encapsulate the logic to translate English sentences into Pirate-speech. The sirmpelauncher class will contain the main method and the associated logic that will allow you to type in sentences and then have them translated for you. In this assignment, I've written the SimpleLauncher class for you (below), and you can simply type it into Eclipse. import java. util. Scanner; oublic class SimpleLauncher \{ pub1ic static void main(String [] args) \{ PirateTranslator translator = new PirateTranslator (); Scanner userInput = new Scanner ( System in); String response; // userInput, hasNext () will return true unti1 // you type 'Control-D' on a mac, or Control-Z on // a windows machine. if that happens, we need // to break out of the loop and stop. while(userInput. hasNext()) \{ System out. println(translator. translate (userInput. nextLine())); 3 Implementing PirateTranslator Within your Eclipse/IntelliJ project, create a new Class called PirateTrans1ator. This class should have one public method with the following signature: public String translate(String input) blaggart". Below is a list of normal english words/phrases and their Pirate-speech counter parts. leagues", "barnacle-covered", "grog-filled", "be" Your translate method should accept strings with arbitrary capitalization, however, it can return translated strings that are all in lower case. three possibilities for affect: positive, negative, and none. negative, or none. end of the translation. Thus an input sentence "I adore you" would translate to "I adore ye 'tis like me pirate treasure!". Thus, for full credit: 1. Translate english phrases into their pirate-speech counterparts 2. Translate arbitrary capitalization on input, but return all lower case output 3. Detect the affect of input sentences and append metaphor appropriately Below is a sample trace from my program when I run simpleLauncher. Translations are in italics. > hello ahoy > hello friend ahoy me bucko > I adore you i adore ye 'tis like me pirate treasure! I hate you i hate ye 'tis like bein' food for the fish! where is my old boat? whar be me barnacle-covered boat? > pardon me sir, do you know where my old boat is? avast matey, do ye be knowin' whar me barnacle-covered boat be? Testing Your Code You can test your code interactively by running the SimpleLauncher. You should also submit to Autolab. Currently, our Autolab implementation will check: 1. If your translator works on the sentences in this description 2. If your translator works on a few other simple sentences 3. If your translator correctly applies affect 4. If your translator can handle input sentences with arbitrary capitalization
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
