ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 11 Weeks Ago, 6 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 27 May 2017 My Price 9.00

Write a program for a police department

Programming Assignment 6

Write a program for a police department that has collected a database of information on various suspects for a given crime. (Luckily for you, the department is only investigating one crime at a time.) Each suspect has a set of attributes, such as shifty eyes, a limp, or a parrot on his shoulder. The maximum number of such attributes for any suspect is not known. Your program accepts commands to manipulate the database in order to narrow down the list of suspects, in the hope of pinpointing the villain.

Input

The retained criminal information, generated by the previous execution of this program, is input from file "Criminal.mf" at the beginning of each execution of the program.

The user inputs commands from the keyboard, in the format shown below. Names and attributes are strings of no more than 20 characters. The program should not be case sensitive (e.g., 'JOE' and 'Joe' are the same name). To simplify the processing, you can assume that names are unique; that is, no two criminals use the same professional handle. The commands are discussed in detail in the Command Processing instructions below.

Output

Responses to user commands are to be written to the screen, as described in the Command Processing instructions below.

Echo print each command and show the results of any PRINT commands in a file called "Criminal.trn". You may determine the format of the information in this file; it should be labeled and formatted clearly. A hard copy of this file is turned in with your program for grading.

If any new suspects were added (see ADD command), file "Criminal.mf" must be rewritten to contain the updated collection of criminal information.

Command Processing

New suspects can be added to the collection of criminal information using the ADD command. An inquiry consists of a set of commands with respect to a single crime, at the end of which the crime is assumed to be solved. An inquiry must be completed within the execution of the program; it cannot be "saved" to finish on a subsequent execution. After an inquiry is complete, a new inquiry (the investigation of another crime) can begin. Each new inquiry starts over with the entire collection of suspects.

Command

Processing

ADD

Add a suspect to the Suspects data structure. Prompt the user for the suspect's name and a list of attributes. ADD commands can be issued only before an inquiry begins.

INQUIRY

Prompt user for code name of this inquiry. Once the inquiry has begun, do not allow the user to issue the ADD command until this inquiry is complete.

TIP

Prompt user for the tip information (a particular attribute). Process the tip, reducing the set of current suspects by deleting suspects who do not match the attribute mentioned in the tip. If there is only one suspect left in the set of active suspects, print out a message indicating that the crime is solved. Be sure to include the suspect's name and inquiry code name. This terminates the current inquiry.

CHECK

Prompt the user for a suspect's name. Check the set of active suspects to see if this name is there; print out an appropriate response.

PRINT

Print the set of active suspects (those who have not yet been eliminated).

QUIT

If any new suspects have been added during this execution of the program, rewrite the "Criminal.mf" file. Be careful about how you go about saving the records; the traversal order affects the shape of the tree that is built on the next execution of the program. Terminate the program.

Sample Input

(Some of the labels shown in the sample input are not typed in by the user, but are only printed for clarity. For this example, the "Criminal.mf" file is empty and all the potential suspects are added by command.)

ADD Name: Quickdraw McGraw

Attributes: has a Texas accent

has a body guard

is computer literate

ADD Name: Twingun Morgan

Attributes: has a New York accent

has red hair

smokes cigars

ADD Name: Jackda Ripper

Attributes: has a body guard

bites his fingernails

carries a knife

is computer literate

ADD Name: Annie Getcher Gunn

Attributes: has a New York accent

has red hair

eats Fritos

smokes cigars

ADD Name: Slowdrawl Raul

Attributes: has a Texas accent

carries a knife

is computer literate

eats Fritos

ADD Name: Sloan de Uptake

Attributes: has a body guard

has red hair

bites his fingernails

is computer literate

INQUIRY Code Name: Bang Bang

TIP Tip Info: has a New York accent

CHECK Quickdraw McGraw

TIP Tip Info: has red hair

CHECK Annie Getcher Gunn

TIP Tip Info: eats Fritos

INQUIRY Code Name: Holdup

TIP Tip Info: has a Texas accent

CHECK Slowdrawl Raul

CHECK Sloan de Uptake

TIP Tip Info: is computer literate

INQUIRY Code Name: Tough Stuff

TIP Tip Info: bites his fingernails

PRINT

CHECK Twingun Morgan

TIP Tip Info: has a body guard

CHECK Slowdrawl Raul

TIP Tip Info: is computer literate

QUIT

Data Structures

There is no upper bound to the number of suspects or number of attributes for a given suspect. You cannot use an array-based list to store the suspects or the attributes for a given suspect.

The CHECK operation must be very efficient, because suspects are continually being pulled off the street for questioning and we must decide whether to let them go or ruthlessly interrogate them. Using a simple linked list to store the suspects is not sufficient. You must use a binary search tree. Suspects must be actually deleted from the structure when they are eliminated by TIP information. Because you destroy the list of suspects, as suspects are eliminated by TIP information, each inquiry should work on a copy of the original tree.

TIP is executed much less often than CHECK and hence can be less efficient. It is acceptable if processing a TIP command requires searching the whole data structure of (active) suspects. Thus, a list of attributes can be stored with each suspect. You do not have to link all the suspects with the same attributes together. (This could potentially make for a much faster TIP operation.) You may do this if you want, but it complicates things.

Deliverables

Your design and CRC cards for any classes

A listing of any test driver necessary to check classes

A listing of the test plan for any class as input to the driver

A listing of the source code

A listing of the test plan as input to the program

A listing of the output from the test run

 

It is for and using C++. Please don't forget the highlighted information. 

Thanks

Answers

(11)
Status NEW Posted 27 May 2017 03:05 AM My Price 9.00

-----------

Attachments

file 1495855242-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)