This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FakeHtmlTextConverter extends HtmlTextConverter { | |
private String fullFilenameWithPath; | |
public FakeHtmlTextConverter(String fullFilenameWithPath) { | |
super(fullFilenameWithPath); | |
this.fullFilenameWithPath = fullFilenameWithPath; | |
} | |
@Override | |
protected Reader getReader() throws FileNotFoundException { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HtmlTextConverter { | |
private String fullFilenameWithPath; | |
public HtmlTextConverter(String fullFilenameWithPath) { | |
this.fullFilenameWithPath = fullFilenameWithPath; | |
} | |
public String convertToHtml() throws IOException { | |
HtmlFormatter formatter = getHtmlFormatter(getReader()); | |
formatter.convertToHtml(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String text = "Hello"; | |
ReaderFactory readerFactory = new StringReaderFactory(text); | |
HtmlTextConverter converter = new HtmlTextConverter(readerFactory); | |
assertThat(converter.convertToHtml(), is("Hello<br />")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HtmlTextConverter { | |
private ReaderFactory readerFactory; | |
public HtmlTextConverter(String fullFilenameWithPath) { | |
this(new FileReaderFactory(fullFilenameWithPath)); | |
} | |
public HtmlTextConverter(ReaderFactory readerFactory) { | |
this.readerFactory = readerFactory; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HtmlTextConverter | |
{ | |
private String fullFilenameWithPath; | |
public HtmlTextConverter(String fullFilenameWithPath) { this.fullFilenameWithPath = fullFilenameWithPath; } | |
public String convertToHtml() throws IOException { | |
BufferedReader reader = new BufferedReader(new FileReader(fullFilenameWithPath)); | |
String line = reader.readLine(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Number implements Comparable<Number> { | |
private int arabic; | |
private String roman; | |
public Number(int arabicIn, String romanIn) { | |
arabic = arabicIn; | |
roman = romanIn; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RomanNumbers { | |
// LinkedHashMap allows the fetch of the items in the same order of the insert | |
private static Map<Integer, String> dictionary = new LinkedHashMap<>(); | |
static { | |
dictionary.put(50, "L"); | |
dictionary.put(40, "XL"); | |
dictionary.put(10, "X"); | |
dictionary.put(9, "IX"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String convertToRoman(int number) { | |
if(dictionary.containsKey(number)) | |
return dictionary.get(number); | |
String result = ""; | |
while(number >= 50){ | |
result += "L"; | |
number -= 50; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String convertToRoman(int number) { | |
if(dictionary.containsKey(number)) | |
return dictionary.get(number); | |
String result = ""; | |
if(number > 50){ | |
result += "L"; | |
return result + convertToRoman(number - 50); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Map<Integer, String> dictionary = new HashMap<>(); | |
static { | |
dictionary.put(1, "I"); | |
dictionary.put(4, "IV"); | |
}; | |
public String convertToRoman(int number) { | |
if(dictionary.containsKey(number)) | |
return dictionary.get(number); |