Assignment Help

  

CD Database

Introduction

This assignment will give you practise w/user and program interfaces, and choosing/building useful data structures.

You will maintain a flat-file database, allowing users to query, delete a entry, create an entry.


The Assignment

Write a command-line utility called cddb to maintain a flat-file database of album information. You will allow the user to view album info, add a new entry, or delete an entry, where each entry is an album w/all of the track information, as follows:


Options, and Descriptions

  • -l — List album
    1. Display an enumerated, alphabetical list of artists
    2. You will allow the user to choose an artist by entering the number, or to quit by entering a q
    3. You will then list all albums, by release date, enumerated
    4. Allow the user to choose an album, by #, or return to the menu above (artists) by entering a
    5. If an album is entered, list all songs in that album, by track order. Prompt for input to return to the previous (i.e., the album) menu
  • -d — Delete album. Similar to above, display menus allowing a user to choose an album to delete
  • -a — Add album. You’ll prompt for artist, album name, release date, and finally the track list. You may assume that they are entered in track order.
    You’ll want to check that the album doesn’t already exist before adding it
  • -h — Show usage msg and quit

You may assume that all names are entered exactly. That is, do not worry about inconsistencies in spelling or capitalisation. E.g., Led Zeppelin, LedZeppelin, and led zeppelin are 3 different groups for this assignment.

If no argument is supplied, a bad argument is supplied, or multiple arguments, print a usage message and exit.


File Format

Album information will be stored in a flat file w/the format shown in sample.db:

To simplify things, the filename (location of the DB) will be stored in an exported environment variable, $CDDB .


Target Language

You can do this in any language you choose, including Bash or AWK. The language must be currently hosted on the tux machines.

If you, e.g., do this in Java, then you’ll need to supply a shell script called cddb that invokes your program, the JRE, whatever, w/the arguments.


Hints (maybe)

  • I’d create some data structure to represent an album
  • Store albums in a dictonary, keyed by artist
  • When updating the DB (writing the new file out), write to a temporary file. If this is successful, rename it appropriately. This is generally an atomic operation. So, if something bad happens w/your program, or the power grid, etc., you don’t blow your DB up

Submission

Since you can do this in a number of languages, submit a makefile . Here is a sample makefile. See my notes on makefiles for help.

Submit the following files to fp via the submit_cliBlackboard Learn utility.

  • makefile – your makefile, with the folowing targets:
    • build — compile your code, whatever, get it ready to run
    • clean — cleans up all intermediate and resulting files
    • view — display any source code that you wrote, in a pager
  • all of your source files. Any executables, binaries, .class, .o, etc. will be deleted before grading. The program must be built from scratch, by your makefile.
  • README optional – anything you want to say to me before I grade.

If you supply input.txt it will be overwritten.

Please note You will use the filenames as listed here, and submit them all to the proper assignment. If this is not clear, then see me in class. If I get programs submitted to the wrong directories, I will be irate, which may, in some subconscious way, affect your grades. Adversely.

  

Leave a Comment

Your email address will not be published.