Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package o1.auctionhouse
- class FixedPriceSale(val description: String, val price: Int, duration: Int) {
- private var kesto = this.duration
- private var ostaja: Option[String] = None
- def daysLeft = kesto
- override def toString = this.description
- def buyer = this.ostaja
- def isExpired = (this.duration == 0)
- def isOpen = (buyer == None && isExpired == false)
- def advanceOneDay(): Unit =
- if (kesto > 0 && isOpen) kesto = kesto - 1
- def buy(asiakas: String): Boolean = {
- if (isOpen) {
- ostaja = Some(asiakas)
- return true
- } else {
- return false
- }
- }
- }
- /*buy "Buys the item for the given customer. The sale becomes closed. This only works, however, if the
- sale was open to begin with."*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement