Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

Dictionary by dffhrtcv3


									Project 11: Dictionary

                     RPN Calculator II

   In a future project, we will extend the RPN
    Calculator from Project 9 to use variables.
   A variable is identified by a name
       String of letters, digits, and underscores
       Must begin with a letter
       Maximum of 15 characters
       Case sensitive
       Cannot duplicate a command
   A variable has a value
       double                                       2
                      The Dictionary

   The program will include a dictionary
    component for variables.
       A set of name-value pairs.
       Specifies the current value of each variable.

   The dictionary provides the ability to add
    and retrieve name-value pairs.
       Variables and their values

   A variable will be added to the dictionary
    when first used, and never removed.

   Design and implement a dictionary
    component for later use in the RPN

   Key: string (array of char)
       Max length 15 characters

   Value: double

                          The Dictionary

   Dictionary Operations:
       Set Variable Value
            Set a specified variable to a specified value.
            Add the variable to the dictionary if necessary.
       Get Variable Value
            Get the value of a specified variable.
            Add the variable with default value of 0 if not
             already in the dictionary.
       Display Variables
            Display all variables and their values.
            Display in lexicographical order.

   The Dictionary is reponsible only for
    storing and retrieving name-value pairs.

   It does not validate the names.
       Accept any string of up to 15 characters.
       Ignore any characters beyond 15.


   Use a linked list to implement the dictionary.
       Dynamically allocated nodes

   Keep variables in lexicographical order.
   Include a self test.
       Given on a later slide.

   Use the files shown on the following slides
    exactly as given.
       Available in the Downloads area.


   Define a struct Variable_t to hold a
    name-value pair.
   Define a struct to hold a linked list node
       next pointer
       prev pointer
       Variable_t struct as its data
   These structs should not be visible outside the


This file defines the external interface of the dictionary component.
This is all the rest of the program knows or needs to know about it.
                             The List Head

   The List Head should be a struct of the
    same type that is used for the list nodes.
   Define the List Head as a static global
    variable near the top of file variables.c.
       It will be visible to all functions defined in
        variables.c, but not visible outside that file.
       Initialize the List Head where it is declared,
        using a struct intializer.
            See slide 10 of the Struct presentation for an example.
            This initializer will be more complex because there is a
             struct within a struct.

Sample Run

                             Ground Rules

   You may work with one other student.
   If you do
       Submit one solution.
       Include both names in the Assignment comments.
            Other student submit comment only with both names.
       Work together! Be sure you both understand the
        program and test plan that you submit.

   It is OK to discuss the project with others. BUT:
       Don’t let anyone see or copy your work.
       Don’t look at or copy anyone else’s work.
       Be sure your Unix source file is read & write
            chmod 600 filename.c                                 14

   Turn in your source file through
    Blackboard Assignments for this class.
       Not Digital Dropbox
       Not Email

   Submit just one source file.
       variables.c

   It will be compiled with the given files,
    variables.h and dictionary_test.c, and
    tested on Circe.
                               Due Date

   Project is due by midnight, Thursday night, April 22.
       No late submissions will be accepted.


To top