CECS 282
LAB ASSIGNMENT 4
Assigned date: 9/19
Due date:  9/26
30 points

Problem 1 [16 points]

Implement a class Person with two attributes name and age , and a class Car with three fields:

The class Person must have a function called incrementAge. The function increments the age by one. Also Create a function to find a person with the given name in an array of Person* pointer.

/**
@param a the array
@param n the name to look for
@return the first matching Person* or NULL if there is no match
*/

Person* find(vector<Person*> a, string n)

Write a program that prompts the user to specify people and cars. Store them in a vector<Person *> and a vector<Car*). Traverse the vector of cars and print out the car model, owner's name and , and driver's name and age.
Use vector to store the objects Car and objects Person.

Output sample

Enter name, q to quit: John Nguyen
Enter age: 30
Enter name, q to quit: Ralph Bravaco
Enter age: 50
Enter name, q to quit: q
Enter model, q to quit: Tesla model S
Enter owner name: John Nguyen
Enter driver name: Sahi Simonson
Enter model, q to quit: Tesla model X
Enter owner name: Timonthy Budd
Enter driver name: John Nguyen
Enter model, q to quit: q
Car model: Tesla model S,owner=John Nguyen,age=31,driver=NULL.
Car model: Tesla model X,owner=NULL,driver=John Nguyen,age=31.

Problem 2 [7 points]

Create a function to copy a portion of a string to another.

void strncpy(char* t, const char* s, int n)

   @param t a pointer to the start of the target string

   @param s a pointer to the start of the source string

   @param n the maximum number of characters to copy

Write a main function to test the string.

Problem 3 [7 points]

Create a function that reverses the values in an array passing to the function. Use pointers to implement the functions.

void reverse(double a[], int size) 

   @param a the array

   @param size the number of elements in the array

Grading