本文整理汇总了C++中Human::getMoney方法的典型用法代码示例。如果您正苦于以下问题:C++ Human::getMoney方法的具体用法?C++ Human::getMoney怎么用?C++ Human::getMoney使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Human
的用法示例。
在下文中一共展示了Human::getMoney方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: win
/*******************************************************************************
* Win
*******************************************************************************
* purpose: To determine the winner
* input:
* p1bal-> player 1's balance
* c1bal-> computers balance
* game-> to determine if the game is over
* output:
* game-> sets game = to false
*
*/
int win(Human &h,int &c1bal,bool&game){
//Wins when computer has no money
if(h.getMoney()<=0){
cout<<"You lose!!!\n";
game=false;
}else if(c1bal<=0){
cout<<"You win!!\n";
game=false;
}
}
示例2: pay
int pay(Human &h,int &c1bal,int c1loc,bool who){
if(who==true){
if(h.getloc()==4){
cout<<"You paid $200 to the bank\n";
h.setmoney(h.getMoney()-200);
}else if(h.getloc()==38){
cout<<"You paid $100 to the bank\n";
h.setmoney(h.getMoney()-100);
}
}else if(who==false){
if(c1loc==4){
cout<<"The computer paid $200 to the bank\n";
c1bal-=200;
}else if(c1loc==38){
cout<<"The computer paid $100 to the bank\n";
c1bal-=100;
}
}
}
示例3: move
/*******************************************************************************
move
*******************************************************************************
* purpose: To move Player around the board
* input:
* p1loc-> takes in the players location on the board
* p1-> to move computer around the board c1 times
* p1bal-> if passed go add $200
* pmove[]->sets new location for computer
* output:
* p1bal->if passed go collect $200
* p1loc->if passed go starts at the beginning
*/
int move(Human &h,int pmove[]){
//Used to make sure the board is set to 0
for(int i=0;i<SIZE;i++){
pmove[i]=0;
}
for(int i=0;i<=h.getroll();i++){
if(h.getloc()>39){
h.setloc(h.getloc()-39);
cout<<"You passed 'Go' please collect $200\n";
h.setmoney(h.getMoney()+200);
}else{
pmove[h.getloc()]=1;
}
}
}
示例4: main
//.........这里部分代码省略.........
case 1:{
do{
if(game!=false){
if(cprison==false){
turn=2;
cprison=true;
}else{
turn=1;
}
for(int i=1;i<=turn;i++){
who=true;
h.setroll(roll(6,2));
cout<<"Player 1 you rolled your dice and got "<<h.getroll()<<endl;
cout<<"Move forward "<<h.getroll()<<" spaces."<<endl;
pmove[h.getloc()]=0;
h.setloc(h.getloc()+h.getroll());
move(h,pmove);
cout<<"You landed on "<<property[h.getloc()]<<endl;
if(h.getloc()==4 || h.getloc()==38){
pay(h,c1bal,c1loc,who);
}
if(h.getloc()==7 || h.getloc()==22 || h.getloc()==36){
chance(h,pmove,c1loc,cmove,c1,c1bal,prison,cprison,who);
}
if(h.getloc()==2 || h.getloc()==17 || h.getloc()==33){
chest(h,pmove,c1loc,cmove,c1,c1bal,prison,cprison,who);
}
if(h.getloc()==30){
prison=false;
jail(h,pmove,c1loc,cmove,c1,who);
}
cout<<"Your balance is $"<<h.getMoney()<<endl;
//Output the board
display(pmove,cmove);
//Used to check if player lands on a computer owned location
for(int i=0;i<c1prop.size();i++){
if(h.getloc()==c1prop[i]){
h.setmoney(h.getMoney()-rent[h.getloc()]);
c1bal+=rent[h.getloc()];
cout<<"Computer owns "<<property[h.getloc()]<<" you owe $"<<rent[h.getloc()]<<" for rent\n";
}
}
//To determine the winner
win(h,c1bal,game);
if(game==false){
break;
}
do{
do{
cout<<"1. Buy Property\n2. See your property\n3. End turn\n";
cin>>buyans;
if(buyans<1 || buyans>3){
cout<<"Invalid Input\n";
}
}while(buyans<1 || buyans>3);
switch(buyans){
case 1:{
if(avail[h.getloc()]==false){
cout<<"You cannot buy this property\n";
}else if(avail[h.getloc()]==true){
cout<<"You can buy this property\n";
board[h.getloc()].print();
do{
cout<<"Press 'Y' if you want to buy this property,or 'N' if you do not\n";
示例5: chest
int chest(Human &h, int pmove[], int &c1loc, int cmove[],int &c1,int &c1bal,bool &prison,bool &cprison,bool &who){
int random=rand()%15+1;
if(who==true){
switch(random){
case 1:{
cout<<"Community Chest: Make it Big in HollyWood. Collect $2000 in a movie deal\n";
h.setmoney(h.getMoney()+2000);
break;
}
case 2:{
cout<<"Community Chest: You promote your new Book on tv morning news. Receive $100 in bonus sales\n";
h.setmoney(h.getMoney()+100);
break;
}
case 3:{
cout<<"Community Chest: Advance to 'Go'(Collect $200)\n";
pmove[h.getloc()]=0;
h.setroll(0);//IDK if i need it????????????????????????????????????????
h.setloc(0);
move(h,pmove);
cout<<"You passed 'Go' collect $200\n";
h.setmoney(h.getMoney()+200);
break;
}
case 4:{
cout<<"Community Chest: Your trust fund becomes available. Collect $500\n";
h.setmoney(h.getMoney()+500);
break;
}
case 5:{
cout<<"Community Chest: Take dance lessons with a celebrity coach. Pay $500\n";
h.setmoney(h.getMoney()-500);
break;
}
case 6:{
cout<<"Community Chest: You run for mayor. Collect $100 from each player to fund your campaign\n";
c1bal-=100;
h.setmoney(h.getMoney()+100);
break;
}
case 7:{
cout<<"Community Chest: You coordinate opening day activities at progressive field. Collect $250 for your services\n";
h.setmoney(h.getMoney()+250);
break;
}
case 8:{
cout<<"Community Chest: Your computer network gets hit with a virus. Pay $1000\n";
h.setmoney(h.getMoney()-1000);
break;
}
case 9:{
cout<<"Community Chest: Sell your lifetime, 50-yard line, season tickets on e-bay. Collect $200\n";
h.setmoney(h.getMoney()+200);
break;
}
case 10:{
cout<<"Community Chest: Win big at the casino. Collect $1000\n";
h.setmoney(h.getMoney()+1000);
break;
}
case 11:{
cout<<"Community Chest: You owe back taxes. Pay $500 in fines\n";
h.setmoney(h.getMoney()-500);
break;
}
case 12:{
cout<<"Community Chest: You win the lottery. Collect $1000\n";
h.setmoney(h.getMoney()+1000);
break;
}
case 13:{
cout<<"Community Chest: You are a runner up on a reality Tv show. Collect $100\n";
h.setmoney(h.getMoney()+100);
break;
}
case 14:{
cout<<"Community Chest: Arrested for insider trading. Go to jail. DO NOT PASS 'GO', DO NOT COLLECT $200\n";
prison=false;
jail(h,pmove,c1loc,cmove,c1,who);
break;
}
case 15:{
cout<<"Community chest: Received a presidential pardon. GET OUT OF JAIL FREE. This card may be kept until needed.\n";
break;
}
default: cout<<"Error: In the switch statment\n";
}
}else if(who==false){
switch(random){
case 1:{
cout<<"Community Chest: Make it Big in HollyWood. Collect $2000 in a movie deal\n";
c1bal+=2000;
break;
}
case 2:{
cout<<"Community Chest: You promote your new Book on tv morning news. Receive $100 in bonus sales\n";
c1bal+=100;
break;
}
case 3:{
//.........这里部分代码省略.........
示例6: chance
int chance(Human &h, int pmove[], int &c1loc, int cmove[],int &c1,int &c1bal,bool &prison,bool &cprison,bool &who){
int random=rand()%12+1;
if(who==true){
switch(random){
case 1:{
cout<<"Chance: Convicted of Identity theft, Go to Jail. Do not pass go. Do not collect $200\n";
prison=false;
jail(h,pmove,c1loc,cmove,c1,who);
break;
}
case 2:{
cout<<"Chance: A group of guest wins a class action suit against your hotel pay each player $500\n";
h.setmoney(h.getMoney()-500);
c1bal+=500;
break;
}
case 3:{
cout<<"Chance: Ride First class to reading railroad. If you pass go collect $200\n";
pmove[h.getloc()]=0;
h.setroll(5);//IDK IF I NEED IT?????????????????????????
h.setloc(5);
move(h,pmove);
break;
}
case 4:{
cout<<"Chance: Make a donation for disaster relief. Pay $150\n";
h.setmoney(h.getMoney()-150);
break;
}
case 5:{
cout<<"Chance: Get a tax break for driving a Hybrid. Collect $50\n";
h.setmoney(h.getMoney()+50);
break;
}
case 6:{
cout<<"Chance: Advance to go collect $200\n";
pmove[h.getloc()]=0;
h.setroll(0);//IDK IF I NEED IT?????????????????????????
h.setloc(0);
move(h,pmove);
cout<<"You passed 'Go' collect $200\n";
h.setmoney(h.getMoney()+200);
break;
}
case 7:{
cout<<"Chance: Summoned for jury duty. Go back three spaces.\n";
pmove[h.getloc()]=0;
h.setloc(h.getloc()-3);
pmove[h.getloc()]=1;
break;
}
case 8:{
cout<<"Chance: Take a helicopter ride to BoardWalk. If you pass go collect $200\n";
pmove[h.getloc()]=0;
h.setroll(39);//IDK IF I NEED IT?????????????????????????
h.setloc(39);
move(h,pmove);
break;
}
case 9:{
cout<<"Chance: Accept the position of CEO of a high powered investment banking firm. Collect a signing bonus of $500\n";
h.setmoney(h.getMoney()+500);
break;
}
case 10:{
cout<<"Chance: Jump on a plane to Illinois Avenue. If you pass go collect $200\n";
pmove[h.getloc()]=0;
h.setroll(24);//IDK IF I NEED IT?????????????????????????
h.setloc(24);
move(h,pmove);
break;
}
case 11:{
cout<<"Chance: Splash out on a trip to St. Charles place. If you pass go collect $200\n";
pmove[h.getloc()]=0;
h.setroll(11);//IDK IF I NEED IT?????????????????????????
h.setloc(11);
move(h,pmove);
break;
}
case 12:{
cout<<"Chance: You are acquitted. GET OUT OF JAIL FREE. This card may be kept until needed.\n";
break;
}
default: cout<<"Error: In the switch statment\n";
}
}else if(who==false){
switch(random){
case 1:{
cout<<"Chance: Convicted of Identity theft, Go to Jail. Do not pass go. Do not collect $200\n";
cprison=false;
jail(h,pmove,c1loc,cmove,c1,who);
break;
}
case 2:{
cout<<"Chance: A group of guest wins a class action suit against your hotel pay each player $500\n";
c1bal-=500;
h.setmoney(h.getMoney()+500);
break;
}
//.........这里部分代码省略.........