Reading another person's code is an important element of learning to be a good programmer. (The other key element is writing lots of code!) The goal of this in-class exercise is to practice reading and critiquing another person's code.
Part 1 - Retrieve the code
Part 2 - Review the code
Read through the code until you feel you understand it.
Part 2 Questions:
Part 3 - Use and modify/extend the code
Part 3.1
Implement a simple Driver program that will take as input a word, a from language, and a to language and will translate the word from the from language to the to language using the API. Print the result at the command line. Your program will be run as follows:
java Driver -p word -f fromlang -t tolang
Sample output: finger in English translates to prst in Croatian.
Assume the classpath is set appropriately.
Part 3.2
You are now going to modify or extend the code to support a method that will accept as input a word, a from language, and an array of to languages and will return a HashMap of the results where the key is the language and the value is the translated string. The signature of your method will look as follows:
public static HashMap<String, String> execute(final String text, final Language from, final Language[] to) throws Exception {
You are free to use any approach you like to providing this functionality, including modifying existing methods, modifying existing classes, or writing new classes/methods. You should, however, be able to justify your new design.
Part 3 Questions:
All required questions can be found in the following document: https://docs.google.com/document/pub?id=1VTUXGWdJL_8xleUhzeLoJ-aG2CdXSuBduYia93_CqAs