Question
C++ Code -------------------------------------------------------- People and vehicles For this part you will be keeping information on people and what cars they are driving. Your program should
C++ Code
--------------------------------------------------------
People and vehicles
For this part you will be keeping information on people and what cars they are driving. Your program should have the following options:
p : create a new person in the database (you may assume this person's name is only one word)
c : create a new car in the database (you may assume the car's name will be only one word)
f : find and select a person in the database (if there is no such person, show no one)
r : register the current person selected to a specified car (if there is no such car, they should be unregistered to any current cars)
You may assume there will be no more than 100 cars in the database and no more than 100 people. If you try and find (and select) a person that doesn't exist, show no one for both the person and car. If a person is not registered to a car, show no one for the car. You may assume all people have different names and all cars have different names. However, a car and person might have the same name (see example 2).
Each person can only be registered to a single car, but a car can have multiple people registered to it simultaneously (see example 3).
Hint 1: use classes (and don't dump everything in a single function)
Hint 2: use pointers (really!) or you might regret it when part B comes around
------------------------------------------------------------------------
Example 1 (user input BOLDED):
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
p
What is this person's name?
qinshu
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
c
What is this car's name?
putput
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
f
Which person do you want to find?
qinshu
Currently looking at:
Person: qinshu
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
r
Which car do you wish to register this person to?
putput
Currently looking at:
Person: qinshu
In car: putput
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
r
Which car do you wish to register this person to?
mcstinks
Currently looking at:
Person: qinshu
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
f
Which person do you want to find?
ahmed
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
p
What is this person's name?
ahmed
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
f
Which person do you want to find?
ahmed
Currently looking at:
Person: ahmed
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
q
------------------------------------------------
Example 2 (user input Bolded):
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
p
What is this person's name?
cp
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
f
Which person do you want to find?
cp
Currently looking at:
Person: cp
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
r
Which car do you wish to register this person to?
cp
Currently looking at:
Person: cp
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
c
What is this car's name?
cp
Currently looking at:
Person: cp
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
r
Which car do you wish to register this person to?
cp
Currently looking at:
Person: cp
In car: cp
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
q
--------------------------------------------------------
Example 3 (user input BOLDED):
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
c
What is this car's name?
bus
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
p
What is this person's name?
a
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
p
What is this person's name?
b
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
p
What is this person's name?
c
Currently looking at:
Person: No one
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
f
Which person do you want to find?
a
Currently looking at:
Person: a
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
r
Which car do you wish to register this person to?
b
Currently looking at:
Person: a
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
r
Which car do you wish to register this person to?
bus
Currently looking at:
Person: a
In car: bus
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
f
Which person do you want to find?
b
Currently looking at:
Person: b
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
r
Which car do you wish to register this person to?
bus
Currently looking at:
Person: b
In car: bus
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
f
Which person do you want to find?
c
Currently looking at:
Person: c
In car: No one
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
r
Which car do you wish to register this person to?
bus
Currently looking at:
Person: c
In car: bus
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
f
Which person do you want to find?
a
Currently looking at:
Person: a
In car: bus
Do you want to: (p) make a new person, (c) make a new car, (f) find a person, (r) register a person to a car, or (q) quit
q
----------------------------------------------------
C++ Code Thanks!!
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