SHARE
TWEET

Map Navigator Part II Main.cpp

zCool May 13th, 2012 8 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "Map.h"
  2. #include<iostream>
  3. #include<string>
  4. #include<vector>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.         vector<Map> mapVector;
  11.         Map capitol(0, "Capitol", "Where the hunger games are held every year.  It is the capitol \
  12. city of Panem.  The capitol is a wealthy urban city supported by its sourrounding impovershed \
  13. twelve districts.", "", "District 1", "", "District 11");
  14.         Map district1(1, "District 1",  "District 1 produces luxury items for the capital.  They are known for\
  15. producing 'Careers', children who are chosen to train specifically for the hunger games.", "Capitol", "",
  16. "", "District 12");
  17.         Map district11(2, "District 11", "District 11 produces agriculture products, the girl Rue, a 12 year old tribute is from \
  18. District 11.  Rue is frail, but wily as she can manuevar easily in the trees.\
  19. Rue teams up with Katniss during the hunger games until she is killed by District 1's Marvel.", "", "District 12",
  20. "Capitol", "");
  21.         Map district12(3, "District 12", "District 12 produces coal, Katniss Everdeen and Peeta Mallark \
  22. are the two hunger games tributes from District 12.", "District 11", "", "District 1", "");
  23.  
  24.         mapVector.push_back(capitol);
  25.         mapVector.push_back(district1);
  26.         mapVector.push_back(district11);
  27.         mapVector.push_back(district12);
  28.  
  29.         string userInput = "";
  30.         int currentMap = capitol.getmapIndex(); //start at the capitol
  31.  
  32.         while(userInput.compare("Exit") != 0)
  33.         {
  34.                 cout << "You are in the " << mapVector[currentMap].getName() << ".\n";
  35.                 cout << mapVector[currentMap].getDescription() << endl;
  36.  
  37.                 cout << "Enter a Direction: ";
  38.                 getline(cin, userInput);
  39.                
  40.                 while(userInput.compare("West") != 0
  41.                         && userInput.compare("East") != 0
  42.                         && userInput.compare("North") != 0
  43.                         && userInput.compare("South") != 0
  44.                         && userInput.compare("Exit") != 0)
  45.                 {
  46.                         cout << "Enter a Direction: ";
  47.                         getline(cin, userInput);
  48.                 }
  49.  
  50.                 if(userInput.compare("Exit") !=0)
  51.                 {
  52.                         //map has a neighbor in direction
  53.                         if(mapVector[currentMap].getNeighbor(userInput) != -1)
  54.                         {
  55.                                 currentMap = mapVector[currentMap].getNeighbor(userInput);
  56.                         }
  57.  
  58.                         //map does not have a neighbor in that direction
  59.                         else if(mapVector[currentMap].getNeighbor(userInput) == -1)
  60.                         {
  61.                                 cout << "Sorry there is nothing to the " << userInput << ".\n";
  62.                         }
  63.  
  64.                 }
  65.         }
  66.  
  67.  
  68. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top