5 // Class which makes the event
6 public class Game : Object {
7 // Note the use of the signal keyword
8 public signal void score_change (int newScore, ref bool cancel);
18 if (_score != value) {
20 score_change (value, ref cancel);
28 // Class which handles the event
29 public class Referee : Object
31 public Game game { get; construct; }
33 public Referee (construct Game game) {
37 // Monitor when a score changes in the game
38 game.score_change += game_score_change;
41 // Notice how this method signature matches the score_change signal's signature
42 private void game_score_change (Game game, int new_score, ref bool cancel) {
44 stdout.printf ("Good Score\n");
47 stdout.printf ("No Score can be that high!\n");
52 // Class to test it all
53 public class GameTest : Object
55 public static void main () {
56 var game = new Game ();
57 var referee = new Referee (game);