1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#include <iostream>;
#include <cstring>;
using namespace std;
class Bug
{
private:
char bugName[30];
int numEyes;
int numLegs;
char color;
public:
void getTraits();
void printTraits(char[30], int, int, char);
Bug();
Bug(char[30], int, int, char);
};
int main ()
{
Bug myBug;
cout << "Welcome To 'Creat Your Own Bug" << endl;
cout << "You will be selecting different traits throughout the program to create a custom bug of your choice" << endl;
cout << "-------------------------------" << endl << endl;
myBug.getTraits();
return 0;
}
Bug::Bug()
{
bugName;
numEyes = 0;
numLegs = 0;
color = '*';
}
Bug::Bug( char[30], int nE, int nL, char col)
{
bugName;
numEyes = nE;
numLegs = nL;
color = col;
}
void Bug::getTraits()
{
cout << "To begin, lets give you bug a name: ";
cin >> bugName;
cout << endl << "Now, your bug gets a choice of a number of Eyes, Legs, and A color of your choice\n";
cout << "How many Eyes would you like your Bug to have(at Least 2)? ";
cin >> numEyes;
if (numEyes < 2)
{
numEyes = 2;
}
else {
numEyes = numEyes;
}
cout << endl << "How many legs would you like you bug to have(at Least 2)?" ;
cin >> numLegs;
if (numLegs < 2)
{
numLegs = 2;
}
else {
numLegs = numLegs;
}
cout << endl << "Lastly, what color would you like your bug to be: " << endl;
cout << "w : White\nb : Blue\n g : Green\ny : Yellow\n";
cin >> color;
cout << endl << endl;
cout << "-------------------------------" << endl;
printTraits(bugName, numEyes, numLegs, color);
}
| |