File tree Expand file tree Collapse file tree
calculator/src/main/java/com/wonu606 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com .wonu606 ;
22
3+ import com .wonu606 .app .App ;
4+ import com .wonu606 .calculator .CalculatorApp ;
5+ import com .wonu606 .io .Input ;
6+ import com .wonu606 .io .Print ;
7+ import java .io .IOException ;
8+
39public class Main {
410
511 public static void main (String [] args ) {
6- System .out .println ("Hello world!" );
12+ Input input ;
13+ Print printer ;
14+
15+ CalculatorApp app = new CalculatorApp ();
16+ try {
17+ runApp (app , input , printer );
18+ } catch (Exception exception ) {
19+ printer .print (exception .getMessage ());
20+ } finally {
21+ input .tearDown ();
22+ printer .tearDown ();
23+ }
24+ }
25+
26+ private static void runApp (App app , Input input , Print printer ) throws IOException {
27+ app .execute (input , printer );
728 }
8- }
29+ }
Original file line number Diff line number Diff line change 1+ package com .wonu606 .app ;
2+
3+ import com .wonu606 .io .Input ;
4+ import com .wonu606 .io .Print ;
5+ import java .io .IOException ;
6+
7+ public interface App {
8+
9+ void execute (Input input , Print printer ) throws IOException ;
10+ }
Original file line number Diff line number Diff line change 1+ package com .wonu606 .calculator ;
2+
3+ import com .wonu606 .app .App ;
4+ import com .wonu606 .io .Input ;
5+ import com .wonu606 .io .Print ;
6+ import java .io .IOException ;
7+
8+ public class CalculatorApp implements App {
9+
10+ Input input ;
11+ Print printer ;
12+
13+ public void execute (Input input , Print printer ) throws IOException {
14+ this .input = input ;
15+ this .printer = printer ;
16+
17+ while (true ) {
18+ String selection = input .getInput ();
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ package com .wonu606 .io ;
2+
3+ import java .io .IOException ;
4+
5+ public interface Input {
6+
7+ String getInput () throws IOException ;
8+
9+ void tearDown ();
10+ }
Original file line number Diff line number Diff line change 1+ package com .wonu606 .io ;
2+
3+ public interface Print {
4+
5+ void print (String message );
6+
7+ void print (int number );
8+
9+ void tearDown ();
10+ }
You can’t perform that action at this time.
0 commit comments