BHXSpecter

Moosader Assignment 1 Test 1 (Modified)

Aug 7th, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char **argv)
  7. {
  8.     string name, kingdom, place, favItem, sex;
  9.     bool sxfull = false;
  10.     string heshe, himher, hisher;
  11.     int len = 0;
  12.    
  13.     // Assignment 1 Test 1 - Short Story
  14.     /* Append == customized short story */
  15.     cout << "This is a customized story for the user.\n "
  16.          << "Please maximize the window before entering data to make it more readable.\n"
  17.          << "***Please keep entries less than 20 characters.***\n";
  18.     cout << "Enter your name: ";
  19.     getline(cin, name, '\n');
  20.     len = name.length();
  21.     while(len > 20)
  22.     {
  23.         cout << "Too long, less than 20 characters!\nEnter your name:";
  24.         getline(cin, name, '\n');
  25.         len = name.length();
  26.     }
  27.    
  28.     while(!sxfull)
  29.     {
  30.         cout << "Enter the sex (M/F): ";
  31.         getline(cin, sex, '\n');
  32.         if(sex == "m")
  33.             break;
  34.         else if(sex == "M")
  35.             break;
  36.         else if(sex == "f")
  37.             break;
  38.         else if(sex == "F")
  39.             break;
  40.         else
  41.             cout << "You MUST enter M or F for sex!\n";
  42.     }
  43.     cout << "Enter a name for the kingdom: ";
  44.     getline(cin, kingdom, '\n');
  45.     len = kingdom.length();
  46.     while(len > 20)
  47.     {
  48.         cout << "Too long, less than 20 characters!\nEnter a name for the kingdom: ";
  49.         getline(cin, kingdom, '\n');
  50.         len = kingdom.length();
  51.     }
  52.     cout << "Enter your favorite place: ";
  53.     getline(cin, place, '\n');
  54.     len = place.length();
  55.     while(len > 20)
  56.     {
  57.         cout << "Too long, less then 20 characters!\nEnter your favorite place: ";
  58.         getline(cin, place, '\n');
  59.         len = place.length();
  60.     }
  61.     cout << "Enter you favorite item: ";
  62.     getline(cin, favItem);
  63.     len = favItem.length();
  64.     while(len > 20)
  65.     {
  66.         cout << "Too long, less than 20 characters!\nEnter your favorite item: ";
  67.         getline(cin, favItem);
  68.         len = favItem.length();
  69.     }
  70.    
  71.     if (sex == "M" || sex == "m")
  72.     {
  73.         heshe = "he";
  74.         himher = "him";
  75.         hisher = "his";
  76.     }
  77.     else
  78.     {
  79.         heshe = "she";
  80.         himher = "her";
  81.         hisher = "her";
  82.     }
  83.     cout << "\n\n\n\n"
  84.          << "\t\t========================================\n"
  85.          << "\t\t========================================\n"
  86.          << "\t\t======== The Great Misadventure ========\n"
  87.          << "\t\t========================================\n"
  88.          << "\t\t========================================\n\n"
  89.          // pagraph 1 - intro
  90.          << "\tThis is the tale of " << name << " and the magical " << favItem << ". In the kingdom of\n"
  91.          << kingdom << ", in the corner of a " << place << ", sat the ever quiet " << name << " contemplating how to\n"
  92.          << "become rich and famous. " << name << " just knew " << heshe << " had greatness locked deep down inside\n"
  93.          << "of " << himher << ", but didn't know how to unlock all that potential. The kingdom has been attacked by\n"
  94.          << "a troll who loved to eat " << favItem << " all day long.\n\n"
  95.          // paragraph 2
  96.          << "\tThat is how " << name << " would become famous, by defeating the evil troll. The kingdom would recognize " << himher << "\n"
  97.          << "as the great hero " << heshe << " had always dreamed about. " << name << " asked around about the troll when he found out\n"
  98.          << "about " << kingdom << "'s witch who could take a regular " << favItem << " and turn it magical in order to beat the troll.\n"
  99.          << name << " climbed down the long, moldy stars that lead to the dimly lit room of the dark, dank dungeon where the witch resided.\n"
  100.          << "Upon entering her chamber, " << name << " felt a sense of fear rush over " << himher << " as the witch was in a huge stone throne\n"
  101.          << "with the back towards " << name <<". Thoughts of what the witch would look like ran through " << hisher << " head. Suddenly the witch\n"
  102.          << "stood up and started to turn. Trembling, " << name << " stepped forward. The witch turned to face him, revealing she wasn't ugly\n"
  103.          << "like " << name << " had originally thought. In fact, she was stunning, but why would she live in a dungeon? " << name << " was\n"
  104.          << "utterly confused. The witch had been expecting " << name << " and already had the " << favItem << " magically enchanted and ready\n"
  105.          << "for " << himher << ". Now it was time for " << himher << " to set out to find the troll that has been attacking " << kingdom << "\n"
  106.          << "and beat it once and for all.\n\n"
  107.          // paragraph 3
  108.          << name << " went into the jungle outside the kingdom toward the old covered bridge where the troll was known to live. Every knight sent\n"
  109.          << "to beat the troll had never returned. " << name << " knew the danger, but " << hisher << " drive for fame was stronger than the fear\n"
  110.          << "of the quest to vanquish the troll. When " << heshe << " entered the cavern under the bridge, " << name << " couldn't believe what " << heshe << "\n"
  111.          << "saw, the troll sitting there crying because all the " << favItem << " had been eaten and the troll had no more left. Turns out the trolls attacks\n"
  112.          << "weren't attacks, but rather just food searches. " << name << " gave the troll the enchanted " << favItem << " while " << name << " watched\n"
  113.          << "the troll eat it and to his surprise another one appear in front of the troll. The enchantment was to make a new one appear, thus ending the\n"
  114.          << "attacks on the village and making " << name << " a true hero...to the troll at least.\n\n"
  115.        
  116.          << "\t\t\tT     D\n"
  117.          << "\t\t\t H   N\n"
  118.          << "\t\t\t  E E\n";
  119.    
  120.     return 0;
  121. }
Advertisement
Add Comment
Please, Sign In to add comment