Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. package o1.auctionhouse
  2.  
  3. class FixedPriceSale(val description: String, val price: Int, duration: Int) {
  4.  
  5. private var kesto = this.duration
  6. private var ostaja: Option[String] = None
  7.  
  8.  
  9. def daysLeft = kesto
  10.  
  11. override def toString = this.description
  12.  
  13. def buyer = this.ostaja
  14.  
  15. def isExpired = (this.duration == 0)
  16.  
  17. def isOpen = (buyer == None && isExpired == false)
  18.  
  19. def advanceOneDay(): Unit =
  20. if (kesto > 0 && isOpen) kesto = kesto - 1
  21.  
  22. def buy(asiakas: String): Boolean = {
  23. if (isOpen) {
  24. ostaja = Some(asiakas)
  25. return true
  26. } else {
  27. return false
  28. }
  29. }
  30.  
  31. }
  32.  
  33. /*buy "Buys the item for the given customer. The sale becomes closed. This only works, however, if the
  34. sale was open to begin with."*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement