コード例 #1
0
ファイル: main.cpp プロジェクト: Alfredof10/C_Space
//***********************************************************************************
// 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
コード例 #2
0
ファイル: main.cpp プロジェクト: Alfredof10/C_Space
//***********************************************************************************
// void checkIfAtPlanet()  
// This fucntion checks to see if you have arrived at a planet, then it'd put you
// in the store.
// 
//**********************************************************************************
void checkIfAtPlanet(ship &s,planet &jupiter,planet &earth,planet &mars,planet &ganymede,planet &moon,planet &saturn,planet &neptune,planet &pluto,planet &ceres)
{
   short input = 0;
//**********************************************************************************
// 1. Jupiter
//**********************************************************************************
	if (s.getX()==jupiter.getX() && s.getY()==jupiter.getY())
    {
	   jupiter.Shop(s);
	
	  
	}
      // end of jupiter if
//**********************************************************************************
// 2. Earth
//**********************************************************************************
      if (s.getX()==earth.getX() && s.getY()==earth.getY())
   {
	   earth.Shop(s);
	
	 
	}
// end of earth if	   
//**********************************************************************************
// 3. Mars
//**********************************************************************************
      if (s.getX()==mars.getX() && s.getY()==mars.getY())
   {
	   mars.Shop(s);
	
	  
	}
// end of mars if
//**********************************************************************************
// 4. Ganymede
//**********************************************************************************
   if (s.getX()==ganymede.getX() && s.getY()==ganymede.getY())
   {
	   
	  ganymede.Shop(s);
	  
 
    }
//**********************************************************************************
// 5. Saturn
//**********************************************************************************
   if (s.getX()==saturn.getX() && s.getY()==saturn.getY())
   {

       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