Buenas!!Soy nuevo en la pagina y estoy intentando encontrar algo de ayuda ya que no se que hacer mas con este maldito codigo.
Estoy haciendo un pequeño juego pero tengo el problema de que ve que esta el codigo perfecto pero cuando lo ejecuto no hace nada.
El juego es un trabajo de la uni y el tema trata de atributos, metodos, herencia y poliformismo. Creo que la parte de la constructora esta perfecto pero despues es como si no hiciese nada de caso de ella. Os pongo el codigo a ver que os parece..
Este es el Studentcraft.cpp
#include "StudentCraft.h"
#include <string>
using namespace std;
StudentCraft::StudentCraft(string username,string name,string surname,string birthdate){}
string StudentCraft::getName(){return name;}
string StudentCraft::getSurname(){ return surname;}
string StudentCraft::getUsername(){ return username;}
string StudentCraft::getBirthdate(){return birthdate;}
int StudentCraft::getClassRoom(){return classroom=0;}
int StudentCraft::getEnergy(){return energy = MAX_ENERGY;}
int StudentCraft::getKnowledge(){return knowledge=0;}
void StudentCraft::assignClassroom(int idClassroom){
classroom= idClassroom;
knowledge= INITIAL_KNOWLEDGE;
}
void StudentCraft::studyModule(){
knowledge=knowledge + (INCREASE_KNOWLEDGE_MO);
energy= energy - (DECREASE_ENERGY_MO);
}
void StudentCraft::realizeAC(){
knowledge=knowledge + (INCREASE_KNOWLEDGE_AC);
energy= energy -(DECREASE_ENERGY_AC);
}
void StudentCraft::increaseEnergy(){
energy=MAX_ENERGY;
}
StudentCraft::~StudentCraft() {}
int StudentCraft::MAX_ENERGY = 1000;
int StudentCraft::OVERLOAD_INITIAL_ENERGY = 100;
int StudentCraft::INITIAL_KNOWLEDGE = 50;
int StudentCraft::INCREASE_KNOWLEDGE_AC = 70;
int StudentCraft::DECREASE_ENERGY_AC = 100;
int StudentCraft::INCREASE_KNOWLEDGE_MO = 50;
int StudentCraft::DECREASE_ENERGY_MO = 70;
Este es el StudentCraft.h
#ifndef STUDENTCRAFT_H_
#define STUDENTCRAFT_H_
#include <string>
using namespace std;
class StudentCraft
{
private:
/** Identifies the user on World of UocCraft (WoU) */
string username;
/** Real player's name */
string name;
/** player's surname */
string surname;
/** player's birthdate. Must follow YYYYMMDD format */
string birthdate;
/** actual energy level of the player */
int energy;
/** actual knowledge level of the player */
int knowledge;
/** classroom code of the player-student */
int classroom;
static int MAX_ENERGY;
static int OVERLOAD_INITIAL_ENERGY ;
static int INITIAL_KNOWLEDGE;
static int INCREASE_KNOWLEDGE_AC;
static int DECREASE_ENERGY_AC;
static int INCREASE_KNOWLEDGE_MO;
static int DECREASE_ENERGY_MO;
public:
/** Constructor method.
* Creates a new instance of StudentCraft
* @param username of the player
* @param name of the player
* @param surname of the player
* @param birthdate of the player
*/
StudentCraft(string username, string name, string surname, string birthdate);
/**getter of classroom*/
int getClassRoom();
/**getter of getEnergy*/
int getEnergy();
/**getter of Knowledge*/
int getKnowledge();
/**getter of name*/
string getName();
/**getter of surname*/
string getSurname();
/**getter of username*/
string getUsername();
string getBirthdate();
/** assigns a new classrom to the student
* @param idClassroom the classroom code
*/
void assignClassroom (int idClassroom);
/**Increments the knowledge of the player in INCREASE_KNOWLEDGE_MO and decreases his energy DECREASE_ENERGY_MO
*/
void studyModule();
/**Increments the knowledge of the player in INCREASE_KNOWLEDGE_AC and decreases his energy DECREASE_ENERGY_AC
*/
void realizeAC();
/**Increments the energy of the player to the maximum
*/
void increaseEnergy();
virtual ~StudentCraft();
};
#endif /*STUDENTCRAFT_H_*/
Y este es UOCCraft.cpp que es el que me esta dando problemas, es la parte que se encarga de ejecutar todo el programa.
#include <iostream>
#include "StudentCraft.h"
using namespace std;
/**
* AirUOC class demo program
*/
int main(int argc, char *argv[]) {
StudentCraft *player1 = new StudentCraft("user1","Sandra","Varillas","19920223");
StudentCraft *player2 = new StudentCraft("user2","Federico","Taulet","197010,15");
StudentCraft *player3 = new StudentCraft("user3","Feliciano","Vargas","19800709");
// Display what we've got->
cout << "Player " << player1->getUsername() << ": name -> " << player1->getName() << " | surname -> " << player1->getSurname() << " | energy -> " << player1->getEnergy() << " | knowledge -> " << player1->getKnowledge() << " | classroom -> " << player1->getClassRoom() << endl;
cout << "Player " << player2->getUsername() << ": name -> " << player2->getName() << " | surname -> " << player2->getSurname() << " | energy -> " << player2->getEnergy() << " | knowledge -> " << player2->getKnowledge() << " | classroom -> " << player1->getClassRoom() << endl;
cout << "Player " << player3->getUsername() << ": name -> " << player3->getName() << " | surname -> " << player3->getSurname() << " | energy -> " << player3->getEnergy() << " | knowledge -> " << player3->getKnowledge() << " | classroom -> " << player1->getClassRoom() << endl;
player1->assignClassroom(327);
player2->assignClassroom(327);
player3->assignClassroom(327);
player1->studyModule();
player1->studyModule();
player1->studyModule();
player1->realizeAC();
player1->realizeAC();
player1->increaseEnergy();
player2->realizeAC();
player2->realizeAC();
player2->realizeAC();
player3->increaseEnergy();
player3->increaseEnergy();
player3->studyModule();
player3->studyModule();
player3->studyModule();
// Display what we've got->
cout << "Player " << player1->getUsername() << ": name -> " << player1->getName() << " | surname -> " << player1->getSurname() << " | energy -> " << player1->getEnergy() << " | knowledge -> " << player1->getKnowledge() << " | classroom -> " << player1->getClassRoom() << endl;
cout << "Player " << player2->getUsername() << ": name -> " << player2->getName() << " | surname -> " << player2->getSurname() << " | energy -> " << player2->getEnergy() << " | knowledge -> " << player2->getKnowledge() << " | classroom -> " << player1->getClassRoom() << endl;
cout << "Player " << player3->getUsername() << ": name -> " << player3->getName() << " | surname -> " << player3->getSurname() << " | energy -> " << player3->getEnergy() << " | knowledge -> " << player3->getKnowledge() << " | classroom -> " << player1->getClassRoom() << endl;
}
Bueno...a ver que os parece, y a ver que podeis decir...muchas gracias de antemano.