-
-
Save jbrains/34e8718cf773dade3b7bf28081e858b0 to your computer and use it in GitHub Desktop.
Revisions
-
jbrains revised this gist
Nov 28, 2016 . 2 changed files with 36 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ package ca.jbrains.pos; import java.io.IOException; import java.io.InputStreamReader; import java.net.InetAddress; import java.util.HashMap; public class PointOfSaleTerminal { public static void main(String[] args) throws IOException { final InputStreamReader commandSource = new InputStreamReader(System.in); final SanitizeTextCommand sanitizeCommand = new SanitizePointOfSaleCommand(); final InterpretCommand interpretCommand = new WarnAboutEmptyCommands( new SellOneItemController( new InMemoryCatalog( new HashMap<String, Price>() {{ put("8586013802135", Price.cents(1000)); put("12345", Price.cents(150)); }} ) )::onBarcode ); final CommandResponseFormat commandResponseFormat = CommandResponse::render; final DisplayText displayText = new UdpPostOffice( InetAddress.getLocalHost(), 5358, "US-ASCII" )::sendMessage; new StreamTextCommands() .streamCommandsFrom(commandSource) .flatMap(sanitizeCommand::apply) .map(interpretCommand::apply) .map(commandResponseFormat::apply) .forEach(displayText::apply); } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ -
CoryFoy created this gist
Nov 28, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ # TODO: Write sample implementation