Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. // ConsoleApplication2.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <cstdlib>
  6. #include <cstdio>
  7. #include <iostream>
  8. #include <list>
  9.  
  10. using namespace std;
  11.  
  12.  
  13.  
  14.  
  15. class pelzacz
  16. {
  17. public:
  18. void przedstawienie();
  19. void ruch();
  20. void jedzenie();
  21. void smierc();
  22. void stworz(int x, int y, int wag);
  23. private:
  24. int waga;
  25. int X;
  26. int Y;
  27. };
  28.  
  29. class pelzaczofag
  30. {
  31. public:
  32. void przedstawienie();
  33. void ruch();
  34. void jedzenie();
  35. private:
  36. int iq;
  37. int X;
  38. int Y;
  39. };
  40.  
  41. class teleportator
  42. {
  43. public:
  44. void przedstawienie();
  45. void teleportacja();
  46. private:
  47. int X;
  48. int Y;
  49. };
  50.  
  51. void stworz_plansze(int, int, int, char **);
  52. void wyswietl_plansze(char **);
  53.  
  54. int m, n, k = 6; // k -wymiar pola planszy
  55.  
  56.  
  57. int main(int argc, const char* argv[])
  58. {
  59.  
  60.  
  61. cout << "Podaj m (szerokosc planszy):" << endl;
  62. cin >> m;
  63. cin.ignore();
  64. cout << "Podaj n (dlugosc planszy):" << endl;
  65. cin >> n;
  66. cin.ignore();
  67.  
  68. list <pelzacz> pelzacze;
  69. list <pelzaczofag> pelzaczofagi;
  70.  
  71. for (int i = 1; i < 4; i++)
  72. {
  73. pelzacz potwor;
  74. potwor.stworz(1, 2, 3);
  75. pelzacze.push_back(potwor);
  76. }
  77.  
  78. pelzacze.front().przedstawienie();
  79.  
  80.  
  81. //for (std::list<pelzacz>::iterator it = pelzacze.begin(); it != pelzacze.end(); it++)
  82. //{
  83. //pelzacz potwor = *it;
  84. //potwor.przedstawienie();
  85. //}
  86.  
  87. // utworzenie tablicy dynamicznej na plansze
  88. char ** plansza = new char *[n*k + 1];
  89. for (int i = 0; i < n*k + 1; i++)
  90. plansza[i] = new char[m*k + 1];
  91.  
  92. stworz_plansze(m, n, k, plansza);
  93. wyswietl_plansze(plansza);
  94.  
  95. // zwalnianie pamieci
  96. for (int i = 0; i<n*k + 1; i++)
  97. delete[] plansza[i];
  98.  
  99. delete[] plansza;
  100.  
  101. getchar();
  102.  
  103. return 0;
  104. }
  105.  
  106.  
  107. void stworz_plansze(int m, int n, int k, char ** plansza)
  108. {
  109.  
  110. for (int i = 0; i < n*k + 1; i = i++)
  111. {
  112.  
  113. for (int j = 0; j < m*k + 1; j = j++)
  114. {
  115. plansza[i][j] = ' ';
  116. }
  117.  
  118. }
  119.  
  120.  
  121.  
  122. for (int i = 0; i < n*k + 1; i++)
  123. {
  124. for (int j = 0; j < m*k + 1; j = j + k)
  125. {
  126. plansza[i][j] = 'I';
  127. }
  128. }
  129.  
  130. for (int i = 0; i < n*k + 1; i = i + k)
  131. {
  132. for (int j = 0; j < m*k + 1; j++)
  133. {
  134. plansza[i][j] = '-';
  135. }
  136. }
  137. }
  138.  
  139. void wyswietl_plansze(char ** plansza)
  140. {
  141. for (int i = 0; i < n*k + 1; i = i++)
  142. {
  143. for (int j = 0; j < m*k + 1; j++)
  144. {
  145. cout << plansza[i][j];
  146. }
  147. cout << endl;
  148.  
  149. }
  150. }
  151.  
  152. void pelzacz::stworz(int x, int y, int wag)
  153. {
  154. x = X;
  155. y = Y;
  156. wag = waga;
  157. }
  158.  
  159. void pelzacz::przedstawienie()
  160. {
  161. cout << X << Y << waga << endl;
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement