Can anyone help. I created a program and now I must create a header file to use with it. Here is the assingment and the code I have written so far. Any help would be appreciated. I am new at C++ and trying to figure this out, but i'm lost. Please let me know if I'm on the right track with my code or any suggestions:
// File Auto.h -- Auto class specification file
#ifndef AUTO_H
#define AUTO_H
const int AUTO_ARRAY;
class Auto
{
private:
int autoCollection[AUTO_ARRAY];
string automake;
int autoyear;
int autospeed;
public:
//Overloaded Contstructor
Auto(string m='Porsche', int y = 2010, int s = 200)
{
automake = m;
autoyear = y;
autospeed = s;
}
~Auto()
void setMake(string); //mutator function
void setYear(int); //mutator function
void setSpeed(int); //mutator function
void Accelerate(int);
void Brake(int);
string getMake();
int getYear();
int getSpeed();
};
#endif
/***********************************************************
//Auto1.cpp - Auto class function implementation file
//Auto::Accelerate function
void Auto::Accelerate(int moreSpeed)
{
if(s <= 200)
moreSpeed += 200 - s;
else{
cout<<"Speed is greater than maximum speed!\n";
}
}
//*************************************
//Auto::Brake function
void Auto::Brake(int lessSpeed)
{
if(s > 200)
lessSpeed -= s-200;
else{
cout<<"Speed is less than maximum speed!\n";
}
//***************************************
//Auto getMake function
string Auto::getMake()
{
return automake;
}
//**********************************
//Auto::getYear function
int Auto::getYear()
{
return autoyear;
}
//**********************************
//Auto::getSpeed function
int Auto::getSpeed()
{
return autospeed;
}
/************************************
const int AUTO_ARRAY;
int autoCollection[AUTO_ARRAY] = {Porshe};
Auto car;
string carMake;
int carYear;
int carSpeed;
int mSpeed;
int lSpeed;
cout<<"What is the make of the auto? ";
cin>>carMake;
cout<<"What is the year the auto was made? ";
cin>>carYear;
cout<<"What is the speed of the auto? ";
cin>>carSpeed;
cout<<"This is the information for the automobile: "<<endl;
cout<<"The make of the automobile is: "<<car.getMake()<<endl;
cout<<"The year the automobile was made is: "<<car.getYear()<<endl;
cout<<"The speed of the automobile is: "<<car.getSpeed()<<endl;