Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language = C++ Thank you! ------------------------------------------------CustomerArray.h-------------------------------------------------------------------------------------- #ifndef CUSTOMERARRAY_H #define CUSTOMERARRAY_H #include Customer.h class CustomerArray { public: CustomerArray(); ~CustomerArray(); int add(Customer*); Customer* get(int); int getSize(); private:

Language = C++ Thank you!

image text in transcribed

image text in transcribed

------------------------------------------------CustomerArray.h--------------------------------------------------------------------------------------

#ifndef CUSTOMERARRAY_H #define CUSTOMERARRAY_H

#include "Customer.h"

class CustomerArray { public: CustomerArray(); ~CustomerArray(); int add(Customer*); Customer* get(int); int getSize(); private: Customer* elements[MAX_CUSTOMERS]; int size; };

#endif

------------------------------------------------CustomerArray.cc--------------------------------------------------------------------------------------

#include "CustomerArray.h" #include "Customer.h" #include "defs.h"

//add code here

------------------------------------------------Customer.h--------------------------------------------------------------------------------------

#ifndef CUSTOMER_H #define CUSTOMER_H

#include #include "Vehicle.h" #include "VehicleArray.h" using namespace std;

class Customer {

public: Customer(string="", string="", string="", string=""); int getId(); string getFname(); string getLname(); string getAddress(); string getPhoneNumber(); int getNumVehicles(); VehicleArray& getVehicles(); int addVehicle(Vehicle*); private:

static int nextId; int id; string firstName; string lastName; string address; string phoneNumber; VehicleArray vehicles; };

#endif

------------------------------------------------defs.h--------------------------------------------------------------------------------------

#ifndef DEFS_H #define DEFS_H

#define MAX_VEHICLES 4 #define MAX_CUSTOMERS 6

#define C_OK 0 #define C_NOK -1

#endif

. The constructor simply initializes the size data member properly, . The destructor must iterate over the stored objects (which are to be dynamically allocated, discussed below), freeing the allocated memory for each one. The getSize function is a simple, one line getter

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions