by noobgrammer on Fri Oct 23, 2009 9:38 pm
here lets get you on the right rails
wizard.h
- Code: Select all
#ifndef WIZARD_H
#define WIZARD_H
#include <iostream>
#include <windows.h>
class wizard
{
public:
//costructors\deconstructors
wizard(int , int , int , bool , bool , bool , bool);
~wizard(){}
//health
int gethealth(){return health;}
void sethealth(int heal){ health = heal;}//this isn't adding to health just reassigning it
int increase_health(){return ++health ;}
int reduce_health(){return --health;}
//strength
int get_strength(){return strength;}
void set_strength(int power){strength = power;}//this isn't adding to strength just reassigning it
int increase_strength(){return ++strength;}
int reduce_strength(){return --strength;}
//currency
int get_gold_coins(){return gold_coins;}
void set_gold_coins(int amount){gold_coins = amount;}
int increase_gold_coins(){return ++gold_coins;}
int reduce_gold_coins(){return --gold_coins;}
//stealth weapon
bool init_stealth_mode(){return stealth_mode = true;}
bool check_stealth_mode(){return stealth_mode;}
bool set_stealth_mode(){return stealth_mode = false;}
//attacking
void attack(){std::cout <<"you are attacking...\n";}
void being_attacked(){std::cout << "you are being attacked....\n";}
// doors
bool check_door(){return door;}
void open_door(){door = true ;}
void close_door(){door = false;}
// keys
bool check_key(){return masterkey;}
void use_key(){masterkey = true ;}
void put_away_key(){masterkey = false;}
//transport
void ride_ninja_bike()
{std::cout <<"\nriding....\n";
Sleep(5000);
std::cout << "you have arrived\n";}
//fly
//variables
private:
int health;
int strength;
int gold_coins;
bool stealth_mode;
bool door;
bool masterkey;
bool ninja_bike;
};
#endif
wizard.cpp
- Code: Select all
#include "wizard.h"
wizard::wizard(int _health, int _strength, int _gold_coins, bool _stealth_mode, bool _door, bool _masterkey, bool _ninja_bike) :
health(_health),
strength(_strength),
gold_coins(_gold_coins),
stealth_mode(_stealth_mode), //put timer with this(reminder)
door(_door),
masterkey(_masterkey),
ninja_bike(_ninja_bike)
{}
main.cpp
- Code: Select all
#include "wizard.h"
int main()
{
wizard darth_vader(1,2,3,true,false,true,false); // i aint started on the main bit yet cos
wizard merlin(1,2,3,true,false,true,false); // i wanna get all my varibles
merlin.sethealth(9); // and functions sorted
merlin.set_strength(9);
merlin.set_gold_coins(9);
darth_vader.sethealth(3);
darth_vader.set_strength(3);
darth_vader.set_gold_coins(9);
std::cout <<darth_vader.gethealth()<< "\n";
darth_vader.ride_ninja_bike();
system("pause");
return 0;
}
I'm a little tired so I will be brief I've already told you how to do it right and did it so you will have a example to look at
I see a couple problems I believe I will show one you will have to hunt the others down
- Code: Select all
void sethealth(int heal){ health = heal;}//this isn't adding to health just reassigning it
I'm tired so I don't know if there are more mistakes but there is a start on the right path
I need a compiler with a can of RAID built into it
I added a msn messenger just for programming feel free to email or add yourself to it