SHOW:
|
|
- or go back to the newest paste.
| 1 | - | int noOfWords = 0; |
| 1 | + | import java.util.*; |
| 2 | - | String [] input = new String[100]; |
| 2 | + | public class PirateTranslator |
| 3 | - | while(!Console.endOfFile()) |
| 3 | + | {
|
| 4 | public static void main(String [] args) | |
| 5 | - | input[noOfWords] = Console.readToken(); |
| 5 | + | |
| 6 | - | if (input[noOfWords] == "pardon" || input[noOfWords] == "excuse") |
| 6 | + | HashMap <String, Object> hashmap = new HashMap <String, Object>(); |
| 7 | - | input[noOfWords] += Console.readToken(); |
| 7 | + | hashmap.put("hello", "ahoy");
|
| 8 | - | noOfWords++; |
| 8 | + | hashmap.put("madam", "proud beauty");
|
| 9 | - | } // while |
| 9 | + | hashmap.put("hi", "yo-ho-ho");
|
| 10 | hashmap.put("pardon me", "avast");
| |
| 11 | - | for (int index = 0; index < noOfWords; index++) |
| 11 | + | hashmap.put("excuse me", "arrr");
|
| 12 | - | System.out.println((String) hashmap.get(input[index]) + " "); |
| 12 | + | hashmap.put("my", "me");
|
| 13 | hashmap.put("friend", "me bucko");
| |
| 14 | hashmap.put("sir", "matey");
| |
| 15 | hashmap.put("madam", "proud beauty");
| |
| 16 | hashmap.put("miss", "comely wench");
| |
| 17 | hashmap.put("stranger", "scurvy dog");
| |
| 18 | hashmap.put("where", "whar");
| |
| 19 | hashmap.put("is", "be");
| |
| 20 | hashmap.put("the", "th'");
| |
| 21 | hashmap.put("you", "ye");
| |
| 22 | hashmap.put("tell", "be tellin'");
| |
| 23 | hashmap.put("know", "be knowin'");
| |
| 24 | hashmap.put("how far", "how many leagues");
| |
| 25 | hashmap.put("old", "barnacle-covered");
| |
| 26 | hashmap.put("attractive", "comely");
| |
| 27 | hashmap.put("happy", "grog-filled");
| |
| 28 | hashmap.put("nearby", "broadside");
| |
| 29 | hashmap.put("restroom", "head");
| |
| 30 | hashmap.put("restaurant", "galley");
| |
| 31 | hashmap.put("hotel", "fleabag inn");
| |
| 32 | hashmap.put("pub", "Skull & Scuppers");
| |
| 33 | hashmap.put("bank", "buried treasure");
| |
| 34 | ||
| 35 | int noOfWords = 0; | |
| 36 | String [] input = new String[100]; | |
| 37 | while(!Console.endOfFile()) | |
| 38 | {
| |
| 39 | input[noOfWords] = Console.readToken(); | |
| 40 | if (input[noOfWords].equals("pardon")
| |
| 41 | || input[noOfWords].equals("excuse")
| |
| 42 | || input[noOfWords].equals("how"))
| |
| 43 | input[noOfWords] += " " + Console.readToken(); | |
| 44 | ||
| 45 | noOfWords++; | |
| 46 | } // while | |
| 47 | ||
| 48 | for (int index = 0; index < noOfWords; index++) | |
| 49 | System.out.print((String) hashmap.get(input[index]) + " "); | |
| 50 | ||
| 51 | System.out.println(); | |
| 52 | ||
| 53 | } | |
| 54 | } | |
| 55 | ||
| 56 |