OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE.md file. | |
4 | |
5 import dartino.*; | |
6 | |
7 class TodoController { | |
8 static void InteractWithService() { | |
9 TodoService.Setup(); | |
10 | |
11 TodoView view = new TodoView(); | |
12 view.showMenu(); | |
13 boolean should_terminate = false; | |
14 do { | |
15 String input = view.getInput(); | |
16 if (null == input) { | |
17 should_terminate = true; | |
18 break; | |
19 } | |
20 switch (input) { | |
21 case "q": | |
22 should_terminate = true; | |
23 break; | |
24 case "m": | |
25 view.showMenu(); | |
26 break; | |
27 case "l": | |
28 view.listTodoItems(); | |
29 break; | |
30 case "a": | |
31 view.addTodoItem(); | |
32 view.listTodoItems(); | |
33 break; | |
34 case "t": | |
35 view.toggleTodoItem(); | |
36 view.listTodoItems(); | |
37 break; | |
38 case "c": | |
39 view.clearDoneItems(); | |
40 view.listTodoItems(); | |
41 break; | |
42 case "d": | |
43 view.deleteItem(); | |
44 view.listTodoItems(); | |
45 break; | |
46 default: | |
47 view.showMenu(); | |
48 break; | |
49 } | |
50 } while (!should_terminate); | |
51 | |
52 TodoService.TearDown(); | |
53 } | |
54 } | |
OLD | NEW |