#include <iostream>;
#include <string>;
#include <random>;
using namespace std;
class Auto
{
public:
void Start();
void Accelerate();
void Break();
string model;
string cylinder;
Auto(string x, string y)
{
model = x;
cylinder = y;
}
};
void Start()
{
cout << "Start\n";
}
void Accelerate()
{
cout << "Accelerate\n";
}
void Break()
{
cout << "Break\n";
}
int main()
{
srand(time(NULL));
int randomAction;
int randomAuto;
randomAction = (rand() % 3) + 1;
randomAuto = (rand() % 3) + 1;
switch (randomAction)
{
case 1:
Start();
break;
case 2:
Accelerate();
break;
case 3:
Break();
break;
}
Auto auto1("CADILAC", "5");
Auto auto2("Ferrari", "7");
Auto auto3("Lamborghini", "9");
switch (randomAuto)
{
case 1:
cout << "The model is: " << auto1.model << ", and the cylinder is: " << auto1.cylinder << endl;
break;
case 2:
cout << "The model is: " << auto2.model << ", and the cylinder is: " << auto2.cylinder << endl;
break;
case 3:
cout << "The model is: " << auto3.model << ", and the cylinder is: " << auto3.cylinder << endl;
break;
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter