summaryrefslogtreecommitdiff
path: root/docs/examples/actors/auction.scala
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/actors/auction.scala')
-rw-r--r--docs/examples/actors/auction.scala19
1 files changed, 10 insertions, 9 deletions
diff --git a/docs/examples/actors/auction.scala b/docs/examples/actors/auction.scala
index 513e9a6ad0..5bda010c57 100644
--- a/docs/examples/actors/auction.scala
+++ b/docs/examples/actors/auction.scala
@@ -1,6 +1,7 @@
package examples.actors
import java.util.Date
+
import scala.actors._
import scala.actors.Actor._
@@ -10,20 +11,20 @@ import scala.actors.Actor._
*/
trait AuctionMessage
-case class Offer(bid: int, client: Actor) extends AuctionMessage // make a bid
+case class Offer(bid: Int, client: Actor) extends AuctionMessage // make a bid
case class Inquire(client: Actor) extends AuctionMessage // inquire status
trait AuctionReply
-case class Status(asked: int, expiration: Date) // asked sum, expiration date
+case class Status(asked: Int, expiration: Date) // asked sum, expiration date
extends AuctionReply
case object BestOffer extends AuctionReply // yours is the best offer
-case class BeatenOffer(maxBid: int) extends AuctionReply // offer beaten by maxBid
+case class BeatenOffer(maxBid: Int) extends AuctionReply // offer beaten by maxBid
case class AuctionConcluded(seller: Actor, client: Actor) // auction concluded
extends AuctionReply
case object AuctionFailed extends AuctionReply // failed with no bids
case object AuctionOver extends AuctionReply // bidding is closed
-class AuctionActor(seller: Actor, minBid: int, closing: Date) extends Actor {
+class AuctionActor(seller: Actor, minBid: Int, closing: Date) extends Actor {
val timeToShutdown = 3000 // msec
val bidIncrement = 10
@@ -68,7 +69,7 @@ class AuctionActor(seller: Actor, minBid: int, closing: Date) extends Actor {
object auction {
- val random = new java.util.Random()
+ val random = new Random
val minBid = 100
val closing = new Date(new Date().getTime() + 4000)
@@ -76,11 +77,11 @@ object auction {
val seller = Actor.actor { }
val auction = new AuctionActor(seller, minBid, closing)
- def client(i: int, increment: int, top: int) = new Actor {
+ def client(i: Int, increment: Int, top: Int) = new Actor {
val name = "Client " + i
def log(msg: String) = Console.println(name + ": " + msg)
- var max: int = _
- var current: int = 0
+ var max: Int = _
+ var current: Int = 0
def act() {
log("started")
auction ! Inquire(this)
@@ -120,7 +121,7 @@ object auction {
}
}
- def main(args: Array[String]) = {
+ def main(args: Array[String]) {
seller.start()
auction.start()
client(1, 20, 200).start()