Coder's Guild Mailing List

Re: fighting styles question

Posted by Frank Hale on 2001-01-18

> im not sure what all those ||'s were.

They mean "OR"

>i guess i havent been coding long
> enough, heh (im just on my second college C++ course, anyway).  but, i was
> reading your post and remembered enum.  our teacher never said much about
> enum, but i thot it was a really handy tool.
>
> for instance:
>
> enum FIGHTING_STYLE = { GungFu, Karate, Capouera, Boxing };
>
> enum basically assigns each entry an index number (kind of like #define.
> not sure, tho.  i havent used define much, either).  in the above example
> any time you referred to "GungFu", a 0 would be returned in its place.
and
> a 1 for "Karate", 2 for "Capouera", and 3 for "Boxing".
>
> set_fighting_style(player1, Capouera);
>
> but my whole thing is id rather find simpler ways than classes.  but thats
> prolly just me.  and if theres more info that needs to be side by side
with
> the style, a class might work too.
>

Personally I would make an abstract base class called FightingStyle then I'd
derive all my fighting styles from it. I wouldn't use enum to do it. I'd
declare the generic behaviour of the fighting styles as maybe pure virtual
functions and then define them in the derived fighting style classes. I'd
make it as OO as possible just for the hell of it. C++ is good for that.
Design a class hierarchy then implement it. If you have a good class design
coding and maintaining become alot easier.