Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#ifndef VEHICLE_H #define VEHICLE_H /* @file vehicle.cpp @author < Fill Me In >

ID: 3708505 • Letter: #

Question

#ifndef VEHICLE_H #define VEHICLE_H
/* @file vehicle.cpp    @author < Fill Me In > @date < Fill Me In >
@description Implements 5 classes for vehicle information */
#include <string>
using namespace std;
const int CURRENT_YEAR = 2018; // Use this variable whever you are doing // your price/year calculations.
// Insert your classes below!



#endif #ifndef VEHICLE_H #define VEHICLE_H
/* @file vehicle.cpp    @author < Fill Me In > @date < Fill Me In >
@description Implements 5 classes for vehicle information */
#include <string>
using namespace std;
const int CURRENT_YEAR = 2018; // Use this variable whever you are doing // your price/year calculations.
// Insert your classes below!



#endif *****************************************
/* @file vehicle_test.cpp    @author < Fill Me In > @date < Fill Me In >
@description Tests for the classes in the vehicle.h file: Bicycle, Car, Truck, Airplane */
#include "gtest/gtest.h"
#include "vehicle.h"
TEST(car,name){ Car a; a.setName("Olds"); EXPECT_EQ(a.getName(), "Olds"); }
// Insert more tests here /* @file vehicle_test.cpp    @author < Fill Me In > @date < Fill Me In >
@description Tests for the classes in the vehicle.h file: Bicycle, Car, Truck, Airplane */
#include "gtest/gtest.h"
#include "vehicle.h"
TEST(car,name){ Car a; a.setName("Olds"); EXPECT_EQ(a.getName(), "Olds"); }
// Insert more tests here ************************************************* /* @file vehicle-sandbox.cpp @author <fill me in> @date <fill me in>
@description Sandbox for the Bicycle, Car, Truck and Airplane classes */
#include <iostream>

#include "vehicle.h"
using namespace std;
int main(int argc, char* argv[]){ // Use this program to test your implementation!       } /* @file vehicle-sandbox.cpp @author <fill me in> @date <fill me in>
@description Sandbox for the Bicycle, Car, Truck and Airplane classes */
#include <iostream>

#include "vehicle.h"
using namespace std;
int main(int argc, char* argv[]){ // Use this program to test your implementation!       }

Objective: The objective of this homework is to create a set of subclasses and a base class. Task 1: Downlod the following files and view the demo-code from class I. Dounloaod the starter code here: Type make to compile the vehic Type make test to run the vehicle test.cpp ile x.cpp file. Task 2: Create a base class and sub-classes inside vehicle.h Create a vehicle.h file Your task is to create 4 classes, Bike, Car, Truck, Airplane. It is your job to choose appropriate types for all variables. Each class below should have it's own constructor which specifies all parameters You MUST create a base class (Vohiclo is a good name) to make your life Here are the specifications for the classes: 1. Bike elass: a. getColor, setColor - stored as a string b. getPrice - Returns a float. A new bike is $1000, and it depreciates 100 per year, down to 0, c. 1 passenger only d. 2 wheels e. getYear, setYear- stored as an int Year built Use the current year if the F10 F11 5 6 8 9

Explanation / Answer

ANS:-

vahicle.h:

#ifndef VEHICLE_H
#define VEHICLE_H

/*    @file vehicle.cpp
      @author < Fill Me In >
      @date < Fill Me In >
           @description Implements 5 classes for vehicle information
*/

#include <string>

using namespace std;

const int CURRENT_YEAR = 2017; // Use this variable whever you are doing
                                // your price/year calculations.

// Insert your classes below!

class vehicle{
    private: string color;
             float prise;
             int number; //number of passengers
          
    public:
        vehicle(){
      
      
    }
        string getColor(){
            return color;
        }
        void setColor(string col){
            color=col;
        }
      
        float getPrice(){
            return price;
        }
      
    
      
        int getPassenger(){
            return
        }
        void setPassenger(int i){
            n=i;
        }
  
} ;

class Bile : public vahicle{
    getPrice(int n){
        number=n;
        if(number==1){
            price = 1000;
        }
        return price;
    }
  
};

class Car : public vahicle{
    getPrice(int n, char ch1, char ch2){
        number=n;
        if(ch1=='y'&& ch2==Y){
            price = (n*5000)+200+100;
        }
        if(ch1=='y'|| ch2==Y){
            price = (n*5000);
        }
        if(ch1!='y'&& ch2==Y){
            price = (n*5000)+100;
        }
        if(ch1=='y'&& ch2!=Y){
            price = (n*5000)+100;
        }
        return price;
    }
  
};

class truck : public vahicle{
    getPrice(int n, char ch1, char ch2){
        number=n;
        if(ch1=='y'&& ch2==Y){
            price = 10000+(n*1000)+200+200;
        }
        if(ch1=='y'|| ch2==Y){
            price = 10000+(n*1000);
        }
        if(ch1!='y'&& ch2==Y){
            price = 10000+(n*1000)+200;
        }
        if(ch1=='y'&& ch2!=Y){
            price = 10000+(n*1000)+200;
        }
        return price;
    }
  
};

class airplane public vahicle{
    getPrice(int n, char ch1, char ch2){
        number=n;
        if(ch1=='y'&& ch2==Y){
            price = 15000+(n*1000)+2000+1000;
        }
        if(ch1=='y'|| ch2==Y){
            price = (n*1000);
        }
        if(ch1!='y'&& ch2==Y){
            price = 15000+(n*1000)+1000;
        }
        if(ch1=='y'&& ch2!=Y){
            price = 15000+(n*1000)+1000;
        }
        return price;
    }
  
};#endif

main.cpp

#include "gtest/gtest.h"

#include "vehicle.h"

TEST(car,name){
Car a;
a.setName("Olds");
EXPECT_EQ(a.getName(), "Olds");
}
int main(){
vehicle vih;
int n1;
char ch1,ch2;
cout<<"enter no of passengers";
cin>>n1;
cout<<"do you need air-conditioning (y/n)";
cin>>ch1;

cout<<"do you need DVD (y/n)";
cin>>ch2;
if(n1<=2)
vih.getBike(n1,ch1,ch2);
if(n1>=3 && n1<<=4)
    vih.getCar(n1,ch1,ch2);
if(n1>=5 && n1<<=10)
    vih.getTruck(n1,ch1,ch2);
if(n1>=11 && n1<<=40)
    vih.getAirPlane(n1,ch1,ch2);
}