CS 1102 (A05) Homework 2: Auctions

Due: September 8 (Thursday) at 11:59pm.

Assignment Goals


The Assignment

Remember to follow the Expectations on Homework when preparing your solutions, including the academic honesty policy.

In this assignment, you will implement functions for a simple version of an auction system such as eBay. Your solutions will be graded partly for their use of helpers and adherence to templates. Code that "works" but violates template structure will receive little credit.

  1. A bid consists of the bidder's name and the amount they wish to bid. An item consists of a description, the current winning (high) bid for an item, and how many hours are left before that item is closed for bidding. An auction is a list of items.

    Write data definitions and provide examples of data for bids, items, and auctions.

  2. Write the template for auctions.

  3. Write a function place-bid that consumes the bidder's name, amount he wants to bid, and the item that he wants to bid on and returns either an item or false. If the amount to bid is greater than the current high bid amount, the function produces an item with the new high bid information. Otherwise, the function produces false.

  4. Write a function total-owed that consumes a person's name and an auction and produces the total amount that the person owes for bids that they have won. A person has won an item if she is named as the high bidder and if the hours left to bid on the item is zero.

  5. Write a function winning-items that consumes a person's name and an auction and produces a list of all the items for which the person is currently the high bidder.

  6. Write a function hour-passed that consumes an auction and produces an auction. The produced auction decreases the hours left on each biddable item by 1. Items that already have zero hours left should stay at zero hours left.

  7. Write a function bid-cheap-cars that consumes a person and an auction and produces an auction. In the produced auction, the person has bid 1000 on every item with "car" as its description and a high bid of under 700 dollars.

  8. Write a function sort-auction that consumes an auction and returns a sorted auction. The sorted auction contains items in increasing order of the number of hours remaining to bid on that item. Items that expire in the same number of hours should be sorted alphabetically by description (search the DrScheme helpdesk on string to get the operators for comparing strings).

  9. The auction company decides to introduce fixed price items into their system. Fixed-price items have a description and a price. Unlike biddable items, they do not expire; they stay in the auction until someone buys them.

    1. Provide data definitions for auctions that include both original items and fixed-price items.

    2. Provide the template for your expanded auction definition.

    3. Write a function guitar-prices that consumes an expanded auction and produces a list of current prices for items (biddable or fixed price) with the description "guitar". The current price of a biddable item is one more than the amount of its highest bid.


What to Turn In

Turn in a single file hwk2.ss or hwk2.scm containing all code and documentation for this assignment. Make sure that both students' names are in a comment at the top of the file.


Back to the Assignments page