Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <ctime>
- #include <string>
- using namespace std;
- struct ArmyTemplate {
- int health;
- int damage;
- int defence;
- char name;
- char type;
- char ammo_type;
- };
- class Army {
- private:
- int current_index = 0;
- public:
- ArmyTemplate *armyTemplate;
- int ArmySize;
- Army(int size){
- armyTemplate = new ArmyTemplate[size];
- ArmySize = size;
- }
- void addUnit(int unit_health, int unit_damage, int unit_defence, char unit_name, char unit_type, char unit_ammo_type) {
- armyTemplate[current_index].health = unit_health;
- armyTemplate[current_index].damage = unit_damage;
- armyTemplate[current_index].defence = unit_defence;
- armyTemplate[current_index].name = unit_name;
- armyTemplate[current_index].type = unit_type;
- armyTemplate[current_index].ammo_type = unit_ammo_type;
- current_index++;
- }
- void get()
- {
- for (int i = 0; i < current_index; i++) {
- cout << "Здоровье - " << armyTemplate[i].health << endl;
- cout << "Урон - " << armyTemplate[i].damage << endl;
- cout << "Защита - " << armyTemplate[i].defence << endl;
- cout << "Имя - " << armyTemplate[i].name << endl;
- cout << "Тип - " << armyTemplate[i].type << endl;
- cout << "Тип боеприпасов - " << armyTemplate[i].ammo_type << endl << endl;
- }
- }
- };
- class Soldier {
- public:
- int health = 0;
- int damage = 0;
- int defence = 0;
- string type = "human";
- string name = "";
- Soldier(int new_health, int new_damage, int new_defence, string new_name)
- {
- health = new_health;
- damage = new_damage;
- defence = new_defence;
- name = new_name;
- }
- void Print() {
- cout << "health" << health << "damage" << damage << endl;
- }
- };
- class Mechanism {
- public:
- int health = 0;
- int damage = 0;
- int defence = 0;
- string type = "mechanism";
- string name = "";
- string ammo_type = "";
- Mechanism(int new_health, int new_damage, int new_defence, string new_name, string new_ammo_type)
- {
- health = new_health;
- damage = new_damage;
- defence = new_defence;
- name = new_name;
- ammo_type = new_ammo_type;
- }
- void Print() {
- cout << "health" << health << "damage" << damage << endl;
- }
- };
- int main()
- {
- int armySize;
- // Soldier test_unit(100, 200, 50, "Маг");
- // Mechanism test_mech(100, 200, 50, "Пушка", "Ядро");
- cout << "Введите размер армии..." << endl;
- cin >> armySize;
- Army army(armySize);
- // army.addUnit(test_unit.health, test_unit.damage, test_unit.defence, test_unit.name, test_unit.type, "none");
- //army.addUnit(test_mech.health, test_mech.damage, test_mech.defence, test_mech.name, test_mech.type, test_mech.ammo_type);
- string names = { "Маг", "Тигр" };
- string types = { "human", "animal" };
- string ammo_types = { "magic_stick", "nails"};
- int health = 0;
- int damage = 0;
- int defence = 0;
- int random_index = 0;
- for (int i = 0; i < armySize; i++)
- {
- srand(time(NULL));
- health = 30 + rand() % 80;
- damage = 10 + rand() % 50;
- defence = 5 + rand() % 15;
- random_index = rand() % 1;
- cout << random_index << endl;
- cout << health << endl;
- cout << damage << endl;
- cout << defence << endl;
- break;
- //army.addUnit(health, damage, defence, names[random_index], types[random_index], ammo_types[random_index]);
- }
- //army.get();
- system("pause");
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement