PS 8
- Write a car class; it should have two variables, a bool on and a string noise. It should have default constructor which sets on to false and noise to "vroom" and another constructor which sets on to false and sets the noise to whatever you tell it. It should have a method go() which prints the value of noise iff on is true and a second method switch_on() should set on to true. The programme
#include<cstdlib>
#include "Car.cpp";
using namespace std;
int main()
{
Car vw;
Car audi("Roorr");
vw.switch_on();
vw.go();
audi.go();
}
should produce the output vroom.
If you don't get your programme to compile write a comment saying it doesn't compile at the top of you code when you hand it in.