Advertisement
Guest User

Untitled

a guest
May 1st, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. /*
  2.     Coded by Simpl0S
  3. */
  4.  
  5. #include <iostream>
  6. #include <list>
  7.  
  8. // Include needed header files
  9. #include "Item.h"
  10. #include "Weapon.h"
  11.  
  12. int main()
  13. {
  14.  
  15.     std::string strPistolName("Pistol"), strShotguntName("Shotgun"), strRifleName("Rifle");
  16.     int nPistolValue{ 10 }, nPistolDamage{ 5 }, nShotgunValue{ 15 }, nShotgunDamage{ 10 },
  17.         nRifleValue{ 20 }, nRifleDamage{ 5 };
  18.  
  19.     Weapon* pPistol = new Weapon(strPistolName, nPistolValue, nPistolDamage);
  20.    
  21.     Weapon* pShotgun = new Weapon(strShotguntName, nShotgunValue, nShotgunDamage);
  22.  
  23.     Weapon* pRifle = new Weapon(strRifleName, nRifleValue, nRifleDamage);
  24.    
  25.     std::list<Weapon*> weaponInventory;
  26.    
  27.     weaponInventory.push_back(pPistol);
  28.     weaponInventory.push_back(pShotgun);
  29.     weaponInventory.push_back(pRifle);
  30.  
  31.     std::list<Weapon*>::iterator weaponInventoryIT;
  32.  
  33.     for (weaponInventoryIT = weaponInventory.begin(); weaponInventoryIT != weaponInventory.end(); ++weaponInventoryIT)
  34.     {
  35.         (*weaponInventoryIT)->printAttributes();
  36.         std::cout << std::endl;
  37.     }
  38.  
  39.     /*
  40.     Pistol.printAttributes();
  41.  
  42.     std::cout << std::endl;
  43.  
  44.     Shotgun.printAttributes();
  45.  
  46.     std::cout << std::endl;
  47.  
  48.     Rifle.printAttributes();
  49.  
  50.     std::cout << std::endl;
  51.     */
  52.  
  53.     delete pPistol;
  54.     delete pRifle;
  55.     delete pShotgun;
  56.  
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement