当前位置: 首页>>代码示例>>C++>>正文


C++ ship::setX方法代码示例

本文整理汇总了C++中ship::setX方法的典型用法代码示例。如果您正苦于以下问题:C++ ship::setX方法的具体用法?C++ ship::setX怎么用?C++ ship::setX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ship的用法示例。


在下文中一共展示了ship::setX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parseMovement

//***********************************************************************************
// int parseStringX()  
// This is a simple function to parse and return the coodinates you want to goto
// 
// 
//**********************************************************************************
void parseMovement(string strX,string strY,ship &s)
{
   int x;
   int y;
   double hypot=0.0;

    

 
   x = atoi(strX.c_str());
   y = atoi(strY.c_str());
  

   if (x == 0)
   {
	s.setX(s.getX());
   }
  
   if (y == 0)
   {
	s.setY(s.getY());
   }


   if (x <= POSITIVE_XLIMIT && x >= NEGATIVE_XLIMIT && y <= POSITIVE_YLIMIT && y >= NEGATIVE_YLIMIT)
  {
  // calculate data for hypotenuese (sp?) and get units for fuel subtraction
   double xc = x-s.getX();
   double yc = y-s.getY();
  
   double xcsq = xc*xc;
   double yxsq = yc*yc;

   double hypot = abs(sqrt(xcsq+yxsq));
	  // error checking for input
	outfile.open("errorLog.txt", ios::app);
	outfile  << "The time is: " << asctime(localtm) << " " << "Hypotenoose: " << hypot << endl;
    outfile.close();
     // ------
	  s.setX(x);  // 
	  s.setY(y);
  
	  s.setFuel(s.getFuel()-hypot);
  }

 

} // end of method
开发者ID:Alfredof10,项目名称:C_Space,代码行数:54,代码来源:main.cpp

示例2: checkIfAtPlanet


//.........这里部分代码省略.........
   {

       saturn.Shop(s);
	 
 
    }
//**********************************************************************************
// 6. Pluto
//**********************************************************************************
	     if (s.getX()==pluto.getX() && s.getY()==pluto.getY())
   {
	
	   pluto.Shop(s);
	 
 
    }
//**********************************************************************************
// 7. Ceres
//**********************************************************************************
		 
		 if (s.getX()==ceres.getX() && s.getY()==ceres.getY())
   {
	 ceres.Shop(s);
	
 
    }
//**********************************************************************************
// 8. Neptune
//**********************************************************************************
		 
		 if (s.getX()==neptune.getX() && s.getY()==neptune.getY())
   {
        neptune.Shop(s);	  
	 
 
    }
//**********************************************************************************
// 9. Moon -- different from planet
//**********************************************************************************
  if (s.getX()==moon.getX() && s.getY()==moon.getY())
   {
	   
	  do 	
	  { // begin do loop
	   
	   input = checkIfAtMoonMenu(s,jupiter,earth,mars,ganymede,moon,saturn,neptune,pluto,ceres);	  
         
	   cout << "1. Check Mail Box: -- Not Functional... " << endl;
	   cout << "2. Repair Ship: -- Not Functional... " << endl;
	   cout << "3. Upgrade Ship: -- Not Functional... " << endl;
	   cout << "4. Pick Up Passengers: -- Not Functional... " << endl;
	   cout << "5. Talk to people listen to space news... -- not functional... " << endl;


       switch(input)
	   {
	   case 1: 
		   system("cls");
           //checkMailBox();   
		   cout << "N/A" << endl;
		   break;
	   case 2:
     	   system("cls");
           //repairShip();
		   cout << "N/A" << endl;
		   break;
	   case 3:
     	   system("cls");
		   //upgradeShip();
           cout << "N/A" << endl;
		   break;
	   case 4:
     	   system("cls");
		   //pickUpPassengers();
           cout << "N/A" << endl;
		   break;
	   case 5:
     	   system("cls");
		   //talkToPeople();
           cout << "N/A" << endl;
		   break;
		case 6:
     	   system("cls");
           cout << "Take Care out there in space..." << endl;
		   break;

	   default:
		     cout << "You can only choose option 1-5 are not programmed, nothing else is programmed... " << endl;
		     break;
	   }// end of switch
       		  
	  } // end of do
	   while (input == 1 || input == 2 || input == 3  || input == 4 || input == 5);
	   s.setX(s.getX()+1);
	   s.setY(s.getY()+1);
 
    }

  s.setX(s.getX()+1);
} // end of method
开发者ID:Alfredof10,项目名称:C_Space,代码行数:101,代码来源:main.cpp


注:本文中的ship::setX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。