#2130 - Fixing unforunate naming in DiningHakkers
This commit is contained in:
parent
dc17bba62f
commit
7cd1d38eb1
2 changed files with 6 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue