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.
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.
Write the template for auctions.
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.
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.
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.
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.
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.
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).
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.
Provide data definitions for auctions that include both original items and fixed-price items.
Provide the template for your expanded auction definition.
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.
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.