To practice C statements and programming ideas, such as loops, arrays, and structures. To practice good programming techniques, style, design, testing, and good program documentation, on a medium-sized programming example in the database and artificial intelligence domains.
(The idea for this assignment, and the story and clues given below, was adapted from the book Great Ideas in Computer Science: A Gentle Introduction, by Alan W. Biermann. ©1990 by Massachusetts Institute of Technology, published by The MIT Press, Cambridge, Mass. Pages 109 and 144. Used with the kind permission of the publisher.)
As the afternoon sun faded on the village green, Chief Inspector Lestrade of Scotland Yard was just lighting his evening pipe when the jangling of his phone interrupted his mellow mood. The call was from a terrified Miss Secrest, who moments before had found Lord Peter Dunsmore collapsed on the drawing room floor of Dunsmore Manor. He was dead. The Lady Emily, Lord Dunsmore's wife, had collapsed from the shock and had been taken to her chambers where the family doctor ministered to her. Miss Secrest begged the Inspector to hurry over to Dunsmore Manor. This he did, after phoning the Medical Examiner and noting the time was a few minutes after 5:00 P.M.
After examining the body, the M.E. pronounced the cause of death as a lethal dose of poison administered within the last few hours.
After questioning the family, servants, and visitors Inspector Lestrade had many facts but was having trouble putting them together. So naturally he turns to you for help, a world-renown computer expert. You decide to build a database of the facts which will allow the Inspector to find related facts. For example, if the Inspector asks "Who visited the manor today?" your program might respond:
Mr. Mason visited at 3:00 P.M. The professor visited at 3:00 P.M. Miss Secrest visited at 5:00 P.M.
or if the query is "Tell me about Mr. Mason?" your program might respond:
Mr. Mason has hobby tennis Mr. Mason visited at 3:00 P.M. Mr. Mason is a chemist
(Naturally, the queries will not be in English, but in your query language.)
After entering all known facts and using your system for awhile, Inspector Lestrade was able to identify a prime suspect, the only person who had an apparent motive, access to the poison, and a way of administering it to the victim. After confronting his suspect with the relevant facts, the suspect broke down and confessed. Thanks to you and your computer skills, Justice has triumphed once again!
You must write a stripped-down database application capable of storing facts. A fact in this program has three parts or fields: a subject (a noun phrase), a relation (a verb phrase), and an object (a noun phrase). For example:
|Lord Dunsmore||is married to||Lady Emily|
You can (and should!) test your program with several different sets of facts (databases). However, a printout of the following must be turned in:
Extra-Credit of 1 point will be awarded if you can identify the murder! Write the name on the bottom of the printout of the output.
(command line: C:\> clue clue.dat)
[Loaded 31 facts from file "Clue.dat".] C L U E D A T A B A S E ------- --------------- (A) Add a fact to the database (D) Delete a fact from the database (Q) Query the database (S) Save the database in a file (H) Print additional Help (X) eXit Clue Enter a choice from the menu above: h A fact has a subject, a relation, and an object. Each field is limited to 50 characters. ... Type Return (Enter) to continue... <MENU IS REPRINTED HERE> Enter a choice from the menu above: q For each field enter the text to match, or the wild-card symbol ("?") to match any text in that field. Enter the subject: dunsmore Enter the relation: ? Enter the object: ? THE MATCHING FACTS: Lord Dunsmore is married to Lady Emily Lord Dunsmore has hobby tennis Lord Dunsmore has rival Lord Secrest Lord Dunsmore died of poison Another query? (Y/n) Enter the subject: Professor Plum Enter the relation: stabbed with the knife Enter the object: ? No matching facts found! Another query? (Y/n) Enter the subject: ? Enter the relation: visit Enter the object: ? THE MATCHING FACTS: Mr. Mason visited at 3:00 P.M. The professor visited at 3:00 P.M. Miss Secrest visited at 5:00 P.M. Another query? (Y/n) n Type Return (Enter) to continue... <MENU IS REPRINTED HERE> Enter a choice from the menu above: a For each field enter the exact text to match. Enter the subject: ? Enter the relation: visited Enter the object: ? ***Warning! A Field must NOT contain the wild-card character "?"! Add another fact? (Y/n) y Enter the subject: This Enter the relation: is Enter the object: fun! Add another fact? (Y/n) n Type Return (Enter) to continue... <MENU IS REPRINTED HERE> Enter a choice from the menu above: d For each field enter the exact text to match, or the wild-card symbol ("?") to match any text in that field. Enter the subject: ? Enter the relation: ? Enter the object: fun DELETING THESE FACTS: This is fun! Type Return (Enter) to continue... <MENU IS REPRINTED HERE> Enter a choice from the menu above: x Really Quit? (Y/n) y Do you want to save the database to disk before quitting? (Y/n/c) n C:\>
(The file clue.dat contains the data shown below):
Lord Dunsmore?is married to?Lady Emily Miss Secrest?called?the Inspector The gardener?is married to?the maid Poison?can be procured by?a blood relative Mr. Mason?visited?at 3:00 P.M. A shared hobby?causes?friendship The gardner?was fired by?Lord Dunsmore Lord Dunsmore?has hobby?tennis The maid?set tea?at 2:45 P.M. The gardener?has hobby?music Lord Secrest?has hobby?philosophy Lord Dunsmore?has rival?Lord Secrest Mr. Mason?is?a chemist The Inspector?is a customer of?Mr. Mason Lord Secrest?has daughter?Miss Secrest The buttler?owes money to?Lord Dunsmore The buttler?served lunch?at 12:00 P.M. The professor?has hobby?philosophy The professor?visited?at 3:00 P.M. Lord Secrest?is a customer of?Mr. Mason The professor?gives gifts to?Lady Emily Tea?is served?at 3:00 P.M. Miss Secrest?visited?at 5:00 P.M. Poison?is procured from?a chemist Lord Dunsmore?died of?poison Lady Emily?has hobby?music Poison?can be procured for?a friend Mr. Mason?has hobby?philosophy Poison?kills?within one hour The professor?was once a suitor of?Lady Emily Miss Secrest?discovered the dead body of?Lord Dunsmore
|Send comments and mail to firstname.lastname@example.org.|