OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of calcui; | 5 part of calcui; |
6 | 6 |
7 class Tape { | 7 class Tape { |
8 static const int OP_NOOP = 0; | 8 static const int OP_NOOP = 0; |
9 static const int OP_PLUS = 1; | 9 static const int OP_PLUS = 1; |
10 static const int OP_MINUS = 2; | 10 static const int OP_MINUS = 2; |
11 static const int OP_MULTI = 3; | 11 static const int OP_MULTI = 3; |
12 static const int OP_DIV = 4; | 12 static const int OP_DIV = 4; |
13 static const int OP_EQUAL = 5; | 13 static const int OP_EQUAL = 5; |
14 static const int OP_CLEAR = 6; | 14 static const int OP_CLEAR = 6; |
15 | 15 |
16 Tape() { | 16 Tape() { |
17 clearTape(); | 17 clearTape(); |
18 } | 18 } |
19 | 19 |
20 void addToTape(int op, String number) { | 20 void addToTape(int op, String number) { |
21 double displayTotal; | 21 double displayTotal; |
22 double numberAsValue; | 22 double numberAsValue; |
23 | 23 |
24 if (number != "." && number != "-" && number != "-.") { | 24 if (number != "." && number != "-" && number != "-.") { |
25 try { | 25 try { |
26 numberAsValue = Math.parseDouble(number.length == 0 ? "0" : number); | 26 numberAsValue = double.parse(number.length == 0 ? "0" : number); |
27 } on FormatException catch (e) { | 27 } on FormatException catch (e) { |
28 displayError(e.toString()); | 28 displayError(e.toString()); |
29 return; | 29 return; |
30 } | 30 } |
31 } else { | 31 } else { |
32 // Display just the . | 32 // Display just the . |
33 displayTotal = total; | 33 displayTotal = total; |
34 numberAsValue = 0.0; | 34 numberAsValue = 0.0; |
35 } | 35 } |
36 | 36 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 DivElement get activeInput => window.document.query("#activeInput"); | 237 DivElement get activeInput => window.document.query("#activeInput"); |
238 DivElement get activeTotal => window.document.query("#activeTotal"); | 238 DivElement get activeTotal => window.document.query("#activeTotal"); |
239 | 239 |
240 void clear() { | 240 void clear() { |
241 final element = new Element.tag('div'); | 241 final element = new Element.tag('div'); |
242 element.innerHtml = tapeUI.clearCalculation(); | 242 element.innerHtml = tapeUI.clearCalculation(); |
243 tapeUI.tape.children.add(element.children[0]); | 243 tapeUI.tape.children.add(element.children[0]); |
244 } | 244 } |
245 } | 245 } |
OLD | NEW |