Description
- This is an individual assignment. Please do not collaborate
- If you think that this document does not clearly describes the assignment, ask questions before its too late.
This assignment is about using C++ STL, exception handling and/or creating Class templates.
- Your program reads two files:
- txt
- txt
- According to content in data.txt, the program utilizes necessary STL classes and/or user-created classes for a catalog representation.
- Your program creates a log file(output.txt) for certain steps of operations performed on catalog. txt
- This file holds information about a catalog. A catalog can be one of the following:
- Book catalog
- Music catalog
- Movie catalog
- The type of the catalog is specified in the first line of data.txt
Book Catalog
- Each line in a book catalog keeps information about a book.
- Format:
<title> <authors> <year> <tags>
- Example: Contents of data.txt for a book catalog
- book
- Hilbert Spaces With Applications Lokenath Debnathl, Piotr Mikusinski 2005 Mathematics,
, Set Theory
- The Neolithic Revolution in the Near East: Transforming the Human Landscape Alan H. Simmons
, 2011 Social Science, Anthropology, Cultural, General, Archaeology
- Learning Flask Framework Matt Copperwaite, Charles Leifer 2015 Computers, Programming
, Languages, Python, Internet, Application Development, Web, Web Programming
- Graphics Gems V Alan W. Paeth 1995
Music Catalog
- Each line in a music catalog keeps information about a music album.
- Format:
<title> <artists> <year> <genre>
- Example: Contents of data.txt for a music catalog
- music
- Professor Satchafunkilus and the Musterion of Rock Joe Satriani 2008 Guitar Virtuoso
- Physical Graffiti Led Zeppelin 1975 Rock
- Witchdoctors Son Okay Temiz, Johnny Dyani 2017 Jazz, Fusion
- Return Of The Mother Heads Family Reunion Richie Kotzen 2007 Rock, Guitar Virtuoso
Movie Catalog
- Each line in a movie catalog keeps information about a movie.
- Format:
<title> <director> <year> <genre> <starring>
- Example: Contents of data.txt for a movie catalog
- movie
- The Lord of the Rings: The Fellowship of the Ring Peter Jackson 2001 Adventure, Drama,
, Fantasy Elijah Wood, Ian McKellen, Orlando Bloom
- Twelve Monkeys Terry Gilliam 1995 Mystery, Sci-Fi, Thriller Bruce Willis, Madeleine
, Stowe, Brad Pitt
- Perfume: The Story of a Murderer Tom Tykwer 2006 Crime, Drama, Fantasy Ben Whishaw,
, Dustin Hoffman, Alan Rickman
- Cold Mountain Anthony Minghella 2003 Adventure, Drama, History Jude Law, Nicole
, Kidman, Renee Zellweger commands.txt
This file includes several commands which work on the catalog information you read from data.txt. Each line is a command. The following should be recognized:
- There are two commands.
search <string> in <field> sort <field> search command
- Format: search <string> in <field>
- Output:
This command returns a list of matched(partially or fully) entries (one entry in a line). Search should be limited to the field specified. Not found returns no line.
- Example:
search Joe in artists This returns the following line:
Professor Satchafunkilus and the Musterion of Rock Joe Satriani 2008 Guitar Virtuoso sort command
- Format: sort <field>
- Output:
This command returns a list of sorted entries (ascending order)
- Example:
sort title
This returns the following lines: 1 Cold Mountain Anthony Minghella 2003 Adventure, Drama, History Jude Law, Nicole
, Kidman, Renee Zellweger
- Perfume: The Story of a Murderer Tom Tykwer 2006 Crime, Drama, Fantasy Ben Whishaw,
, Dustin Hoffman, Alan Rickman
- The Lord of the Rings: The Fellowship of the Ring Peter Jackson 2001 Adventure, Drama,
, Fantasy Elijah Wood, Ian McKellen, Orlando Bloom
- Twelve Monkeys Terry Gilliam 1995 Mystery, Sci-Fi, Thriller Bruce Willis, Madeleine
, Stowe, Brad Pitt output.txt
This file keeps the log of the operations. The following events should be recorded in the specified format:
- catalog read
- output of commands catalog read
- First specify the type of the catalog.
- At the end, state the number of unique entries.
Catalog Read: music 4 unique entries output of commands
- State the command.
- Append its output.
search Joe in artists
Professor Satchafunkilus and the Musterion of Rock Joe Satriani 2008 Guitar Virtuoso
Exceptions
- Your program should catch certain exceptions and create log entries for them.
- You need to catch the following exceptions:
Missing field exception
- If any of the field in any entries is missing your program should omit that line and create an exception record in the log file.
Exception: missing field
Duplicate entry exception
- If the first field of any entries fully match, your program should create an exception for each repetition and log these instances in the log file.
Exception: duplicate entry
Wrong command exception
- If the command is not in the expected format(unrecognized field name, extra information etc), log this instance as an exception. Exception: command is wrong
A full example.
- Suppose we are given the following data.txt file and commands.txt file:
- txt
- movie
- The Lord of the Rings: The Fellowship of the Ring Peter Jackson 2001 Adventure, Drama,
, Fantasy Elijah Wood, Ian McKellen, Orlando Bloom
- Twelve Monkeys Terry Gilliam 1995 Mystery, Sci-Fi, Thriller Bruce Willis, Madeleine
, Stowe, Brad Pitt
- Twelve Monkeys Sci-Fi, Thriller Bruce Willis, Madeleine Stowe, Brad Pitt 5 Perfume: The Story of a Murderer Tom Tykwer 2006 Crime, Drama, Fantasy Ben Whishaw,
, Dustin Hoffman, Alan Rickman
- Twelve Monkeys Mystery, Sci-Fi, Thriller Bruce Willis, Madeleine Stowe, Brad Pitt
- Cold Mountain Anthony Minghella 2003 Adventure, Drama, History
- commands.txt
- search Monkeys in title
- search Spice in type
- sort year
- The first line is movie. This means your application will going to run in movie organiser mode.
- Following is the log file for this example:
- txt 1 Catalog Read: movie
- Exception: duplicate entry
- Twelve Monkeys Sci-Fi, Thriller Bruce Willis, Madeleine Stowe, Brad Pitt
- Exception: duplicate entry
- Twelve Monkeys Mystery, Sci-Fi, Thriller Bruce Willis, Madeleine Stowe, Brad Pitt
- Exception: missing field
- Cold Mountain Anthony Minghella 2003 Adventure, Drama, History
- 3 unique entries
- search Monkeys in title
- Twelve Monkeys Terry Gilliam 1995 Mystery, Sci-Fi, Thriller Bruce Willis, Madeleine
, Stowe, Brad Pitt
- Exception: command is wrong
- search Spice in type
- sort year
- Twelve Monkeys Terry Gilliam 1995 Mystery, Sci-Fi, Thriller Bruce Willis, Madeleine
, Stowe, Brad Pitt
- The Lord of the Rings: The Fellowship of the Ring Peter Jackson 2001 Adventure, Drama,
, Fantasy Elijah Wood, Ian McKellen, Orlando Bloom
- Perfume: The Story of a Murderer Tom Tykwer 2006 Crime, Drama, Fantasy Ben Whishaw, , Dustin Hoffman, Alan Rickman
Reviews
There are no reviews yet.