Question: [C++] Edit the code using pointers to accomplish the following: You will be keeping information on people and what cars they are driving. Your program
[C++] Edit the code using pointers to accomplish the following:
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 (use an array). 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. Each person can only be registered to a single car, but a car can have multiple people registered to it simultaneously.
#include #include
using namespace std;
class Person{ public: Person(); void setCar(Car& theirCar); private: string personName; };
class Car{ public: Car(); private: string carName; };
Person::Person() { //Set to null }
Car::Car() { //Set to null }
int main() { Car cars[101]; Person persons[101]; char selection;
while(1) { cout
cin >> selection;
if(selection == 'p') { cout
if(selection == 'c') { cout
if(selection == 'f') { cout
if(selection == 'r') { cout
if(selection == 'q') { return(0); } }
}
EXAMPLE OUTPUT:
![[C++] Edit the code using pointers to accomplish the following: You will](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4efbcd71ef_18866f4efbc3d0af.jpg)

Example 1 (user input underlined): 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 What is this person's name? inshu. 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 What is this car's name? 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 Which person do you want to find? inshu 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 which car do you wish to register this person to? 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 Which car do you wish to register this person to? mcstinks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
