Skip to content

Instantly share code, notes, and snippets.

@jbrains
Created April 30, 2019 13:32
Show Gist options
  • Save jbrains/47e8738bfd87851d0cd8c6041be0f86b to your computer and use it in GitHub Desktop.
Save jbrains/47e8738bfd87851d0cd8c6041be0f86b to your computer and use it in GitHub Desktop.

Revisions

  1. jbrains created this gist Apr 30, 2019.
    29 changes: 29 additions & 0 deletions VirtualPointOfSaleTerminal.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    package ca.jbrains.pos;

    import ca.jbrains.pos.ui.TextProcessorAndCommandInterpreter;
    import ca.jbrains.pos.ui.lcd.UdpPostOffice;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.HashMap;

    public class VirtualPointOfSaleTerminal {
    public static void main(String[] args) throws IOException {
    TextProcessorAndCommandInterpreter textProcessorAndCommandInterpreter = new TextProcessorAndCommandInterpreter(
    new SaleController(
    new InMemoryCatalog(
    new HashMap<String, Price>() {{
    put("12345", Price.cents(795));
    put("23456", Price.cents(1250));
    put("036000216066", Price.cents(379));
    }}
    ),
    new EnglishLanguageTextDisplay(
    new UdpPostOffice("localhost", 5358, "UTF-8"))
    )
    );

    textProcessorAndCommandInterpreter.process(
    new InputStreamReader(System.in)
    ):
    }
    }