Packages

c

o1.auctionhouse

FixedPriceSale

class FixedPriceSale extends AnyRef

Each instance of the class FixedPriceSale represents an item that has been put up for sale in an (imaginary) electronic auction house. Each such item is being sold for a fixed price (as opposed to being auctioned).

Apart from a price, each sale has a duration measured in days. Every day, the method advanceOneDay must be called. If the set number of days is reached without anyone buying the item, the sale expires and the item can no longer be bought.

This simple class does not store any seller information.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. FixedPriceSale
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new FixedPriceSale(description: String, price: Int, duration: Int)

    description

    a short description of the item

    price

    the price the item is being sold for

    duration

    the maximum number of days the sale will remain open

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def advanceOneDay(): Unit

    Records one day as having passed.

    Records one day as having passed. In practice, what this means is that the item becomes one day closer to expiring, unless it had already been bought in which case its state does not change.

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def buy(buyer: String): Boolean

    Buys the item for the given customer.

    Buys the item for the given customer. The sale now has a buyer (and is therefore no longer open). This only works, however, if the sale was open to begin with. The method returns true if the item was successfully bought, false if the purchase failed.

  7. def buyer: Option[String]

    Returns the buyer of the item, wrapped in an Option; None is returned if nobody has bought the item yet.

  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  9. def daysLeft: Int

    Returns the number of days remaining until the sale expires, unless someone buys the item.

    Returns the number of days remaining until the sale expires, unless someone buys the item. Initially, this number will be equal to the sale's duration, but will decrease with each passing day until it reaches zero or the item is bought.

    If the item has been already bought when this method is called, the number of days that were remaining at the time of purchase is returned. A return value of zero means that time has already run out to buy the item.

  10. val description: String
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  13. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  15. def isExpired: Boolean

    Determines whether the sale has expired.

    Determines whether the sale has expired. That is, determines whether the item is no longer available because time has run out. Note that if the item is unavailable because it was bought, it has not "expired" in this sense and this method will return false.

  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. def isOpen: Boolean

    Determines if the sale is open, that is, if the item can still be bought.

    Determines if the sale is open, that is, if the item can still be bought. A fixed-price sale is always open if nobody has yet bought the item and the sale has not yet expired.

  18. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  19. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  20. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  21. val price: Int
  22. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  23. def toString: String

    Returns a textual description of the item.

    Returns a textual description of the item. This text is the same as that returned by description.

    Definition Classes
    FixedPriceSale → AnyRef → Any
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  26. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from AnyRef

Inherited from Any

Ungrouped