Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 2.58 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /* Current errors that I receive:
  2.  
  3. Random.cpp:71: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x
  4. Random.cpp:71: error: invalid conversion from ‘char*’ to ‘char’
  5.  
  6. */
  7.  
  8. #include <iostream>
  9.  
  10. struct Armor
  11.         {
  12.                 int Defense;
  13.                 char Name[50];
  14.         };
  15.  
  16. // Tried to put a struct inside of a struct so I could access name in the Armor struct (it seemed to eliminate some errors lol
  17. struct Inventory
  18.         {
  19.                 int Gold;
  20.                 Armor Armors;
  21.         };
  22.  
  23. void Shop();
  24.  
  25. int main()
  26. {
  27.        
  28.  
  29.  
  30.         Shop();
  31.  
  32.  
  33.         return 0;
  34. }
  35.  
  36.  
  37. void Shop()
  38. {
  39.         // Structs for Armor and for inventory items, see before int main()
  40.         Armor Light_Armor[10] =
  41.         {
  42.                 {5,"Cloth pants"},
  43.                 {5,"Cloth shirt"},
  44.                 {1,"Sandals"},
  45.                 {8,"Leather chestpiece"},
  46.                 {8,"Light leather pants"},
  47.                 {3,"Leather boots"},
  48.         };
  49.  
  50.         Inventory Items[12] =
  51.         {
  52.                 {100}
  53.         };
  54.  
  55.  
  56.         std::cout << "Welcome to the shop\n";
  57.         std::cout << "You currently have " << Items[0].Gold << " gold\n";
  58.         std::cout << "To purchase an item, enter the number listed before it\n";
  59.  
  60.         bool Shop_Loop = true;
  61.  
  62.         while(Shop_Loop)
  63.         {
  64.                 std::cout << "Items currently avaliable:\n";
  65.                 std::cout << "(1)(Cost: 20 gold) " << Light_Armor[0].Name << std::endl;
  66.                 std::cout << "(2)(Cost: 20 gold) " << Light_Armor[1].Name << std::endl;
  67.                 std::cout << "(3)(Cost: 40 gold) " << Light_Armor[3].Name << std::endl;
  68.                 std::cout << "(4)(Cost: 40 gold) " << Light_Armor[4].Name << std::endl;
  69.        
  70.                 int Shop_Choice;
  71.                 std::cin >> Shop_Choice;
  72.  
  73.                 // Bunch of choices for when the person buys something
  74.                 switch(Shop_Choice)
  75.                 {
  76.                         case 1:
  77.                         std::cout << "You have purchased the " << Light_Armor[0].Name << std::endl;
  78.                         Items[0].Gold = Items[0].Gold - 20;
  79.                         // ERROR IS HERE: fucking arrays how do they work,  I am probably majorly screwing up here out of stupidity
  80.                         Items[1].Armors.Name = {Light_Armor[0].Name};
  81.                         break;
  82.  
  83.                         case 2:
  84.                         std::cout << "You have purchased the " << Light_Armor[1].Name << std::endl;
  85.                         Items[0].Gold = Items[0].Gold - 20;
  86.                         break;
  87.  
  88.                         case 3:
  89.                         std::cout << "You have purchased the " << Light_Armor[3].Name << std::endl;
  90.                         Items[0].Gold = Items[0].Gold - 40;
  91.                         break;
  92.        
  93.                         case 4:
  94.                         std::cout << "You have purchased the " << Light_Armor[4].Name << std::endl;
  95.                         Items[0].Gold = Items[0].Gold - 40;
  96.                         break;                 
  97.  
  98.  
  99.                 }
  100.                
  101.                 std::cout << "Do you wish to continue browsing?(y/n)";
  102.                 char Browsing_Choice;
  103.                 std::cin >> Browsing_Choice;
  104.                
  105.                 if(Browsing_Choice == 'y')
  106.                 {
  107.                         continue;
  108.                 }
  109.                 if(Browsing_Choice == 'n')
  110.                 {
  111.                         std::cout << "Thanks for shopping.\n";
  112.                         Shop_Loop = false;
  113.                 }
  114.  
  115.         }
  116.  
  117.  
  118. }