diff options
author | Martin Odersky <odersky@gmail.com> | 2003-03-31 08:29:52 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2003-03-31 08:29:52 +0000 |
commit | efd06d74f1621351c70456478b07a4ace6a9a211 (patch) | |
tree | 01ac7505ed4f33582974d4519dc3e33d601614d2 /sources/examples | |
parent | 85c73ba918913361f925c23469c012096a93fb54 (diff) | |
download | scala-efd06d74f1621351c70456478b07a4ace6a9a211.tar.gz scala-efd06d74f1621351c70456478b07a4ace6a9a211.tar.bz2 scala-efd06d74f1621351c70456478b07a4ace6a9a211.zip |
*** empty log message ***
Diffstat (limited to 'sources/examples')
-rw-r--r-- | sources/examples/auction.scala | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/sources/examples/auction.scala b/sources/examples/auction.scala index e553752342..102892b4c6 100644 --- a/sources/examples/auction.scala +++ b/sources/examples/auction.scala @@ -11,18 +11,17 @@ case class trait AuctionReply; case class Status(asked: Int, expiration: Date), // asked sum, expiration date - BestOffer(), // yours is the best offer + BestOffer, // yours is the best offer BeatenOffer(maxBid: Int), // offer beaten by maxBid AuctionConcluded(seller: Actor, client: Actor), // auction concluded - AuctionFailed(), // failed with no bids - AuctionOver() extends AuctionReply; // bidding is closed + AuctionFailed, // failed with no bids + AuctionOver extends AuctionReply; // bidding is closed -class Auction(seller: Actor, minBid: Int, closing: Date) extends Actor() { +class Auction(seller: Actor, minBid: Int, closing: Date) extends Actor { val timeToShutdown = 36000000; // msec val bidIncrement = 10; - override def run() = execute; - def execute = { + override def run() = { var maxBid = minBid - bidIncrement; var maxBidder: Actor = _; var running = true; @@ -33,7 +32,7 @@ class Auction(seller: Actor, minBid: Int, closing: Date) extends Actor() { if (maxBid >= minBid) maxBidder send BeatenOffer(bid); maxBid = bid; maxBidder = client; - client send BestOffer(); + client send BestOffer; } else { client send BeatenOffer(maxBid); } @@ -41,17 +40,17 @@ class Auction(seller: Actor, minBid: Int, closing: Date) extends Actor() { case Inquire(client) => client send Status(maxBid, closing); - case TIMEOUT() => + case TIMEOUT => if (maxBid >= minBid) { val reply = AuctionConcluded(seller, maxBidder); maxBidder send reply; seller send reply; } else { - seller send AuctionFailed(); + seller send AuctionFailed; } receiveWithin(timeToShutdown) { - case Offer(_, client) => client send AuctionOver() - case TIMEOUT() => running = false; + case Offer(_, client) => client send AuctionOver + case TIMEOUT => running = false; } } } |