In Class Work

Design

ChallengeT:
    Methods

        SetName(string)
        SetDescription(string)
        SetValue(string) 
        Get* : return the value associated with a data member
        DoChallenge(player)
    Data:
        string Name
        string Description
//        int level
//        int cash
//        int damage
//        int xp
//        AttributeT attribute;

ReadFile

    open the file.
    ReadPlayer(file, player);
    read number of encounters
    for(i=0; i < number of encounters; i++) {
        Read Encounter
    }

////
void  ReadEncounter
    Read NPC
    Read Challenge


////
ChallengeT ReadChallenge(ifstream & inFile) {
     string name, description, stats;
     ChallengeT rv;

     inFile >> name;
     inFile >> description;
     inFile >> stats;

     rv.SetName(name);
     rv.SetDescription(description)
     rv.SetValue(stats);

     return rv;
}

ChallengeT.h

#ifndef CHALLENGET
#define CHALLENGET

#include <string>
#include "PlayerT.h"
#include "AttributeT.h"

class ChallengeT {
   public:
      ChallengeT(void);
      void SetName( std::string n);
      void SetDescription( std::string des);
      void SetValues(std::string v);

      void DoChallenge(PlayerT & player);

      void Level(int l);
      int Level(void) const;


   private:
      std::string name;
      std::string description;
      AttributeT attribute;
      ...
      int cash = 0;
};

void PrintChallenge(const ChallengeT  & challenge);

#endif 

ChallengeT.cpp

#include <iostream>
#include "ChallengeT.h"

using namespace std;

ChallengeT::ChallengeT() {
     cash = 0;
     level = 0;
     damage = 0;
     ...
}


void ChallengeT::SetName(string n) {
    name = n;
}

void ChallengeT::Level(int l){
     level = l;
}

int ChallengeT::Level(void) const{
     return level;
}

Battle


// probably needs modified.
void DoBattle(PlayerT & p1,  PlayerT & p2) {
     while (p1.HP() > 0 and p2.HP() > 0)  {
         p1.Attack(p2);
         p2.Attack(p1);

     }
}

Makefile Stuff

main: ChallengeT.o

ChallengeT.o: ChallengeT.h