AuctionHouse1 Docs
Fall 2025
API

# o1.auctionhouse

package o1.auctionhouse

## Members list

### Packages

package o1.auctionhouse.gui

### Type members

#### Classlikes

class AuctionHouse(val `name`: String)

The class `AuctionHouse` represents electronic auction houses. It provides methods for adding auctions and producing statistics about the items being sold, among other things.

The class `AuctionHouse` represents electronic auction houses. It provides methods for adding auctions and producing statistics about the items being sold, among other things.

This version of class `AuctionHouse` can only handle English-style auctions (of type `EnglishAuction`). Other ways of selling items are not supported.

## Parameters

name

  the name of the auction house

## Attributes

Supertypes
  class Object
  trait Matchable
  class Any

class Bid(val `bidder`: Option[String], val `limit`: Int)

The class `Bid` represents bids made for items up for auction in an electronic auction house. Each `Bid` object stores the name of the bidder — that is, the customer who made the bid — as well as the maximum amount the bidder is willing to pay for the item.

The class `Bid` represents bids made for items up for auction in an electronic auction house. Each `Bid` object stores the name of the bidder — that is, the customer who made the bid — as well as the maximum amount the bidder is willing to pay for the item.

A bid object may also be created that has no bidder at all. This is useful, because a `Bid` object with no bidder can now be used for representing the initial prices of auctions before any genuine bids have been made.

A bid object is immutable after creation.

## Parameters

bidder

  the name of the customer who made the bid, wrapped in an `Option`, or `None` if the object represents an initial price with no bidder

limit

  the maximum sum of money the bidder is willing to pay for the item

## Attributes

Supertypes
  class Object
  trait Matchable
  class Any

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

Supertypes
  class Object
  trait Matchable
  class Any

class EnglishAuction(val `description`: String, val `startingPrice`: Int, `duration`: Int)

The class EnglishAuction represents “normal”, “English-style” auctions in an electronic auction house. Each auction object represents an auction for a single item that has been put up for sale.

The class EnglishAuction represents “normal”, “English-style” auctions in an electronic auction house. Each auction object represents an auction for a single item that has been put up for sale.

Each English auction has a starting price for the item being sold. No bids lower than the starting price are accepted. The highest bidder wins the item at the end of the auction. If two bidders bid the same amount, the first bidder wins over the later one. Apart from this, the order in which bids are placed is not significant.

Upon creation, a duration (in days) is set for the auction. Every day, the method `advanceOneDay` must be called to update the auction status. Once the time limit is reached, the auction closes and the highest bid wins. If there were no bids made by this time, the auction closes anyway and is considered “expired”.

In a traditional non-electronic auction, all bidders are physically present, and it is very common for the same person to make multiple slightly increased bids during the course of the auction, which only lasts a relatively short time. The bidding system in an electronic “English auction” is different. When bidding, bidders indicate the maximum price that they are willing to pay for the item. Storing the maximum bid amount in the electronic auction house is convenient, as it allows bidders to indicate how far they are willing to go, without having to come back to the auction house service repeatedly to increase their bids.

Even if a bidder later wins the auction, they do not necessarily have to pay the full maximum price indicated when placing the bid. They only need to pay enough to beat the second highest bidder. Consider an example: Bidder A has bid a maximum of 100 for an item and Bidder B has bid 150, and the auction then closes. B wins the item and has to pay a price of 101 for it, just enough to beat A’s 100.

The maximum bid amount of the leading bidder is not publicly displayed. The program is intended to display only the current price of the auction and the minimum amount that new bidders must bid to stand any chance of winning. For instance, say Bidder A has placed a bid with a limit of 200 and Bidder B has placed a bid with a limit of 300. The current price of the auction is now 201. The minimum amount that new bidders must bid is 202 (good enough to beat 201). B’s limit of 300 will not become apparent to other bidders unless someone bids over 300, thereby becoming the leading bidder. (Not displaying the leading bidder’s limit is a sensible policy. Otherwise, bidders or sellers could raise the price without any intention of actually winning the item.)

Note that if the two highest bids are equal, the first bidder always wins over the second. The first bidder does not have to pay over their bid limit simply because someone else also bid the same amount.

See Huuto.Net or eBay for descriptions of similar real-world systems.

This simple class does not support bid cancellations, reserve prices, item buyouts, etc., and does not store any seller information.

## Parameters

description

  a short description of the item

duration

  the length of the auction, in days

startingPrice

  the initial price of the item, that is, the lowest possible price the seller is willing to accept

## Attributes

Supertypes
  class Object
  trait Matchable
  class Any

class FixedPriceSale(val `description`: String, val `price`: Int, `duration`: Int)

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

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.

## 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

Supertypes
  class Object
  trait Matchable
  class Any

final class testFixedPrice

## Attributes

Supertypes
  class Object
  trait Matchable
  class Any

### Value members

#### Concrete methods

def testFixedPrice(): Unit

A small program that uses the class `FixedPriceSale`. May be expanded by the student as desired.

A small program that uses the class `FixedPriceSale`. May be expanded by the student as desired.

Assuming the class `FixedPriceSale` has been implemented correctly, the output of this program (as given) is this:

    TWO SALES CREATED.
    days left: 4 & 2
    buyers:    None & None
    open:      true & true
    expired:   false & false

    ONE DAY PASSES.
    days left: 3 & 1
    buyers:    None & None
    open:      true & true
    expired:   false & false

    THE FIRST ITEM IS BOUGHT. A DAY PASSES.
    days left: 3 & 0
    buyers:    Some(T. Teekkari) & None
    open:      false & false
    expired:   false & true

    A DAY PASSES. ATTEMPTS ARE MADE TO BUY EACH OF THE ITEMS.
    days left: 3 & 0
    buyers:    Some(T. Teekkari) & None
    open:      false & false
    expired:   false & true

## Attributes