AuctionHouse1 Docs
Fall 2025
API

# DutchAuction

o1.auctionhouse.DutchAuction
class DutchAuction(val `description`: String, val `startingPrice`: Int, val `decrement`: Int, val `minimumPrice`: Int)

Each instance of the class `DutchAuction` represents an item that has been put up for sale in an electronic auction house. More specifically, the item is being sold in a so-called Dutch auction.

Each Dutch auction has a starting price for the item being sold. However, unlike in a typical (“English-style”) auction where the price goes up from the starting price, the price in a Dutch auction goes down until someone decides to purchase the item. Every day, the price of the item is decreased by a certain amount from the previous day’s price, and the first person who decides to buy the item gets it immediately at the current price.

Upon creation, a starting price and a minimum price are set for the auction. Every day, the method `advanceOneDay` must be called to update the auction status and to decrease the current price if nobody has bought the item yet. The price of the item will never drop below the preset minimum price. After the minimum price is reached, the auction will remain open (at the minimum price) for a further three days. If nobody still buys the item, the auction expires.

To summarize, a Dutch auction is always in one of these four stages:

- Decreasing price: The auction is open and the current price of the auction keeps dropping daily until the minimum price is reached or until someone buys the item.

- Stagnant: The auction is still open but its price no longer decreases, and instead stays at the minimum price.

- Expired: After the price of the auction has been stagnant at the minimum price for over three days (that is, three additional full days after reaching the minimum price), and still nobody has bought the item, the auction expires and is no longer open.

- Bought: As soon as anyone chooses to buy the item, the auction ceases to be open.

Please note that the term “Dutch auction” has various meanings, one of which is used here. The kind of Dutch auctions that this class represents, are not identical to those featured on the trading website eBay, for instance.

## Parameters

decrement

  the amount that is removed from the current price each day

description

  a short description of the item

minimumPrice

  the lowest possible price that the seller is willing to accept

startingPrice

  the initial price of the item

## Attributes

Graph
Supertypes
  class Object
  trait Matchable
  class Any

## Members list

### Value members

#### Concrete methods

def advanceOneDay(): Unit

Records one day as having passed. For a Dutch auction, this means that if the auction is still open, the current price of the auction is reduced by the preset decrement, but only until the minimum price of the auction. (If the price would go lower than the minimum, it only reaches the minimum instead.)

Records one day as having passed. For a Dutch auction, this means that if the auction is still open, the current price of the auction is reduced by the preset decrement, but only until the minimum price of the auction. (If the price would go lower than the minimum, it only reaches the minimum instead.)

If the auction was already at the minimum price to begin with, then the current price does not decrease at all; instead the auction object keeps track of how many days the price has remained stagnant at the minimum level. This will eventually lead to auction expiry when this method is called for the fourth time after the current price reached the minimum price.

## Attributes

See also

  isExpired

  isOpen

def buy(`buyer`: String): Boolean

Buys the item for the given customer. The auction becomes closed. This only works, however, if the auction 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 auction becomes closed. This only works, however, if the auction was open to begin with. The method returns `true` if the item was successfully bought, `false` if the purchase failed.

## Attributes

def buyer: Option[String]

Returns the winner of the auction. That is, returns the name of the person who bought the item, wrapped in an `Option`. `None` is returned if nobody has bought the item yet.

Returns the winner of the auction. That is, returns the name of the person who bought the item, wrapped in an `Option`. `None` is returned if nobody has bought the item yet.

## Attributes

def isExpired: Boolean

Determines if the auction has expired, that is, if it has ended without the item being sold. A Dutch auction expires if the price remains stagnant at the minimum price level for over three days without anyone buying the item (not counting the day when the price originally reached the minimum price).

Determines if the auction has expired, that is, if it has ended without the item being sold. A Dutch auction expires if the price remains stagnant at the minimum price level for over three days without anyone buying the item (not counting the day when the price originally reached the minimum price).

(Note: Being expired implies that the auction is also closed. However, not being expired does not guarantee that the auction is open. An auction closes when either it expires or someone buys the item.)

## Attributes

See also

  advanceOneDay

  isOpen

def isOpen: Boolean

Determines if the auction is open, that is, if the item can still be bought. A Dutch auction is always open if nobody has yet bought the item and the auction has not yet expired.

Determines if the auction is open, that is, if the item can still be bought. A Dutch auction is always open if nobody has yet bought the item and the auction has not yet expired.

## Attributes

See also

  isExpired

def price: Int

Returns the current price of the item, that is, the price that the item can be purchased for at the moment, assuming the auction is open. If the auction is not open, the actual sale price (if bought) or the minimum price (is expired) is returned.

Returns the current price of the item, that is, the price that the item can be purchased for at the moment, assuming the auction is open. If the auction is not open, the actual sale price (if bought) or the minimum price (is expired) is returned.

## Attributes

def priceRatio: Double

Returns the “price ratio” of the auction that describes the current “cheapness” of the item; the lower, the cheaper. The price ratio is the ratio of the current price to the starting price. For instance, if the current price is 500 and the starting price is 1000, the price ratio is 0.5.

Returns the “price ratio” of the auction that describes the current “cheapness” of the item; the lower, the cheaper. The price ratio is the ratio of the current price to the starting price. For instance, if the current price is 500 and the starting price is 1000, the price ratio is 0.5.

## Attributes

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
  Any

#### Concrete fields

val decrement: Int
val description: String
val minimumPrice: Int
val startingPrice: Int