Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication2.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <cstdlib>
- #include <cstdio>
- #include <iostream>
- #include <list>
- using namespace std;
- class pelzacz
- {
- public:
- void przedstawienie();
- void ruch();
- void jedzenie();
- void smierc();
- void stworz(int x, int y, int wag);
- private:
- int waga;
- int X;
- int Y;
- };
- class pelzaczofag
- {
- public:
- void przedstawienie();
- void ruch();
- void jedzenie();
- private:
- int iq;
- int X;
- int Y;
- };
- class teleportator
- {
- public:
- void przedstawienie();
- void teleportacja();
- private:
- int X;
- int Y;
- };
- void stworz_plansze(int, int, int, char **);
- void wyswietl_plansze(char **);
- int m, n, k = 6; // k -wymiar pola planszy
- int main(int argc, const char* argv[])
- {
- cout << "Podaj m (szerokosc planszy):" << endl;
- cin >> m;
- cin.ignore();
- cout << "Podaj n (dlugosc planszy):" << endl;
- cin >> n;
- cin.ignore();
- list <pelzacz> pelzacze;
- list <pelzaczofag> pelzaczofagi;
- for (int i = 1; i < 4; i++)
- {
- pelzacz potwor;
- potwor.stworz(1, 2, 3);
- pelzacze.push_back(potwor);
- }
- pelzacze.front().przedstawienie();
- //for (std::list<pelzacz>::iterator it = pelzacze.begin(); it != pelzacze.end(); it++)
- //{
- //pelzacz potwor = *it;
- //potwor.przedstawienie();
- //}
- // utworzenie tablicy dynamicznej na plansze
- char ** plansza = new char *[n*k + 1];
- for (int i = 0; i < n*k + 1; i++)
- plansza[i] = new char[m*k + 1];
- stworz_plansze(m, n, k, plansza);
- wyswietl_plansze(plansza);
- // zwalnianie pamieci
- for (int i = 0; i<n*k + 1; i++)
- delete[] plansza[i];
- delete[] plansza;
- getchar();
- return 0;
- }
- void stworz_plansze(int m, int n, int k, char ** plansza)
- {
- for (int i = 0; i < n*k + 1; i = i++)
- {
- for (int j = 0; j < m*k + 1; j = j++)
- {
- plansza[i][j] = ' ';
- }
- }
- for (int i = 0; i < n*k + 1; i++)
- {
- for (int j = 0; j < m*k + 1; j = j + k)
- {
- plansza[i][j] = 'I';
- }
- }
- for (int i = 0; i < n*k + 1; i = i + k)
- {
- for (int j = 0; j < m*k + 1; j++)
- {
- plansza[i][j] = '-';
- }
- }
- }
- void wyswietl_plansze(char ** plansza)
- {
- for (int i = 0; i < n*k + 1; i = i++)
- {
- for (int j = 0; j < m*k + 1; j++)
- {
- cout << plansza[i][j];
- }
- cout << endl;
- }
- }
- void pelzacz::stworz(int x, int y, int wag)
- {
- x = X;
- y = Y;
- wag = waga;
- }
- void pelzacz::przedstawienie()
- {
- cout << X << Y << waga << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement