Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Objectives: Solve problem, design solution and implement using C + + classes and objects Learn how to manipulate a list of C + + objects
Objectives:
Solve problem, design solution and implement using C classes and objects
Learn how to manipulate a list of C objects using vector class
Use C stream to read in data and format output
Description:
Write a commanddriven program named "ManageVariableObjects" that will accept the following commands:
list
exit
save away the variable and its value in the list array
If the variable has been assigned before, it simply updates with the new value
Note: the variablevalue can now be another variable name.
If the value is another variable name, it will look up and save its value into the new variable.
display the current value of the variable in the following format such as count
or "undefined"
"list" command will display all the variables and its count
"exit" command will exit the program
Requirements:
The program must produce the same expected output as provided.
There should be no global variables. Please use only local variables and parameters instead
Scanf and printf are not allowed Please use C cin and cout and C formatting
It should display "Undefined" when the variable is not assigned yet
You must define at least two more C classes:
Variable class that manages variable information such as name and value
VariableListManager class that manages a list of Variable object pointers not objects using the vector class.
It means that the Variable object is outside the vector object and you must create the objects using "new" operator.
Simple error check for variable names: cannot start with a digit.
There must be at least functions including main
Please do not use arrays. You must use the C vector class to manage the list of object pointers.
The vector must be a private data member in the "VariableListManager" class. No vector class and object
can be referenced or used outside the VariableListManager class.
Please minimize redundant code. Please write functions if you need to perform the same tasks multiple times.
There should be at most one return statement in each function.
Please do not iterate through the list in the vector more than once for each task and please do not iterate to the end of the list unnecessarily.
You should not define the maximum size limit and not to keep track of its actual number of variables separately because the vector object has its size.
You can assume that the user enters the variable assignment correctly eg correct operator and integer value separated by blanks
All data members must be declared private in the class.
The "Variable" class must not provide the default constructor.
Sample output of a program run:
Please note that the output of the project # will continue to work and display the same result.
Here is the new additional run and output:
C: ManageVariableObjects
Please enter variable assignment, variable name only or list or exit:
count
Undefined
count
Undefined
count
count
count
count
list
count
Number of variables:
total
total
list
count
total
Number of variables:
duplicate
Undefined
count duplicate
Undefined
duplicate count
duplicate
count
count
list
count
total
duplicate
Number of variables:
total count
total
list
count
total
duplicate
Number of variables:
count
count
total
total
duplicate
duplicate
quantity
quantity
list
count
total
duplicate
quantity
Number of variables:
count quantity
count
count
Undefined
price
Undefined
price quantity
price
list
count
total
duplicate
quantity
price
Number of variables:
duplicate temp
Undefined
temp duplicate
temp
quit
Undefined
count
Invalid variable name. Cannot start with a digit.
exit
Exiting...
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started