Class OutputFormatter
Object
OutputFormatter
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addShopkeeperList
(Set<Item> set, StringBuilder builder) Adds a descriptive set of the items and their buy/sell price to the string builder.static boolean
compareItemDescription
(List<String> parsed, String adjectives, String name) For example "dusty grey-trimmed fur white cloak".static String
getDescriptionOfItem
(String adjectives, String noun, boolean with_a_or_an) get a description based on the adjectives and the noun.static String
getDescriptionOfMoney
(int aValue) Returns the amount of money in gold coins, silver coins and copper coins.static String
htmlEscaper
(String source) static Map
<ItemDefinition, Integer> Provides a map containing description of items and their amounts.static boolean
isVowel
(char aChar) Returns whether or not a character is a vowel.static String
startWithCapital
(String string) Changes a sentence to always start with a capital.
-
Method Details
-
startWithCapital
Changes a sentence to always start with a capital.- Parameters:
string
- the string to change, may be empty or null.- Returns:
- a new string, containing a capital for the first letter. If original is null, returns null. If original is empty string, returns empty string.
-
getDescriptionOfItem
get a description based on the adjectives and the noun.- Parameters:
adjectives
- String containing the adjectives.noun
- String containing the noun.with_a_or_an
- indicates if the word should include an a or an an.- Returns:
- String containing the description in the format: "an/a [adject1], [adject2], [adject3] [noun]".
-
isVowel
public static boolean isVowel(char aChar) Returns whether or not a character is a vowel.- Parameters:
aChar
- the character to check- Returns:
- boolean which is true if the character is a vowel.
-
getDescriptionOfMoney
Returns the amount of money in gold coins, silver coins and copper coins.- 1 silver = 10 copper
- 1 gold = 10 silver
- Parameters:
aValue
- the amount of money in copper coins.- Returns:
- String description of the amount of money, for example 320 will be translated as "3 gold coins, 2 silver coins". Returns "no money" if no money is present.
-
compareItemDescription
For example "dusty grey-trimmed fur white cloak".- Parameters:
parsed
- A list of all the words entered by the player, see the example.adjectives
- adjectives, in this case "dusty, grey-trimmed, fur, white".name
- the noun, in this case "cloak".- Returns:
- true if the item description matches.
-
addShopkeeperList
Adds a descriptive set of the items and their buy/sell price to the string builder.- Parameters:
set
- a set of items to be described.builder
- the builder to append to. Should not be null.
-
inventory
Provides a map containing description of items and their amounts.- Parameters:
set
-- Returns:
-
htmlEscaper
-