Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
SpaceAdventureRPG/InitialisePlanets.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (25 sloc)
959 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "InitialisePlanets.h" | |
#include "database_manager.cpp" | |
// this was moved from header file | |
static int toInt(string* s) { | |
return atoi((s->c_str())); // converts strings to integers | |
} | |
InitialisePlanets::InitialisePlanets() { | |
// constructor for initialising planets | |
this->planetsPool = {}; | |
// implementing initialiseplanets class | |
this->initialisePlanet(); | |
} | |
void InitialisePlanets::initialisePlanet() { | |
for (int i = 1; i < DatabaseManager::countRows("Planet")+1; i++) { | |
vector<string> data = DatabaseManager::getNthRowFromPlanet(i); | |
Planet planet(toInt(&data[0])); | |
planet.setPlanetName(data[1]); | |
planet.setPlanetRadiation(data[2]); | |
planet.setPlanetOxygen(data[3]); | |
planet.setPlanetTemperature(data[4]); | |
planet.setPlanetWeatherChance(data[5]); | |
planet.setPlanetWeatherType(data[6]); | |
this->planetsPool.push_back(planet); | |
} | |
} |