summaryrefslogtreecommitdiff
path: root/scala/kids.scala
diff options
context:
space:
mode:
authorGuillermo Ramos2012-05-08 17:41:55 +0200
committerGuillermo Ramos2012-05-08 17:41:55 +0200
commitbedac58408e4c6a701dd8065ed7a11277f5358e5 (patch)
tree7d136b49e25c536712429ffd05fe99c947865c61 /scala/kids.scala
parentb0ce25e6d3d77c18c958578fdbdae92654e46c93 (diff)
download7l-bedac58408e4c6a701dd8065ed7a11277f5358e5.tar.gz
[Scala] Día 3
Diffstat (limited to 'scala/kids.scala')
-rw-r--r--scala/kids.scala31
1 files changed, 31 insertions, 0 deletions
diff --git a/scala/kids.scala b/scala/kids.scala
new file mode 100644
index 0000000..590e742
--- /dev/null
+++ b/scala/kids.scala
@@ -0,0 +1,31 @@
+import scala.actors._
+import scala.actors.Actor._
+
+case object Poke
+case object Feed
+
+class Kid() extends Actor {
+ def act() {
+ loop {
+ react {
+ case Poke => {
+ println("Ow...")
+ println("Quit it...")
+ }
+ case Feed => {
+ println("Gurgle...")
+ println("Burp...")
+ }
+ }
+ }
+ }
+}
+
+val bart = new Kid().start
+val lisa = new Kid().start
+
+println("Ready to poke and feed...")
+bart ! Poke
+lisa ! Poke
+bart ! Feed
+lisa ! Feed