AuctionHouse2 Docs
Fall 2025
API

# FixedPriceSale

o1.auctionhouse.FixedPriceSale
class FixedPriceSale(`description`: String, val `price`: Int, `duration`: Int) extends ItemForSale, InstantPurchase

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.

## Parameters

description

  a short description of the item

duration

  the maximum number of days the sale will remain open

price

  the price the item is being sold for

## Attributes

Graph
Supertypes
  trait InstantPurchase
  trait ItemForSale
  class Object
  trait Matchable
  class Any

## Members list

### Value members

#### Concrete methods

def advanceOneDay(): Unit

Records one day as having passed. In practice, what this means is that the item becomes one day closer to expiring, assuming the item is open for purchase (as per isOpen) to begin with. This method does nothing if the item has already been bought or if the sale has expired.

Records one day as having passed. In practice, what this means is that the item becomes one day closer to expiring, assuming the item is open for purchase (as per isOpen) to begin with. This method does nothing if the item has already been bought or if the sale has expired.

## Attributes

def daysLeft: Int

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.

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.

## Attributes

def isExpired: Boolean

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`.

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`.

## Attributes

#### Inherited methods

def buy(`buyer`: String): Boolean

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.

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.

## Attributes

Inherited from:
  InstantPurchase

def buyer: Option[String]

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

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

## Attributes

Inherited from:
  InstantPurchase

def isOpen: Boolean

Determines if the sale is open, that is, if the item can still be bought. An item like this is always open if nobody has yet bought it and the opportunity to buy it has not yet expired.

Determines if the sale is open, that is, if the item can still be bought. An item like this is always open if nobody has yet bought it and the opportunity to buy it has not yet expired.

## Attributes

Inherited from:
  InstantPurchase

override def toString: String

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

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

## Attributes

Definition Classes
  ItemForSale -> Any
Inherited from:
  ItemForSale

#### Concrete fields

val price: Int

Returns the current price of the item, that is, the price that the item is selling for at the moment. If the item is not open, the sale price (if bought) or closing price (if expired) is returned.

Returns the current price of the item, that is, the price that the item is selling for at the moment. If the item is not open, the sale price (if bought) or closing price (if expired) is returned.

## Attributes