Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdio.h>
- #include <string>
- #include <iostream>
- #include "Car.h"
- using namespace std;
- class Car{
- private:
- // Member variables
- int yearModel;
- string make;
- int speed;
- public:
- // Mutator method prototypes
- void setYearModel(int);
- void setMake(string);
- void setSpeed(int);
- void accelerate(int);
- void brake(int);
- // Accessor method prototypes
- int getYearModel() const;
- string getMake() const;
- int getSpeed() const;
- };
- // Assigns the model year of the car to yearModel
- void Car::setYearModel(int yearModel){
- yearModel = yearModel;
- }
- // Assigns the name of the car to make
- void Car::setMake(string make){
- make = make;
- }
- // Assigns the speed value of the car to speed
- void Car::setSpeed(int speed){
- speed = speed;
- }
- // Adds 5 to speed
- void Car::accelerate(int speed){
- speed += 5;
- }
- // Subtracts 5 from speed
- void Car::brake(int speed){
- speed -= 5;
- }
- // Returns the model year
- int Car::getYearModel() const{
- return yearModel;
- }
- // Returns the name of the car
- string Car::getMake() const{
- return make;
- }
- int Car::getSpeed() const{
- return speed;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement