#include
#include
#include
#include
#include
#include
using namespace std;
// Enum for the types of rooms in the dungeon
enum class RoomType { Empty, Monster, Treasure };
class Room {
public:
RoomType type;
vector connectedRooms;
// Constructor to initialize a Room with a given type
Room(RoomType t) : type(t) {}
// Connects this room to another room
void connectTo(Room* other) {
connectedRooms.push_back(other);
other->connectedRooms.push_back(this);
}
};
class EmptyRoom : public Room {
public:
// Constructor for an EmptyRoom, setting its type to Empty
EmptyRoom() : Room(RoomType::Empty) {}
};
class MonsterRoom : public Room {
public:
int monsterHealth = 10;
int monsterAttack = 2;
// Constructor for a MonsterRoom, setting its type to Monster
MonsterRoom() : Room(RoomType::Monster) {}
};
class TreasureRoom : public Room {
public:
// Constructor for a TreasureRoom, setting its type to Treasure
TreasureRoom() : Room(RoomType::Treasure) {}
};
class Dungeon {
public:
vector rooms;
// Constructor to create a Dungeon with a set of rooms
Dungeon() {
// Initializing dungeon with a mix of room types
for (int i = 0; i < 5; i++) {
rooms.push_back(make_unique());
rooms.push_back(make_unique());
rooms.push_back(make_unique());
rooms.push_back(make_unique());
rooms.push_back(make_unique());
rooms.push_back(make_unique());
}
rooms.push_back(make_unique());
// Connecting each room to the next
for (size_t i = 0; i < rooms.size() - 1; ++i) {
rooms[i]->connectTo(rooms[i + 1].get());
}
}
};
class Monk {
public:
string name;
string description;
int healthPoints = 15;
int attackPoints = 3;
Room* currentRoom;
// Constructor for a Monk, initializing name, description, and starting room
Monk(const string& n, const string& d) : name(n), description(d), currentRoom(nullptr) {}
// Moves the Monk to a specified room
void moveToRoom(Room* room) {
currentRoom = room;
string roomType = (currentRoom->type == RoomType::Empty) ? "an Empty" :
(currentRoom->type == RoomType::Monster) ? "a Monster" : "the Treasure";
cout connectedRooms.empty()) {
player.moveToRoom(player.currentRoom->connectedRooms[0]);
}
else {
cout
Источник: [url]https://stackoverflow.com/questions/78132683/i-had-all-of-my-classes-in-a-single-cpp-file-now-i-have-seperated-them-into-mul[/url]
[code]#include #include #include #include #include #include using namespace std;
// Enum for the types of rooms in the dungeon enum class RoomType { Empty, Monster, Treasure };
class Room { public: RoomType type; vector connectedRooms;
// Constructor to initialize a Room with a given type Room(RoomType t) : type(t) {}
// Connects this room to another room void connectTo(Room* other) { connectedRooms.push_back(other); other->connectedRooms.push_back(this); } };
class EmptyRoom : public Room { public: // Constructor for an EmptyRoom, setting its type to Empty EmptyRoom() : Room(RoomType::Empty) {}
};
class MonsterRoom : public Room { public: int monsterHealth = 10; int monsterAttack = 2;
// Constructor for a MonsterRoom, setting its type to Monster MonsterRoom() : Room(RoomType::Monster) {} };
class TreasureRoom : public Room { public: // Constructor for a TreasureRoom, setting its type to Treasure TreasureRoom() : Room(RoomType::Treasure) {} };
class Dungeon { public: vector rooms;
// Constructor to create a Dungeon with a set of rooms Dungeon() { // Initializing dungeon with a mix of room types for (int i = 0; i < 5; i++) { rooms.push_back(make_unique()); rooms.push_back(make_unique()); rooms.push_back(make_unique()); rooms.push_back(make_unique()); rooms.push_back(make_unique()); rooms.push_back(make_unique()); } rooms.push_back(make_unique());
// Connecting each room to the next for (size_t i = 0; i < rooms.size() - 1; ++i) { rooms[i]->connectTo(rooms[i + 1].get()); } } };
class Monk { public: string name; string description; int healthPoints = 15; int attackPoints = 3; Room* currentRoom;
// Constructor for a Monk, initializing name, description, and starting room Monk(const string& n, const string& d) : name(n), description(d), currentRoom(nullptr) {}
// Moves the Monk to a specified room void moveToRoom(Room* room) { currentRoom = room; string roomType = (currentRoom->type == RoomType::Empty) ? "an Empty" : (currentRoom->type == RoomType::Monster) ? "a Monster" : "the Treasure"; cout connectedRooms.empty()) { player.moveToRoom(player.currentRoom->connectedRooms[0]); } else { cout
У меня есть данные, указанные ниже. При этом я хочу, чтобы значения столбца A были разделены на разные столбцы и имели значения соответствующих значений столбца2, и мне нужно, чтобы столбец3 содержал соответствующее значение группы. Обратите...
*Обновление: после запуска ProGuard для уменьшения моих ресурсов кажется, что ProGuard может удалять важный код:
Ошибка: не удалось найти метод android() для аргументов в корневом проекте ' Демо-версия карт Google' типа org.gradle.api.Project....
*Обновление: после запуска ProGuard для уменьшения моих ресурсов кажется, что ProGuard может удалять важный код:
Ошибка: не удалось найти метод android() для аргументов в корневом проекте ' Демо-версия карт Google' типа org.gradle.api.Project....
Привет, я новичок в мире C ++, и я пытаюсь написать функции, вызывая эту функцию через HPP и другой CPP в main.cp Я получил много ошибок
, если я переоденулся на char и int это работает
Моя основная цель - понять - использовать файлы HPP и CPP,...