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
|
#include <iostream>
#include<string>
#include<ctime>
#include<cstdlib>
using namespace std;
int getrand ();
class bunny{
public:
void setname (string x)
{
name = x;
}
string getname()
{
return name;
}
private:
string name;
};
string namelist ();
main()
{
bunny bun1;
bun1.setname (namelist());
cout << bun1.getname()<<endl;
}
int getrand ()
{
srand(time(0));
return 1+(rand()%6);
}
string namelist ()
{
string namearray [15] = {"frufru ","baxter ","voldermort ","falafal ","fluffles "," flopsy "," panhandle ",
" bruchetta "," cottonflop "," pixie ","bouviay","lightening","cellotape","bonapart","jackson"};
string none = namearray [getrand()];
string ntwo =namearray [getrand()*2];
string nthree=namearray [getrand()*3];
string fullname=none+ntwo+nthree;
return fullname;
}
|