#2130 - Fixing unforunate naming in DiningHakkers

This commit is contained in:
Viktor Klang 2012-05-25 17:15:35 +02:00
parent dc17bba62f
commit 7cd1d38eb1
2 changed files with 6 additions and 10 deletions

View file

@ -131,17 +131,15 @@ class Hakker(name: String, left: ActorRef, right: ActorRef) extends Actor {
object DiningHakkers {
val system = ActorSystem()
def main(args: Array[String]): Unit = {
run
}
def main(args: Array[String]): Unit = run
def run {
//Create 5 chopsticks
val chopsticks = for (i 1 to 5) yield system.actorOf(Props[Chopstick], "Chopstick " + i)
val chopsticks = for (i 1 to 5) yield system.actorOf(Props[Chopstick], "Chopstick" + i)
//Create 5 awesome hakkers and assign them their left and right chopstick
val hakkers = for {
(name, i) List("Ghosh", "Bonér", "Klang", "Krasser", "Manie").zipWithIndex
(name, i) List("Ghosh", "Boner", "Klang", "Krasser", "Manie").zipWithIndex
} yield system.actorOf(Props(new Hakker(name, chopsticks(i), chopsticks((i + 1) % 5))))
//Signal all hakkers that they should start thinking, and watch the show

View file

@ -169,16 +169,14 @@ object DiningHakkersOnFsm {
val system = ActorSystem()
def main(args: Array[String]): Unit = {
run
}
def main(args: Array[String]): Unit = run
def run = {
// Create 5 chopsticks
val chopsticks = for (i 1 to 5) yield system.actorOf(Props[Chopstick], "Chopstick " + i)
val chopsticks = for (i 1 to 5) yield system.actorOf(Props[Chopstick], "Chopstick" + i)
// Create 5 awesome fsm hakkers and assign them their left and right chopstick
val hakkers = for {
(name, i) List("Ghosh", "Bonér", "Klang", "Krasser", "Manie").zipWithIndex
(name, i) List("Ghosh", "Boner", "Klang", "Krasser", "Manie").zipWithIndex
} yield system.actorOf(Props(new FSMHakker(name, chopsticks(i), chopsticks((i + 1) % 5))))
hakkers.foreach(_ ! Think)