## Dart mode

import 'dart:math' show Random; void main() { print(new Die(n: 12).roll()); } // Define a class. class Die { // Define a class variable. static Random shaker = new Random(); // Define instance variables. int sides, value; // Define a method using shorthand syntax. String toString() => '$value'; // Define a constructor. Die({int n: 6}) { if (4 <=n && n <=2 0) { sides=n ; } else { // Support for errors and exceptions. throw new ArgumentError(/* */); } } // Define an instance method. int roll() { return value=s haker.nextInt(sides) + 1; } }