Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ Workshop - Week 5 (Ch. 6 & Ch. 11) - Quizzes and Exercises

Started by JWalsh Jul 13, 2006 at 6:00 PM 12 replies 8.4k views
Original Post
JWalsh
JWalsh

Quizzes and Extra Credit for Week 5.

Post your answers to the Quizzes from Week 5 here rather than in the chapter thread, so as not to spoil things for the others.
Chapter 6 Quiz 1. What was the ‘C’ capability which allowed you to combine related variables? Did this solve the problem of connecting data with behaviors? 2. How do you make a new type in C++? 3. What is a class? 4. What is another name for variables within a class? What is another name for the member functions? 5. What are the requisite parts of a class declaration? Show an example. 6. What are the two things a class declaration tells your compiler? 7. When discussing naming conventions, what’s the most important point to remember? 8. What is an object? 9. How do you declare an object? Show an example. 10. What operator is used to access members and methods of a class for objects created on the stack. 11. What is the difference between public and private members/methods within a class? Which is the default? 12. In general, should methods or members be private? Why? 13. What is the primary way you initialize the member data of a class? 14. How can you identify a constructor for a class? 15. What is a default constructor? How is it called. 16. What does “declaring a method of a class const” mean? What is the syntax for such a declaration? 17. In the context of classes and objects, what is a client? 18. Where do class declarations go? Where do the member function definitions go? 19. When one class has a member variable which is an object of a different class they are said to form a ___ relationship? 20. What is the only difference between C++ classes and C++ structs? Chapter 11 Quiz 1. What’s the purpose of a model? 2. What is the basic philosophy of iterative design/development? 3. What’s the difference between waterfall vs. iterative development? 4. What are the 6 steps listed in your book for iterative development. 5. What happens if you lose sight of the vision of your product? 6. What is a use case? 7. What is a domain expert? 8. What is an actor? 9. What are the 6 questions you should ask yourself about the actors when determining use cases, according to your book? 10. What is a domain model? 11. What is a scenario? 12. What are the 9 items, according to your book, should you include when documenting a scenario? 13. What is systems analysis? 14. What is the simplistic technique, according to your book, for determining the classes in your project? 15. What are the three areas of concern for the Static Model of your classes? 16. What is the most important principle when deciding the responsibilities of a class? 17. What are the two types of diagrams shown in the book for determining how classes interact? Exercise 1 – The random character generator In the game “Dungeons & Dragons” by WoTC, each player controls a character. The character has a number of attributes, specifically, they have Strength, Dexterity, Stamina, Intellect, Wisdom, and Charisma – each which can have a score in the range of 1 to 20. These “ability” scores are used to determine the success and/or failure of skills used, as well as how your character performs in combat. We’ll explore more of that later. For this week, I want you to write a program which contains a “Character” class. The character should have attributes representing the 6 ability scores, with accesses for each score. As well, the class should contain two constructors, 1 which takes as input 6 ability scores, and the second which is the default. The default constructor should randomly assign each ability score a value in the range of 1 to 20. To make it easier, I’ve posted the code below to help generate random numbers. Your main function should create two “characters”….one by using the default constructor, and one by passing in values between 1-20…might want to check in your constructor to make sure the input is valid (1-20). After both characters are created, use your accessors to print the attributes of each character to the screen with appropriate labels.

// Required headers
#include <stdlib.h>
#include <time.h>

// Call this ONCE, in your main function to seed the random number generator
srand( (unsigned)time( NULL ) );

// Call this in your default constructor in order to generate a random number from 1 to 20.
int randomNum = ( rand() % 20 ) + 1;
[Edited by - jwalsh on July 13, 2006 9:01:14 PM]
RinusMaximus
RinusMaximus
Thats a cool exercise Jeromy! It would be fun if we can build on top of this exercise in the next weeks, adding stuff as we learn new things.
Palejo
Palejo
I really did enjoy working on this week's project. I would love any feedback anyone might have regarding sloppiness on my part or any other comments in general:) Thank you again!


Chapter 6 Quiz

1. What was the ‘C’ capability which allowed you to combine related variables? Did this solve the problem of connecting data

with behaviors?
The C capability was called structures and no it did not.

2. How do you make a new type in C++?
You declare a class.

3. What is a class?
A composition of of related variables and functions.

4. What is another name for variables within a class? What is another name for the member functions?
Variables within a class are called members variables or data members. Functions within a class are called member functions

or methods.

5. What are the requisite parts of a class declaration? Show an example.
class Cat
{
int itsAge;
void meow();
};

The word 'class', the class name and brackets (with an ending semi-colon) are all required parts of the class declaration.

6. What are the two things a class declaration tells your compiler?
It tells the compiler what the class exactly is, and how much memory it needs to allocate for each object it creates of that

class.

7. When discussing naming conventions, what’s the most important point to remember?
Choose a naming convention and be consistent with it.

8. What is an object?
AN individual instance of a class.

9. How do you declare an object? Show an example.
Cat cupcake;
The above statement creates a cat object called cupcake.

10. What operator is used to access members and methods of a class for objects created on the stack.
The dot (.) operator.

11. What is the difference between public and private members/methods within a class? Which is the default?
Private members can only be accessed when processing is inside the actual object. Public members can be accessed from

anywhere in your program. Class members are private by default.

12. In general, should methods or members be private? Why?
Yes, because if anything has the ability to access your members or methods, it makes your program much more difficult to

debug. It also allows you to distinguis between how your data is stored and how it is used.

13. What is the primary way you initialize the member data of a class?
With a constructor.

14. How can you identify a constructor for a class?
By defining a member function of the same name of the class, IE
Cat::Cat (int itsAge)
{
itsAge=initialage;
}


15. What is a default constructor? How is it called.
If you don't specify your own constructor, the default constructor is automatically called. The default constructor has no

actual code in it, it simply initializes your object.

16. What does “declaring a method of a class const” mean? What is the syntax for such a declaration?
This means that the method being declared const will not manipulate member variables at all. An example would be:
void someFunction () const;

17. In the context of classes and objects, what is a client?
Anyone or anything that actually interfaces with those objects.

18. Where do class declarations go? Where do the member function definitions go?
Class declarations should go into .hpp files and be included into your program using #include. Member function

definitions. Member function definitions can go into any .cpp file that is also included in your program.

19. When one class has a member variable which is an object of a different class they are said to form a ___ relationship?
a has-a relationship.

20. What is the only difference between C++ classes and C++ structs?
Members in classes are private by default. In structs, they are public by default.



Chapter 11 Quiz

1. What’s the purpose of a model?
To create a meaningful abstraction of the real world.

2. What is the basic philosophy of iterative design/development?
You begin with an idea you want to build on, and as you investigate it, the idea evolves. You may end up going back to

previous stages of design/development based on what you find in later stages.

3. What’s the difference between waterfall vs. iterative development?
In waterfall development, you are incapable of going 'backward' to previous stages, in iterative development you can.

4. What are the 6 steps listed in your book for iterative development.
Conceptulaization, analysis, design, implementation, testing and rollout.
`
5. What happens if you lose sight of the vision of your product?
Chances are your product is doomed!

6. What is a use case?
A description of how the software will be used.

7. What is a domain expert?
An expert in the area of business in which you are designing the product.

8. What is an actor?
Any person or system that interacts with the product you are developing.

9. What are the 6 questions you should ask yourself about the actors when determining use cases, according to your book?
1. Why is the actor using this system?
2. What outcome does the actor want or expect from each request?
3. What happened to cause the actor to use this system now?
4. What must the actor do to use the system?
5. What information must the actor provide to the system?
6. What information does the actor hope to get from the system?

10. What is a domain model?
A document that captures everything you know about the domain.

11. What is a scenario?
A specific set of circumsances within an individual use case.

12. What are the 9 items, according to your book, should you include when documenting a scenario?
1. Preconditions
2. Triggers
3. What actions the actors take.
4. What results or changes are caused by the system.
5. What feedback the actors receive.
6. Whether repeating activites occur, and what causes them to conclude.
7. A description of the logical flow of the scenario.
8. What causes the scenario to end.
9. Postconditions

13. What is systems analysis?
The process of collecting information from all the other systems you plan on interacting with in your product.

14. What is the simplistic technique, according to your book, for determining the classes in your project?
Pulling out all the nouns in your use case scenarios.

15. What are the three areas of concern for the Static Model of your classes?
Responsibilities, attributes and relationships.

16. What is the most important principle when deciding the responsibilities of a class?
Each class should be responsible for one thing.

17. What are the two types of diagrams shown in the book for determining how classes interact?
Sequence disgrams and collaboration diagrams.


Exercise 1 – The random character generator

In the game “Dungeons & Dragons” by WoTC, each player controls a character. The character has a number of attributes, specifically, they have Strength, Dexterity, Stamina, Intellect, Wisdom, and Charisma – each which can have a score in the range of 1 to 20. These “ability” scores are used to determine the success and/or failure of skills used, as well as how your character performs in combat. We’ll explore more of that later. For this week, I want you to write a program which contains a “Character” class. The character should have attributes representing the 6 ability scores, with accesses for each score. As well, the class should contain two constructors, 1 which takes as input 6 ability scores, and the second which is the default. The default constructor should randomly assign each ability score a value in the range of 1 to 20. To make it easier, I’ve posted the code below to help generate random numbers. Your main function should create two “characters”….one by using the default constructor, and one by passing in values between 1-20…might want to check in your constructor to make sure the input is valid (1-20). After both characters are created, use your accessors to print the attributes of each character to the screen with appropriate labels.



#include <iostream>#include <stdlib.h>#include <time.h>using namespace std;class character //defining the character class{	public: //public accessor and modifier functions		int GetStrength() const;		void SetStrength (int strength);		int GetDexterity() const;		void SetDexterity (int dexterity);		int GetStamina() const;		void SetStamina (int stamina);		int GetIntellect() const;		void SetIntellect (int intellect);		int GetWisdom() const;		void SetWisdom (int wisdom);		int GetCharisma() const;		void SetCharisma (int charisma);		//construction and destructor declarations		character (int strength, int dexterity, int stamina, int intellect, int wisdom, int charisma);		character();		~character();	private: //private data members		int itsStrength;		int itsDexterity;		int itsStamina;		int itsIntellect;		int itsWisdom;		int itsCharisma;};//constructor definitionscharacter::character(int strength, int dexterity, int stamina, int intellect, int wisdom, int charisma){	//check input values to make sure they are valid. If not, we will print an error message.		if ((0 >= strength) || (strength > 20))		cout << "Error! Input value for strength was invalid!" << endl << endl;	if ((0 >= dexterity) || (dexterity > 20))		cout << "Error! Input value for dexterity was invalid!" << endl << endl;	if ((0 >= stamina) || (stamina > 20))		cout << "Error! Input value for stamina was invalid!" << endl << endl;	if ((0 >= intellect) || (intellect > 20))		cout << "Error! Input value for intellect was invalid!" << endl << endl;	if ((0 >= wisdom) || (wisdom > 20))		cout << "Error! Input value for wisdom was invalid!" << endl << endl;	if ((0 >= charisma) || (charisma > 20))		cout << "Error! Input value for charisma was invalid!" << endl << endl;		itsStrength = strength;	itsDexterity = dexterity;	itsStamina = stamina;	itsIntellect = intellect;	itsWisdom = wisdom;	itsCharisma = charisma;}character::character() //default constructor that takes in no values and assigns random values to all six attributes{	int rdmStrength = ( rand() % 20 ) + 1;	int rdmDexterity = ( rand() % 20 ) + 1;	int rdmStamina = ( rand() % 20 ) + 1;	int rdmIntellect = ( rand() % 20 ) + 1;	int rdmWisdom = ( rand() % 20 ) + 1;	int rdmCharisma = ( rand() % 20 ) + 1;	itsStrength = rdmStrength;	itsDexterity = rdmDexterity;	itsStamina = rdmStamina;	itsIntellect = rdmIntellect;	itsWisdom = rdmWisdom;	itsCharisma = rdmCharisma;}character::~character() //destructor, takes no action.{}//The following six member functions are the accessor functions for characterint character::GetStrength() const {	return itsStrength;}int character::GetDexterity() const{	return itsDexterity;}int character::GetStamina() const{	return itsStamina;}int character::GetIntellect() const{	return itsIntellect;}int character::GetWisdom() const{	return itsWisdom;}int character::GetCharisma() const{	return itsCharisma;}//The following six member definitons define the modifier functions for character classesvoid character::SetStrength(int strength){	itsStrength = strength;}void character::SetDexterity(int dexterity){	itsDexterity = dexterity;}void character::SetStamina(int stamina){	itsStamina = stamina;}void character::SetIntellect(int intellect){	itsIntellect = intellect;}void character::SetWisdom(int wisdom){	itsWisdom = wisdom;}void character::SetCharisma(int charisma){	itsCharisma = charisma;}int main(){	srand( (unsigned)time( NULL ) );	int inputStrength, inputDexterity, inputStamina, inputIntellect, inputWisdom, inputCharisma;	cout << "Creating Palejo..." << endl;	character Palejo;	cout << "Palejo has been created with random stats!" << endl;	cout << "You will now enter Reshad's stats. Please enter values between 1 and 20." << endl;	cout << "Enter Reshad's strength:" << endl;	cin >> inputStrength;	cout << "Enter Reshad's dexterity:" << endl;	cin >> inputDexterity;	cout << "Enter Reshad's stamina:" << endl;	cin >> inputStamina;	cout << "Enter Reshad's intellect:" << endl;	cin >> inputIntellect;	cout << "Enter Reshad's wisdom:" << endl;	cin >> inputWisdom;	cout << "Enter Reshad's charisma:" << endl;	cin >> inputCharisma;	cout << "Creating Reshad..." << endl << endl << endl;	character Reshad (inputStrength, inputDexterity, inputStamina, inputIntellect, inputWisdom, inputCharisma);		cout << "Here are Palejo's stats:" << endl;	cout << "strength:" << Palejo.GetStrength() << endl;	cout << "dexterity:" << Palejo.GetDexterity() << endl;	cout << "stamina:" << Palejo.GetStamina() << endl;	cout << "intellect:" << Palejo.GetIntellect() << endl;	cout << "wisdom:" << Palejo.GetWisdom() << endl;	cout << "charisma:" << Palejo.GetCharisma() << endl << endl << endl;	cout << "Here are Reshad's stats:" << endl;	cout << "strength:" << Reshad.GetStrength() << endl;	cout << "dexterity:" << Reshad.GetDexterity() << endl;	cout << "stamina:" << Reshad.GetStamina() << endl;	cout << "intellect:" << Reshad.GetIntellect() << endl;	cout << "wisdom:" << Reshad.GetWisdom() << endl;	cout << "charisma:" << Reshad.GetCharisma() << endl << endl << endl;	return 0;}


[Edited by - Palejo on July 16, 2006 1:50:36 PM]
kuukkeli
kuukkeli
I'll post the answers to Chapter 11 Quiz later (the lack of course book is a small hindrance on those).

Chapter 6 Quiz

1. What was the 'C' capability which allowed you to combine related variables?
Did this solve the problem of connecting data with behaviors?
Struct. No, C structs didn't have class methods.

2. How do you make a new type in C++?
class new_type { <class definition> };


3. What is a class?
A collection of related data and functionality.

4. What is another name for variables within a class? What is another name for
the member functions?
Data members. Methods.

5. What are the requisite parts of a class declaration? Show an example.
Keyword 'class' followed by the class name, and then the list of data
members and methods within a set of curly braces followed by a semicolon.

class Dog    {    unsigned short age;    unsigned short weight;    Bark();    }


6. What are the two things a class declaration tells your compiler?
What class is (its data members and methods), and how much memory is set
aside for each instance of the class.

7. When discussing naming conventions, what's the most important point to
remember?
Consistency within a single project.

8. What is an object?
An instance of a class.

9. How do you declare an object? Show an example.
Just like declaring any of the built-in types - type followed by the
object's name and semicolon.

Dog Blackie;


10. What operator is used to access members and methods of a class for objects
created on the stack.
Dot (.).

11. What is the difference between public and private members/methods within
a class? Which is the default?
Public means that they can be accessed from anywhere, while private allows
access from only within the class itself. Private is the default.

12. In general, should methods or members be private? Why?
Members should be private. It allows better encapsulation.

13. What is the primary way you initialize the member data of a class?
Through constuctor method.

14. How can you identify a constructor for a class?
Like any other method, except its name must be exactly the same as the
name of the class, and it has no return type (not even void).

15. What is a default constructor? How is it called.
Default constructor is an empty method. Class Object;

16. What does 'declaring a method of a class const' mean? What is the syntax
for such a declaration?
const methods can't change any of the data members.

return_value functionName() const;


17. In the context of classes and objects, what is a client?
A part of program that uses the class or object.

18. Where do class declarations go? Where do the member function definitions
go?
Declarations should be in separate header files. Method definitions should
be in the actual .cpp file.

19. When one class has a member variable which is an object of a different
class they are said to form a ___ relationship?
Has-a relationship.

20. What is the only difference between C++ classes and C++ structs?
In structs the data members and methods are public by default, while in
classes they're private.

EXERCISE 1:

character.h
#include <cstdlib>#include <iostream>// A Character class for something-like-D&D.class Character {public:	// Constructors - the default and one that takes all six attributes as 	// parameters.	Character();	Character(unsigned short str, unsigned short dex, unsigned short con,		      unsigned short itg, unsigned short wis, unsigned short cha);		// The "evil" getters and setters.	unsigned short getStrength() const;	void setStrength (unsigned short str);	unsigned short getDexterity() const;	void setDexterity (unsigned short dex);	unsigned short getConstitution() const;	void setConstitution (unsigned short con);	unsigned short getIntelligence() const;	void setIntelligence (unsigned short itg);	unsigned short getWisdom() const;	void setWisdom (unsigned short wis);	unsigned short getCharisma() const;	void setCharisma (unsigned short cha);	// Public printer method (should probably be returning string but we 	// haven't had strings yet).	void printCharacter() const;private:	// Private attribute variables (as in the actual D&D).	unsigned short Strength, Dexterity, Constitution,		           Intelligence, Wisdom, Charisma;		// Private helper method to do the randomizing.	void randomize();};


character.cpp
#include "character.h"Character::Character() {	randomize();}Character::Character(unsigned short str, unsigned short dex, unsigned short con, 					 unsigned short itg, unsigned short wis, unsigned short cha) {	if (str == 0 || str > 20 || dex == 0 || dex > 20 || con == 0 || con > 20 ||		itg == 0 || itg > 20 || wis == 0 || wis > 20 || cha == 0 || cha > 20) 	{		std::cout<<"Illegal attribute value(s)! Random character created!\n";		randomize();	}	else	{		Strength = str;		Dexterity = dex;		Constitution = con;		Intelligence = itg;		Wisdom = wis;		Charisma = cha;	}}unsigned short Character::getStrength() const{	return Strength;}void Character::setStrength(unsigned short str){	if (str >= 1 && str <= 20)		Strength = str;	else		std::cout<<"Illegal value for Stength\n";}unsigned short Character::getDexterity() const{	return Dexterity;}void Character::setDexterity(unsigned short dex){	if (dex >= 1 && dex <= 20)		Dexterity = dex;	else		std::cout<<"Illegal value for Dexterity\n";}unsigned short Character::getConstitution() const{	return Constitution;}void Character::setConstitution(unsigned short con){	if (con >= 1 && con <= 20)		Constitution = con;	else		std::cout<<"Illegal value for Constitution\n";}unsigned short Character::getIntelligence() const{	return Intelligence;}void Character::setIntelligence(unsigned short itg){	if (itg >= 1 && itg <= 20)		Intelligence = itg;	else		std::cout<<"Illegal value for Intelligence\n";}unsigned short Character::getWisdom() const{	return Wisdom;}void Character::setWisdom(unsigned short wis){	if (wis >= 1 && wis <= 20)		Wisdom = wis;	else		std::cout<<"Illegal value for Wisdom\n";}unsigned short Character::getCharisma() const{	return Charisma;}void Character::setCharisma(unsigned short cha){	if (cha >= 1 && cha <= 20)		Charisma = cha;	else		std::cout<<"Illegal value for Charisma\n";}void Character::printCharacter() const{	std::cout<<"\nStrength: \t"<<Strength<<	"\nDexterity: \t"<<Dexterity<<	"\nConstitution: \t"<<Constitution<<	"\nIntelligence: \t"<<Intelligence<<	"\nWisdom: \t"<<Wisdom<<	"\nCharisma: \t"<<Charisma<<std::endl;}void Character::randomize(){	Strength = (rand() % 20) + 1;	Dexterity =  (rand() % 20) + 1;	Constitution = (rand() % 20) + 1;	Intelligence = (rand() % 20) + 1;	Wisdom = (rand() % 20) + 1;	Charisma = (rand() % 20) + 1;}


main.cpp
#include <iostream>#include <ctime>#include "character.h"int main(){	srand((unsigned)time(NULL));	Character c1;	std::cout<<"Character #1 with printCharacter():";	c1.printCharacter();	Character c2 = Character (18, 15, 15, 12, 10, 13);	std::cout<<"\nCharacter #2 with getters: "<<		"\nStrength: \t"<<c2.getStrength()<<		"\nDexterity: \t"<<c2.getDexterity()<<		"\nConstitution: \t"<<c2.getConstitution()<<		"\nIntelligence: \t"<<c2.getIntelligence()<<		"\nWisdom: \t"<<c2.getWisdom()<<		"\nCharisma: \t"<<c2.getCharisma()<<std::endl;	return 0;}
Myotis
Myotis
This is my take on Exercise 1 – The random character generator

I know it gives the expected output but it would be nice if you could comment my syntax. Is my way of solving this problem good ? Have I picken up bad programming practice ?

Thanks

My header file:

#include <iostream>#include <stdlib.h>#include <time.h>// int randomNum = ( rand() % 20 ) + 1;class Character{	public:		Character(int Str, int Dex, int Con, int Int, int Wis, int Cha);		Character();		~Character();		int GetStr() const {return itsStr;}		int GetDex() const {return itsDex;}		int GetCon() const {return itsCon;}		int GetInt() const {return itsInt;}		int GetWis() const {return itsWis;}		int GetCha() const {return itsCha;}		void SetStr(int Str) {itsStr=Str;}		void SetDex(int Dex) {itsDex=Dex;}		void SetCon(int Con) {itsCon=Con;}		void SetInt(int Int) {itsInt=Int;}		void SetWis(int Wis) {itsWis=Wis;}		void SetCha(int Cha) {itsCha=Cha;}	private:	// Stands for Strength, Dexterity, Constitution, Intelligence, Wisdom, Charisma .	int itsStr, itsDex, itsCon, itsInt, itsWis, itsCha;};


My cpp file:

#include "Character.h"using namespace std;Character::Character(int Str, int Dex, int Con, int Int, int Wis, int Cha){	if	(Str<=20 && Str>=1 && Dex<=20 && Dex>=1 && Con<=20 && Con>=1 && Int<=20 && Int>=1 && Wis<=20 && Wis>=1 && Cha<= 20 && Cha>=1)	{		itsStr=Str;		itsDex=Dex;		itsCon=Con;		itsInt=Int;		itsWis=Wis;		itsCha=Cha;	}	else	{		itsStr=1;		itsDex=1;		itsCon=1;		itsInt=1;		itsWis=1;		itsCha=1;	}	}Character::Character(){	itsStr=( rand() % 20 ) + 1;	itsDex=( rand() % 20 ) + 1;	itsCon=( rand() % 20 ) + 1;	itsInt=( rand() % 20 ) + 1;	itsWis=( rand() % 20 ) + 1;	itsCha=( rand() % 20 ) + 1;	if	(itsStr>20 || itsStr<1 || itsDex>20 || itsDex<1 || itsCon>20 || itsCon<1 || itsInt>20 || itsInt<1 || itsWis>20 || itsWis<1 || itsCha>20 || itsCha<1)	{		itsStr=1;		itsDex=1;		itsCon=1;		itsInt=1;		itsWis=1;		itsCha=1;	}}Character::~Character(){}int main(){	srand( (unsigned)time( NULL ) );	Character Me(14,16,14,16,16,14);	Character You;	cout<<"**YOU**" <<endl <<"Strength: " <<You.GetStr() <<endl;	cout<<"Dexterity: " <<You.GetDex() <<endl <<"Constitution: " <<You.GetCon() <<endl;	cout<<"Intelligence: " <<You.GetInt() <<endl <<"Wisdom: " <<You.GetWis() <<endl;	cout<<"Charisma: " <<You.GetCha() <<endl <<endl;	cout<<"**ME**" <<endl <<"Strength: " <<Me.GetStr() <<endl;	cout<<"Dexterity: " <<Me.GetDex() <<endl <<"Constitution: " <<Me.GetCon() <<endl;	cout<<"Intelligence: " <<Me.GetInt() <<endl <<"Wisdom: " <<Me.GetWis() <<endl;	cout<<"Charisma: " <<Me.GetCha() <<endl <<endl;	cin.get();	return 0;}


[Edited by - Myotis on August 12, 2006 1:15:29 AM]
Myotis
Myotis
Yes, sorry I replaced the && with ||
Dave Sutherland
Dave Sutherland
i've been following the workshop for the last couple of weeks and would like to say thanks to all those involved - its a great help.

i have a couple of questions about the character generating exercise.

is it necessary to include the Set accessors (eg void SetDexterity (int dexterity); ) or is this just good practice?

we have #include in the header file so do we need to include it
in the main.cpp file as well?

thanks
dave
DeadlyVirus
DeadlyVirus
You guys are helping me beyond imagine with this workshop. I have read so many books to learn c++ and it was hard to take it all in, but with your help I've been able to understand it.

Here is my random character, if you could please check my syntax ty.

//Character.h
#include <cstdlib>#include <iostream>using namespace std;class character{public:	// Default and main character	character();	character(unsigned short strength, unsigned short dexterity, unsigned short stamina, unsigned short intelligence, unsigned short wisdom, unsigned short charisma);	~character();	//accessors    unsigned short getStrength() const;	unsigned short getDexterity()const;	unsigned short getStamina() const; 	unsigned short getIntelligence() const;	unsigned short getWisdom() const;	unsigned short getCharisma() const;	void setStrength(unsigned short strength);	void setDexterity(unsigned short dexterity);	void setStamina(unsigned short stamina);	void setIntelligence(unsigned short intelligence);	void setWisdom(unsigned short wisdom);	void setCharisma(unsigned short charisma);private:	unsigned short Strength, Dexterity, Stamina, Intelligence, Wisdom, Charisma;};


//Character.cpp
#include "Character.h"//Class definitionscharacter::character(){	int randomStrength = ( rand() % 20 ) + 1;	int randomDexterity = ( rand() % 20 ) + 1;	int randomStamina = ( rand() % 20 ) + 1;	int randomIntelligence = ( rand() % 20 ) + 1;	int randomWisdom = ( rand() % 20 ) + 1;	int randomCharisma = ( rand() % 20 ) + 1;	Strength = randomStrength;	Dexterity = randomDexterity;	Stamina = randomStamina;	Intelligence = randomIntelligence;	Wisdom = randomWisdom;	Charisma = randomCharisma;}character::character(unsigned short strength, unsigned short dexterity, unsigned short stamina, unsigned short intelligence, unsigned short wisdom, unsigned short charisma){	if ( strength == 0 || strength > 20 || dexterity == 0 || dexterity > 20 || stamina == 0 ||		stamina > 20 || intelligence == 0 || intelligence > 20 || wisdom == 0 || wisdom > 20 ||		charisma == 0 || charisma > 20 )	{		std::cout << "Illegal values set" << std::endl;	}	else		Strength = strength;		Dexterity = dexterity;		Stamina = stamina;		Intelligence = intelligence;		Wisdom = wisdom;	    Charisma = charisma;}character::~character(){}//Get accessors definitionsunsigned short character::getStrength() const{	return Strength;}unsigned short character::getDexterity() const{	return Dexterity;}unsigned short character::getStamina()const{	return Stamina;}unsigned short character::getIntelligence() const{	return Intelligence;}unsigned short character::getWisdom() const{	return Wisdom;}unsigned short character::getCharisma() const{	return Charisma;}//Set Accessorsvoid character::setStrength(unsigned short strength){	Strength = strength;}void character::setDexterity(unsigned short dexterity){	Dexterity = dexterity;}void character::setStamina(unsigned short stamina){	Stamina = stamina;}void character::setWisdom(unsigned short wisdom){	Wisdom = wisdom;}void character::setCharisma(unsigned short charisma){	Charisma = charisma;}


//Main.cpp
#include <iostream>#include <ctime>#include "Character.h"int main(){	//random generator	srand ((unsigned)time(NULL));		//Integors for input values	int userStrength, userDexterity, userStamina, userIntelligence, userWisdom, userCharisma;    //Create random character	std::cout << "Creating random character, please hold..." << std::endl;	character Human;	std::cout << "Random Human character created!" << std::endl;	//Get input from user	std::cout << "You will enter stats for our Elf character." << std::endl;	std::cout << "Please enter values between 1-20." << std::endl;	std::cout << "Enter Strength: " << std::endl;	std::cin >> userStrength;	std::cout << "Enter Dexterity: " << std::endl;	std::cin >> userDexterity;	std::cout << "Enter Stamina: " << std::endl;	std::cin >> userStamina;	std::cout << "Enter Intelligence: " << std::endl;	std::cin >> userIntelligence;	std::cout << "Enter Wisdom: " << std::endl;	std::cin >> userWisdom;	std::cout << "Enter Charisma: " << std::endl;	std::cin >> userCharisma;	//Input stats for user character	std::cout << "Inputting stats, please hold..." << std::endl;	character Elf(userStrength, userDexterity, userStamina, userIntelligence, userWisdom, userCharisma);	//Output random stats	std::cout << "Human's stats are: " << std::endl;	std::cout << "Strength: " << Human.getStrength() << std::endl;	std::cout << "Dexterity: " << Human.getDexterity() << std::endl;	std::cout << "Stamina: " << Human.getStamina() << std::endl;	std::cout << "Intelligence: " << Human.getIntelligence() << std::endl;	std::cout << "Wisdom: " << Human.getWisdom() << std::endl;	std::cout << "Charisma: " << Human.getCharisma() << std::endl << std::endl << std::endl;	//Output user stats	std::cout << "Now outputting Elf's stats that you entered: " << std::endl;	std::cout << "Strength: " << Elf.getStrength() << std::endl;	std::cout << "Dexterity: " << Elf.getDexterity() << std::endl;	std::cout << "Stamina: " << Elf.getStamina() << std::endl;	std::cout << "Intelligence: " << Elf.getIntelligence() << std::endl;	std::cout << "Wisdom: " << Elf.getWisdom() << std::endl;	std::cout << "Charisma: " << Elf.getCharisma() << std::endl;	//end file	system("PAUSE");	return 0;}
J0Be
J0Be
Where can I find your answers to the Quiz/Exercise of these chapters jwalsh?
shawnre
shawnre
Quote:
Original post by J0Be
Where can I find your answers to the Quiz/Exercise of these chapters jwalsh?


I second that question. I am having to go back and reread Chapter 6 myself, got a little confused on some of the information. I should also go back and reread Chapter 5 I think, because I believe that is what is causing my confusion. First I read about function prototypes and defining the functions, thought I grasped that. After reading this chapter however, I think I am confusing declaring classes vs. functions (I suppose I mean the structure/syntax of each).

Anyhow, being able to compare the "correct" answers to my answers would be helpful. As well as, where can I fina a "correct" implementation of the Random Character Generator? I know there are lots of different ways to do it, I would just like to see how one of the tutors had coded it. Thanks for the workshop, if it hadnt been for my college, I would have been on board since the beginning!!!

Shawn

J0Be
J0Be
Chapter 6.

1) What was the 'C' capability which allowed you to combine related variables? Did this solve the problem of connection data with behaviors?
A) That capability was a struct, which could be made available as a new data type through the use of typedef statement. It didn't solve the problem of connecting data with behaviors because struct's' and the functions that operate on them aren't cohesive wholes; functions can only be found by reading the header files for the libraries available and looking for those with the new type as parameter.

2) How do you make a new type in C++?
A) You make a new type in C++ by declaring a class.

3) What is a class?
A) A class is a collection of variables--ofter of different types--combined with a set of related functions.

4) What is another name for variables within a class? What is another name for the member functions?
A) Another name for a variable in a class is a 'data member', a member function can be called a 'method'.

5) What are the requisite parts of a class declaration? Show an example.
A) To declare the class, use the class keyword followed by the class name, an opening brace, and then list of the data member and methods of that class. End the declaration with a closing brace and a semicolon.
Example: class myClass
{
public:
int myInt;
std::string myString;

void myFunction();
};

6) What are the two things a class declaration tells your compiler?
A) It tells the compiler how big it is, without reserving any memory yet, and what data members and functions it has declared.

7) When discussing naming conventions, what's the most important point to remember?
A) That you as a programmer MUST name all your member variables, member functions and classes.

8) What is an object?
A) An object is an individual instance of a class.

9) How do you declare an object? Show an example.
A) You write the name of the class which is then followed by the name of the class object. If my class would be called myGame, then I could declare the object as follows: myGame TotalWar;

10) What operator is used to access members and methods of a class for objects created on the stack?
A) The dot ( . ) operator is used for that.

11) What is the difference between public and private members/methods within a class? Wich is default?
A) Private members can be accessed only within methods of the class itself. Public members can be accessed through any object of the class. All members of a class are private by default.

12) In general, should methods or members be private? Why?
A) Members should be kept private while in general, methods are public, the main reason is to keep your progam easy to maintain. It gives your code a longer life because design changes don't make your program obsolete.

13) What is the primary way you initialize the member data of a class.
A) By using a constructor.

14) How can you identify a constructor far a class?
A) It has the same name as the class and has no return value, not even void.

15) What is a default constructor? How is it called?
A) A default constructor is a constructor without parameters and is called by the compiler automatically if you haven't created one of your own.

16) What does "declaring a method of a class const" mean? What is the syntax for such a declaration?
A) It means that you promise not to change the member function during it's call. The syntax looks like this for example: int myFunc() const;

17) In the context of classes and objects, what is a client?
A) Clients are the parts of the program that create and use objects of your class.

18) Where do class declarations go? Wher do the member function definitions go?
A) Declarations go intoo an .h or .hpp file, member definitions go intoo a .cpp file.

19) When one class has a member variable which is an object of a different class they are said to form a _____ relationship?
A) A "has-a" relationship.

20) What is the only difference between C++ classes and C++ structs?
A) Class members and methods are by default private, with structs, they're public by default.

Chapter 11.

1) What's the purpose of a model?
A) The purpose is to create a meaningfull abstraction of the real world in a simplified manner but accuratly enough so that it can be used to predict the behaviour of things in the real world.

2) What is the basic philosophy of iterative design/development?
A) The basic philosophy is to start with a concept; an idea of what you might want to buld and develop it further step by step and iterate back to a previous step(s) to expand the design.

3) What's the difference between waterfall vs.iterative development?
A) In waterfall development, the output from one stage becomes the input to the next, problem with this is, you can't go a step back. With iterative development, you start with an idea and build upon that idea by iterating threw several stages and going back to a previous stage(s) when needed.

4) What are the 6 steps listed in your book for iterative development?
A) 1) Conceptualization.
2) Analysis.
3) Design.
4) Implementation.
5) Testing
6) Rollout.

5) What happens if you lose sight of the vision of your product?
A) Then, almost surely, your project is doomed.

6) What is a use case?
A) It is a high-level description of how the product will be used. Use cases drive not only the analysis, but they also drive the design, they help you determine the classes, and they are especially important in testing the product.

7) What is a domain expert?
A) A domain expert is someone with expertise in the domain(area) of business for which you are creating the product.

8) What is an actor?
A) Any person or system that interacts with the system you are developing.

9) What are the 6 questions you should ask yourself about the actors when determining use cases, according to your book?
A) 1. Why is the actor using this system?
2. What outcome does the actor want or expect from each request?
3. What happened to cause the actor to use this sytem now?
4. What must the actor do to use the system?
5. What information must the actor provide to the system?
6. What information does the actor hope to get from the system?

10) What is a domain model?
A) A domain model is a document that captures all you know about the domain(the field of business you are working in).

11) What is a scenario?
A) A scenario is a description of a specific set of circumstances that distinguish amoung the various elements of the use case.

12) What are the nine items, according to your book, should you include when documenting a scenario?
A) 1. Preconditions - What must be true for the scenario to begin.
2. Triggers - What even causes the scenario to begin.
3. What actions the actors take.
4. What results or changes are caused by the system.
5. What feedback the actors receive.
6. Whether repeating activities occur, and what causes them to conclude.
7. A description of the logical flow of the scenario.
8. What causes the scenario to end.
9. Postconditions - What must be true when the scenario is complete.

13) What is system analysis?
A) System analysis is the process of collecting all the details for the systems with which you will interact.

14) What is the simplistic technique, according to your book, for determining the classes in your project?
A) The simplified technique is by writing out the use-case scenarios and then creating a class for every noun.

15) What are the three areas of concern for the Static Model of your classes?
A) 1. Responsibilities - each class should be responsible for one thing.
2. Attributes .
3. Relationships.

16) What is the most important principle when deciding the responsibilities of a class?
A) That each class must have one and only one responsibility.

17) What are the two types of diagrams shown in the book for determining how classes interact?
A) 1. Sequence diagram.
2. Collaboration diagram.

// Character.h file#include <iostream>class Character{public:	Character();	Character(int strength, int dexterity, int stamina, int intellect, int wisdom, int charisma);	~Character();	int GetStrength() const;	int GetDexterity() const;	int GetStamina() const;	int GetIntellect() const;	int GetWisdom() const;	int GetCharisma() const;	int ValidInput(int value);		// method will check whether value is within it's min- and maximum range.	int RandomNumGen();				// will generate a number between the min- and maximum range.	void PrintValues() const;	private:	int m_Strength;	int m_Dexterity;	int m_Stamina;	int m_Intellect;	int m_Wisdom;	int m_Charisma;	const static int m_MAX = 20;	const static int m_MIN = 0;};


// Character.cpp-file.#include <cstdlib>#include "Character.h"Character::Character(){	m_Strength = RandomNumGen();		m_Dexterity = RandomNumGen();		m_Stamina = RandomNumGen();		m_Intellect = RandomNumGen();		m_Wisdom = RandomNumGen();		m_Charisma = RandomNumGen();}Character::Character(int strength, int dexterity, int stamina, int intellect, int wisdom, int charisma){		m_Strength = ValidInput(strength);	m_Dexterity = ValidInput(dexterity);	m_Stamina = ValidInput(stamina);	m_Intellect = ValidInput(intellect);	m_Wisdom = ValidInput(wisdom);	m_Charisma = ValidInput(charisma);}Character::~Character() {}int Character::GetStrength() const{	return m_Strength;}int Character::GetDexterity() const{	return m_Dexterity;}int Character::GetStamina() const{	return m_Stamina;}int Character::GetIntellect() const{	return m_Intellect;}int Character::GetWisdom() const{	return m_Wisdom;}int Character::GetCharisma() const{	return m_Charisma;}int Character::ValidInput(int value){	if(value > m_MIN && value < m_MAX)		return value;	else		return (0);}int Character::RandomNumGen(){	int randomNum = ( rand() % m_MAX ) + 1;	return randomNum;}void Character::PrintValues() const{	std::cout << "Strength:\t " << m_Strength << " Points." << std::endl		<< "Dexterity:\t " << m_Dexterity << " Points." << std::endl		<< "Stamina:\t " << m_Stamina << " Points." << std::endl		<< "Intellect:\t " << m_Intellect << " Points." << std::endl		<< "Wisdom:\t\t " << m_Wisdom << " Points." << std::endl		<< "Charisma:\t " << m_Charisma << " Points." << std::endl;}


// Exampl()e(s) and exercise(s) from the book: Sams Teach Yourself// Authors: Jesse Liberty and Bradley Jones// Combination with the online tutorial classes from Jeromy Walsh on Gamedev.// Required headers#include <ctime>#include "Character.h"int main(){	// Call this ONCE, in your main function to seed the random number generator	srand( (unsigned)time( NULL ) );	Character Tom(15, 13, 14, 13, 34, 5);	Character Johan;	std::cout << "The values for Tom are: \n";	Tom.PrintValues();	std::cout << "\n\nThe values for Johan are:\n" 		<< "Strength:\t " << Johan.GetStrength() << " Points." << std::endl		<< "Dexterity:\t " << Johan.GetDexterity() << " Points." << std::endl		<< "Stamina:\t " << Johan.GetStamina() << " Points." << std::endl		<< "Intellect:\t " << Johan.GetIntellect() << " Points." << std::endl		<< "Wisdom:\t\t " << Johan.GetWisdom() << " Points." << std::endl		<< "Charisma:\t " << Johan.GetCharisma() << " Points." << std::endl;	return 0;}
Dbproguy
Dbproguy
Chapter 6 Quiz

1. What was the ‘C’ capability which allowed you to combine related variables? Did this solve the problem of connecting data with behaviors?
Structures, it didn't solve the problem though.

2. How do you make a new type in C++?
making the class declaration, class myClass { }

3. What is a class?
It is a type, it combines several variables, functions and types to make one object.

4. What is another name for variables within a class? What is another name for the member functions?
Data members and methods.

5. What are the requisite parts of a class declaration? Show an example.
The name, opening brace the data members and methods then a closing brace and a semi-colon after the closing brace.

6. What are the two things a class declaration tells your compiler?
It tells the compiler what the class is and what it can do (example, the class Cat, it tells the compiler what a cat is and what it can do)

7. When discussing naming conventions, what’s the most important point to remember?
To use one easy-to-remember naming convention so while you code you aren't try ing to figure out what the case is of a certain variable, etc.

8. What is an object?
A variable, the type being the class.

9. How do you declare an object? Show an example.
Just as you declare a variable, if the class was named cat,
Cat Frisky;

10. What operator is used to access members and methods of a class for objects created on the stack.
The dot operator, like Cat.SetAge() would access the method SetAge.

11. What is the difference between public and private members/methods within a class? Which is the default?
Private data members and methods can only be access from other methods within the class. Public data members and methods can be access from anywhere in the program, unless public or private is specified it's always private by default.

12. In general, should methods or members be private? Why?
Methods should generally be public and data members private.

13. What is the primary way you initialize the member data of a class?
Setting a constructor, and then assigning values to the data members in the constructor.

14. How can you identify a constructor for a class?
Declare it in the class declaration just with the class name and no type, with the parameters listed as usual in a function. Then you can make it a function basically and all that is within the function will happen when the class is defined.

15. What is a default constructor? How is it called.
A constructor that does nothing, called just as Cat(); in the example of the class cat

16. What does “declaring a method of a class const” mean? What is the syntax for such a declaration?
That promises that the method will not change any values of the class.

17. In the context of classes and objects, what is a client?
The function which calls the class/object.

18. Where do class declarations go? Where do the member function definitions go?
The declarations should be at the beginning, or in a header file. the function definitions should go in the main source file.

19. When one class has a member variable which is an object of a different class they are said to form a ___ relationship? a has-a relationship.

20. What is the only difference between C++ classes and C++ structs?
They could not have methods/functions.
--Dbproguy - My Blog - Tips, Opinions and Reviews about C++, Video Games, and Life
Dbproguy
Dbproguy
Chapter 11 Quiz

1. What’s the purpose of a model?
To know what you are doing when making a program.

2. What is the basic philosophy of iterative design/development?
Starting with an idea and expanding on it.

3. What’s the difference between waterfall vs. iterative development?
The waterfall method only features the 4 categories, analysis design implmentation and test, but you cannot go in reverse order and it isn't so great. iterative development features a full 6 steps (including conceptualization where you start with a small idea)

4. What are the 6 steps listed in your book for iterative development.
Conceptualization, analysis, design, implementation, testing and rollout

5. What happens if you lose sight of the vision of your product?
Your product is doomed

6. What is a use case?
A description of the different possible uses of the product.

7. What is a domain expert?
Someone who deals with the domains of the product and knows how to do it well.

8. What is an actor?
The external objects which will use the product, like customers and bankers for an atm.

9. What are the 6 questions you should ask yourself about the actors when determining use cases, according to your book?
Why is the actor using this system? What outcome does the actor want or expect from each request? What happened to cause the actor to use this system now? What must the actor do to use the system? What information must the actor provide to the system? What informatio ndoes the actor hope to get from the system?

10. What is a domain model?
A document that captures all needed knowledge about the domain.

11. What is a scenario?
Something that can happen, all possible scenario's must be found and dealt with.

12. What are the 9 items, according to your book, should you include when documenting a scenario?
Preconditions, Triggers, Actions, Results, Feedback received, Looping and what causes the loop to end, Logical flow of the scenario, What makes the scenario end, Postconditions

13. What is systems analysis?
The process of collectiong details which will ineract with the product

14. What is the simplistic technique, according to your book, for determining the classes in your project?
Write out the use-case scenarios then make a class for every noun.

15. What are the three areas of concern for the Static Model of your classes?
responsibilities, attributes and relationships

16. What is the most important principle when deciding the responsibilities of a class?
Understanding what each class does.

17. What are the two types of diagrams shown in the book for determining how classes interact?
Aggregation and Composition.

#include <stdlib.h>		//Header - required for the randomization#include <time.h>		//Header - required to get the time for the seed#include <iostream>		//The regular in out stream headerusing std::cout;using std::endl;		//Using the cout, endl and cin functions of the std libraryusing std::cin;class Character{public:	//constructors/destructor	Character();	Character (int str, int dex, int sta, int intel, int wis, int cha);	~Character(){}	//accessor functions Get	int GetStrength() { return itsStrength; }	int GetDexterity() { return itsDexterity; }	int GetStamina() { return itsStamina; }	int GetIntellect() { return itsIntellect; }	int GetWisdom() { return itsWisdom; }	int GetCharisma() { return itsCharisma; }	//accessor functions Set	void SetStrength(int str) { itsStrength = str; }	void SetDexterity(int dex) { itsDexterity = dex; }	void SetStamina(int sta) { itsStamina = sta; }	void SetIntellect(int intel) { itsIntellect = intel; }	void SetWisdom(int wis) { itsWisdom = wis; }	void SetCharisma(int cha) { itsCharisma = cha; }private:	int itsStrength;	int itsDexterity;	int itsStamina;	int itsIntellect;	int itsWisdom;	int itsCharisma;};//Random number functionint RandNum(int range, int start){	int randNum = ( rand() % range ) + start;	return randNum;}//The constructor, which adds a value to the variables by the given random numbers.Character::Character(){	itsStrength = RandNum(20,1);	itsDexterity = RandNum(20,1);	itsStamina = RandNum(20,1);	itsIntellect = RandNum (20,1);	itsWisdom = RandNum (20,1);	itsCharisma = RandNum (20,0);}//The overloaded constructor, initializing all the variablesCharacter::Character(int str, int dex, int sta, int intel, int wis, int cha){	if ((str >=1) && (str <= 20))	{		itsStrength = str;	}	else	{		cout << "Invalid Strength. Setting to a random number." << endl;		itsStrength = RandNum(20,1);	}	if ((dex >=1) && (str <= 20))	{		itsDexterity = dex;	}	else	{		cout << "Invalid Dexterity. Setting to a random number." << endl;		itsDexterity = RandNum(20,1);	}	if ((sta >=1) && (sta <= 20))	{		itsStamina = sta;	}	else	{		cout << "Invalid Stamina. Setting to a random number." << endl;		itsStamina = RandNum(20,1);	}	if ((intel >=1) && (intel <= 20))	{		itsIntellect = intel;	}	else	{		cout << "Invalid Intellect. Setting to a random number." << endl;		itsIntellect = RandNum(20,1);	}	if ((wis >=1) && (wis <= 20))	{		itsWisdom = wis;	}	else	{		cout << "Invalid Wisdom. Setting to a random number." << endl;		itsWisdom = RandNum(20,1);	}	if ((cha >=1) && (cha <= 20))	{		itsCharisma = cha;	}	else	{		cout << "Invalid Charisma. Setting to a random number." << endl;		itsCharisma = RandNum(20,1);	}}//Main functionint main(){	srand( (unsigned)time( NULL ) );	cout << "Welcome to the Random Character Generator" << endl;	cout << "   by Marcus Johnson" << endl << endl;	cout << "I will start off by creating a player named Bob with random stats." << endl;	cout << "Press enter to continue" << endl;	cin.get();	Character Bob;	cout << "Bob:" << endl << endl;	cout << "Strength: " << Bob.GetStrength() << endl;	cout << "Dexterity: " << Bob.GetDexterity() << endl;	cout << "Stamina: " << Bob.GetStamina() << endl;	cout << "Intellect: " << Bob.GetIntellect() << endl;	cout << "Wisdom: " << Bob.GetWisdom() << endl;	cout << "Charisma: " << Bob.GetCharisma() << endl << endl;	int strength, dexterity, stamina, intellect, wisdom, charisma;	cout << "Now you get to create the stats of Joe." << endl;	cout << "Strength: ";	cin >> strength;	cout << "Dexterity: ";	cin >> dexterity;	cout << "Stamina: ";	cin >> stamina;	cout << "Intellect: ";	cin >> intellect;	cout << "Wisdom: ";	cin >> wisdom;	cout << "Charisma: ";	cin >> charisma;	cout << endl;	Character Joe(strength, dexterity, stamina, intellect, wisdom, charisma);	cout << endl << endl << "Here's the stats of Bob and Joe." << endl;	cout << "Bob:" << "\t\tJoe:" << endl << endl;	cout << "Strength: " << Bob.GetStrength() << "\tStrength: " << Joe.GetStrength() << endl;	cout << "Dexterity: " << Bob.GetDexterity() << "\tDexterity: " << Joe.GetDexterity() << endl;	cout << "Stamina: " << Bob.GetStamina() << "\tStamina: " << Joe.GetStamina() << endl;	cout << "Intellect: " << Bob.GetIntellect() << "\tIntellect: " << Joe.GetIntellect() << endl;	cout << "Wisdom: " << Bob.GetWisdom() << "\tWisdom: " << Joe.GetWisdom() << endl;	cout << "Charisma: " << Bob.GetCharisma() << "\tCharisma: " << Joe.GetCharisma() << endl << endl;	cout << "Thanks for trying this.  Bye." << endl;}


[Edited by - Dbproguy on May 23, 2008 5:53:15 PM]
--Dbproguy - My Blog - Tips, Opinions and Reviews about C++, Video Games, and Life

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.