Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Current errors that I receive:
- Random.cpp:71: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x
- Random.cpp:71: error: invalid conversion from βchar*β to βcharβ
- */
- #include <iostream>
- struct Armor
- {
- int Defense;
- char Name[50];
- };
- // 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
- struct Inventory
- {
- int Gold;
- Armor Armors;
- };
- void Shop();
- int main()
- {
- Shop();
- return 0;
- }
- void Shop()
- {
- // Structs for Armor and for inventory items, see before int main()
- Armor Light_Armor[10] =
- {
- {5,"Cloth pants"},
- {5,"Cloth shirt"},
- {1,"Sandals"},
- {8,"Leather chestpiece"},
- {8,"Light leather pants"},
- {3,"Leather boots"},
- };
- Inventory Items[12] =
- {
- {100}
- };
- std::cout << "Welcome to the shop\n";
- std::cout << "You currently have " << Items[0].Gold << " gold\n";
- std::cout << "To purchase an item, enter the number listed before it\n";
- bool Shop_Loop = true;
- while(Shop_Loop)
- {
- std::cout << "Items currently avaliable:\n";
- std::cout << "(1)(Cost: 20 gold) " << Light_Armor[0].Name << std::endl;
- std::cout << "(2)(Cost: 20 gold) " << Light_Armor[1].Name << std::endl;
- std::cout << "(3)(Cost: 40 gold) " << Light_Armor[3].Name << std::endl;
- std::cout << "(4)(Cost: 40 gold) " << Light_Armor[4].Name << std::endl;
- int Shop_Choice;
- std::cin >> Shop_Choice;
- // Bunch of choices for when the person buys something
- switch(Shop_Choice)
- {
- case 1:
- std::cout << "You have purchased the " << Light_Armor[0].Name << std::endl;
- Items[0].Gold = Items[0].Gold - 20;
- // ERROR IS HERE: fucking arrays how do they work, I am probably majorly screwing up here out of stupidity
- Items[1].Armors.Name = {Light_Armor[0].Name};
- break;
- case 2:
- std::cout << "You have purchased the " << Light_Armor[1].Name << std::endl;
- Items[0].Gold = Items[0].Gold - 20;
- break;
- case 3:
- std::cout << "You have purchased the " << Light_Armor[3].Name << std::endl;
- Items[0].Gold = Items[0].Gold - 40;
- break;
- case 4:
- std::cout << "You have purchased the " << Light_Armor[4].Name << std::endl;
- Items[0].Gold = Items[0].Gold - 40;
- break;
- }
- std::cout << "Do you wish to continue browsing?(y/n)";
- char Browsing_Choice;
- std::cin >> Browsing_Choice;
- if(Browsing_Choice == 'y')
- {
- continue;
- }
- if(Browsing_Choice == 'n')
- {
- std::cout << "Thanks for shopping.\n";
- Shop_Loop = false;
- }
- }
- }
Add Comment
Please, Sign In to add comment