peterzig

Budynki2

Apr 10th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.30 KB | None | 0 0
  1. // Budynki2.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <string>
  6. #include <iostream>
  7. #include <conio.h>
  8.  
  9. using namespace std;
  10.  
  11. class Building
  12. {
  13.  
  14. public:
  15.     string buildingName;
  16.     int buildCost;
  17.     int maintainCost;
  18.     int resourcesUsed;
  19.     int resourcesProduced;
  20.     Building();
  21.     void addBuilding(int buildCost, int resourcesUsed);
  22. };
  23.  
  24. class Resource
  25. {
  26. public:
  27.     string resourceName;
  28.     int resourceAmount;
  29.     int resourceAdded;
  30.     int resourceDeleted;
  31.     Resource();
  32.     void addResource(int resourceAdded, int resourceAmount);
  33.     void deleteResource(int resourceDeleted, int resourceAmount);
  34. };
  35.  
  36. Building::Building()
  37. {
  38.     buildingName = "Building";
  39.     buildCost = 0;
  40.     maintainCost = 0;
  41.     resourcesUsed = 0;
  42.     resourcesProduced = 0;
  43. }
  44.  
  45. Resource::Resource()
  46. {
  47.     resourceName = "Resource";
  48.     resourceAmount = 0;
  49.     resourceAdded = 0;
  50.     resourceDeleted = 0;
  51. }
  52.  
  53. void Resource::addResource(int resourceAdded, int resourceAmount)
  54. {
  55.     resourceAmount += resourceAdded;
  56.  
  57. }
  58.  
  59.  
  60.  
  61.  
  62. int main()
  63. {
  64.     Building Quarry;
  65.     Quarry.buildingName = "Kamieniolom";
  66.     Quarry.buildCost = 200;
  67.     Quarry.maintainCost = 100;
  68.     Quarry.resourcesUsed = 10;
  69.     Quarry.resourcesProduced = 20;
  70.     Resource Gold;
  71.     Gold.resourceAmount = 300;
  72.     Resource Stone;
  73.     Stone.resourceAmount = 0;  
  74.     Building Kupa;
  75.     cout << "Nazwa: " << Quarry.buildingName
  76.         << "\nKoszt budowy: " << Quarry.buildCost
  77.          << "\nKoszt utrzymania: " << Quarry.maintainCost
  78.         << "\nUzyte zasoby: "<< Quarry.resourcesUsed
  79.         << "\nProdukowane zasoby: " << Quarry.resourcesProduced << "\n"
  80.         << endl;
  81.     cout << "Nazwa: " << Kupa.buildingName
  82.         << "\nKoszt budowy: " << Kupa.buildCost
  83.         << "\nKoszt utrzymania: " << Kupa.maintainCost
  84.         << "\nUzyte zasoby: " << Kupa.resourcesUsed
  85.         << "\nProdukowane zasoby: " << Kupa.resourcesProduced << "\n"
  86.         << "\nIlosc zlota:" <<Gold.resourceAmount << "\nIlosc kamienia: "<< Stone.resourceAmount<< "\n"
  87.         << endl;
  88.     cout << "Czy chcesz kupic kamieniolom za 200 golda? [T/N]" << endl;
  89.     char wybor;
  90.     cin >> wybor;
  91.     switch(wybor)
  92.     {
  93.     case 'T': cout << "Kupiono " << Quarry.buildingName << " za " << Quarry.buildCost << " golda " << endl; break;
  94.     case 'N': cout << "Nie to nie :)" << endl; break;
  95.     default: cout << "Cos sie zepsulo, sprobuj jeszcze raz"; break;
  96.     }
  97.     _getch();
  98.     return 0;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment