Car Class Composition Create a class called `Car` that will utilize other objects. ## Car ### Car member variables Create two data members that are: (1) an instance of the `VehicleId` class called `id_` and (2) an instance of the `Date` class called `release_date_`. *NOTE*: `VehicleId` and `Date` are classes that have been provided to you. You **DO NOT** need to create them. ### Default Constructor The default constructor will be **EMPTY**, so you do not have to initialize anything. `VehicleId` and `Date`'s respective constructors will initialize their default values. ### Non-Default Constructors 1. Create a non-default constructor that takes in a `VehicleId` object. This will assign the parameter to the `id_` member variable. 2. Create a non-default constructor that takes in a `Date` object. This will assign the parameter to the `release_date_` member variable. 3. Create a non-default constructor that takes in a `VehicleId` and a `Date` object (in this order). This will assign the parameters to the `id_` and `release_date_` parameters correspondingly. ### Accessors and Mutators Create accessors and mutators for `id_` and `release_date_`, following the naming conventions covered in class. e.g. for id_, name the accessor `Id`, and the mutator `SetId`. ### Other Member Functions Create a `void` member function called `Print` that takes in no parameters. `Print` should print the model, vehicle id (VIN), license plate, and release date of the car. The release date should follow the format **mm/dd/yyyy**. See the output below as a reference. ## Other instructions Complete the `main` function as described. Place your class in `car.h`. Member functions that take more than ten lines or use complex constructs should have their function prototype in `car.h` and implementation in `car.cc`. Your program does not need to account for the correct dates or license plates. For example: 13/41/1 will be acceptable for your program, even though it is not an acceptable date, and "1111111111111111" will be acceptable in your program, even though it is not a valid license plate number. ## Sample output ``` The model of the car is: Tesla The VIN of the car is: 121 The license plate of the car is: TUFFY121L The release date of the car is: 1/1/2022 The model of the car is: Honda The VIN of the car is: 3 The license plate of the car is: 7B319X4 The release date of the car is: 1/1/2022 The model of the car is: Ford The VIN of the car is: 1 The license plate of the car is: 123456 The release date of the car is: 11/4/2018 The model of the car is: Honda The VIN of the car is: 3 The license plate of the car is: 7B319X4 The release date of the car is: 11/4/2018 The model of the car is: Tesla The VIN of the car is: 121 The license plate of the car is: TUFFY121L The release date of the car is: 1/1/2022
# Car Class Composition
Create a class called `Car` that will utilize other objects.
## Car
### Car member variables
Create two data members that are: (1) an instance of the `VehicleId` class called `id_` and (2) an instance of the `Date` class called `release_date_`.
*NOTE*: `VehicleId` and `Date` are classes that have been provided to you. You **DO NOT** need to create them.
### Default Constructor
The default constructor will be **EMPTY**, so you do not have to initialize anything. `VehicleId` and `Date`'s respective constructors will initialize their default values.
### Non-Default Constructors
1. Create a non-default constructor that takes in a `VehicleId` object. This will assign the parameter to the `id_` member variable.
2. Create a non-default constructor that takes in a `Date` object. This will assign the parameter to the `release_date_` member variable.
3. Create a non-default constructor that takes in a `VehicleId` and a `Date` object (in this order). This will assign the parameters to the `id_` and `release_date_` parameters correspondingly.
### Accessors and Mutators
Create accessors and mutators for `id_` and `release_date_`, following the naming conventions covered in class. e.g. for id_, name the accessor `Id`, and the mutator `SetId`.
### Other Member Functions
Create a `void` member function called `Print` that takes in no parameters. `Print` should print the model, vehicle id (VIN), license plate, and release date of the car. The release date should follow the format **mm/dd/yyyy**. See the output below as a reference.
## Other instructions
Complete the `main` function as described. Place your class in `car.h`. Member functions that take more than ten lines or use complex constructs should have their function prototype in `car.h` and implementation in `car.cc`.
Your program does not need to account for the correct dates or license plates. For example: 13/41/1 will be acceptable for your program, even though it is not an acceptable date, and "1111111111111111" will be acceptable in your program, even though it is not a valid license plate number.
## Sample output
```
The model of the car is: Tesla
The VIN of the car is: 121
The license plate of the car is: TUFFY121L
The release date of the car is: 1/1/2022
The model of the car is: Honda
The VIN of the car is: 3
The license plate of the car is: 7B319X4
The release date of the car is: 1/1/2022
The model of the car is: Ford
The VIN of the car is: 1
The license plate of the car is: 123456
The release date of the car is: 11/4/2018
The model of the car is: Honda
The VIN of the car is: 3
The license plate of the car is: 7B319X4
The release date of the car is: 11/4/2018
The model of the car is: Tesla
The VIN of the car is: 121
The license plate of the car is: TUFFY121L
The release date of the car is: 1/1/2022
car.h:
#include "date.h"
#include "vehicleid.h"
#include <string>
#include <iomanip>
#include <iostream>
class Car{
private:
Identifier identity_;
Date release_date_;
public:
Car() {}
Car(Identifier identifier);
Car(Date date);
Car(Identifier identity, Date date);
void set_identity(Identifier identity);
Identifier identity();
Date releasedate();
void set_releasedate(Date date);
void print();
};
data.h:
class Date {
public:
Date() : Date(1, 1, 2022) {}
Date(int day, int month, int year) : day_(day), month_(month), year_(year) {}
int Day() const { return day_; }
void SetDay(int day) { day_ = day; }
int Month() const { return month_; }
void SetMonth(int month) { month_ = month; }
int Year() const { return year_; }
void SetYear(int year) { year_ = year; }
private:
int day_;
int month_;
int year_;
};
vehicleld.h:
#include <string>
class VehicleId {
public:
VehicleId() : VehicleId("Tesla", 121, "TUFFY121L") {}
VehicleId(const std::string &model, int vin, const std::string &license_plate)
: model_(model), vin_(vin), license_plate_(license_plate) {}
int Vin() const { return vin_; }
void SetVin(int vin) { vin_ = vin; }
std::string Model() const { return model_; }
void SetModel(const std::string &model) { model_ = model; }
std::string LicensePlate() const { return license_plate_; }
void SetLicensePlate(const std::string &license_plate) {
license_plate_ = license_plate;
}
private:
// A vehicle identification number (VIN)
int vin_;
std::string model_;
std::string license_plate_;
};
do car.cc and main.cc in C++
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 4 images
i fixed some problems, but i do not know how to fix this, it wants Id in car.h instead of id, and SetId instead of set_identity