CS 1101 - Aterm 11

Homework 4 - Lists of Structs

Due: Tuesday, September 20 at 5pm

Read the expectations on homework.

Assignment Goals


The Assignment

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.

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

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

  2. Write the template(s) 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's name 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. (Clarification: the entire auction should be returned (with the specified cars updated to the new bid.))

  8. Write a function expiring-within that consumes an auction and a number and produces a list of all items that expire within the given number of hours.


What to Turn In

Here is the grading sheet that the graders will be using for Homework 4.

Using web-based turnin, turn in a single file containing all code and documentation for this assignment. Name your file according to the naming conventions for files. Make sure both partners' names and login names appear at the top of the file in a comment.