Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: src/tests/site/code/die.dart

Issue 83663005: added front page samples to testing, plus a couple of tweaks to front page and code lab (Closed) Base URL: https://github.com/dart-lang/dartlang.org.git@master
Patch Set: changed width of iframe for pirate badge app Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/tests/site/code/collections.dart ('k') | src/tests/site/code/futures.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 import 'dart:math' show Random; // Import a class from a library.
2
3 void main() { // This is where the app starts executing .
4 print(new Die(n: 12).roll()); // Print a new object's value. Chain met hod calls.
5 }
6
7 class Die { // Define a class.
8 static Random shaker = new Random(); // Define a class variable.
9 int sides, value; // Define instance variables.
10
11 String toString() => '$value'; // Define a method using shorthand syntax .
12
13 Die({int n: 6}) { // Define a constructor.
14 if (4 <= n && n <= 20) {
15 sides = n;
16 } else {
17 throw new ArgumentError(/* */); // Support for errors and exceptions.
18 }
19 }
20 int roll() { // Define an instance method.
21 return value = shaker.nextInt(sides); // Get a random number.
22 }
23 }
OLDNEW
« no previous file with comments | « src/tests/site/code/collections.dart ('k') | src/tests/site/code/futures.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698