|
|
|
|
|
|
I am not grasping how I am to link the 3 files first of all |
all
their homework, and this looked like another one of those.http://www.cplusplus.com/doc/tutorial/pointers/ |
http://www.cplusplus.com/doc/tutorial/classes/ |
My instructor told me not to include the Character.h in main.cpp. He said that the compiler will know they go together as long as they are in the same project folder. |
My instructor told me not to include the Character.h in main.cpp. He said that the compiler will know they go together as long as they are in the same project folder. |
Character
means if the symbol has already been defined in that translation unit. We include that definition, by #include
-ing the header file that contains the definition.Character
will also need to be part of that translation unit - which means we also include the header file in Character.cpp.#include "Character.h"
and defines the functions (or will when I write that portion of code, if I #include "Character.h"
in main.cpp, then I will have access to the function definitions from Character.cpp in main.cpp? Is that what you are telling me?
cin >>
or cout <<
statements. Everything that will be displayed is coming from his hard coded program that runs through ours to check if we hit all the marks. I just have a difficult time visualizing this program without actually having those statements to reference while I'm writing the code. Should I just write the code with those statements and then comment them out later when the program is running properly?
Statement of Work Programming Assignment 1 1.0 Overview In role-playing adventure games such as Dungeons and Dragons each person creates a player character which they play in the game. In this program a C++ class will be created which can be used to define a player character according to the rules of Dungeons and Dragons. This programming assignment requires an understanding of pointers, and C++ functions and classes. Simply put, a class is a data structure which contains data and the functions to work on that data. A pointer is a variable that holds the memory address of another variable, data structure, or class. This program will provide the opportunity to explore pointers, functions, and classes and learn how to use them. 2.0 Requirements The student shall define, develop, document, prototype, test, and modify as required the software system. 2.1 This software system shall define a player character class called Character (file names shall be Character.h and Character.cpp) which contains all information to define and maintain a player character for a Dungeons and Dragons style role playing adventure game. 2.1.1 The Character class shall contain private variables as described below: 2.1.1.1 A character array, called m_sName capable of holding strings of up to 64 characters. 2.1.1.2 Three ints called m_iClass, m_iAlignment, and m_iHitPoints. 2.1.1.3 An array of six integers called m_iCharTraits used to represent the character qualities of: Strength, Dexterity, Constitution, Intelligence, Wisdom, and Charisma 2.1.2 The Character class shall contain public functions as described below: 2.1.2.1 Character(), ~Character() A default constructor and destructor. 2.1.2.2 Character(char *name, int cl, int al, int hp, int str, int dex, int con, int itl, int wis, int chr) A parameterized constructor which shall take as arguments a character array giving the name and integer arguments specifying the class, alignment, hit points, strength, dexterity, constitution, intelligence, wisdom, and charisma of the character. 2.1.2.3 Get/Set functions There will be a getVariable() and a setVaraible() designed to return the value stored in or set the value stored in a character's data. Specifically these functions shall be prototyped as: 2.1.2.3.1 void getName(char *name), void setName(char *name) - Get and set the player name. 2.1.2.3.2 void getClass(int& cl), void setClass(int cl) - Get and set the player class. The get function shall be a reference function. 2.1.2.3.3 void getAlignment(int& al), void setAlignment(int al) - Get and set the player alignment value. The get function shall be a reference function. 2.1.2.3.4 void getHitPoints(int& hp), void setHitPoints(int hp) - Get and set the player hit points. The get function shall be a reference function. 2.1.2.3.5 Six pairs of functions to get and set the various character traits stored in the m_iCharTraits array. All of the get functions shall be pointer functions. The functions are: void getStrength(int *str), void setStrength(int str) - Get and set the player Strength score (m_iCharTraits[0]). void getDexterity(int *dex), void setDexterity(int dex) - Get and set the player Dexterity score (m_iCharTraits[1]). void getConstitution(int *cn), void setConstitution(int cn) - Get and set the player Constitution score (m_iCharTraits[2]). void getIntelligence(int *itl), void setIntelligence(int itl) - Get and set the player Intelligence score (m_iCharTraits[3]). void getWisdom(int *wis), void setWisdom(int wis) - Get and set the player Wisdom score (m_iCharTraits[4]). void getCharisma(int *chr), void setCharisma(int chr) - Get and set the player Charisma score (m_iCharTraits[5]). 2.1.2.3.6 void printAll() - Print all information on this character. This includes, Name, Class, Alignment, Hit points, and all 6 character trait values. 2.2 The class file and its' associated header file must be capable of being compiled and linked in with the instructor's driver program (which will contain main) for testing. Do not turn in your source file containing main. It will not be used for testing. 3.0 Deliverables These products shall be delivered to the instructor electronically via e-mail as specified below. 3.1 Sprint Report -- The student shall provide filled out Sprint Report form for instructor approval NLT (Not Later Than) Thursday, February 4. 3.2 Program source files -- The student shall provide fully tested electronic copies of the .cpp and .h files. These files must be submitted to the instructor via e-mail. The files shall be delivered NLT Thursday, February 4. 4.0 Period of Performance The period of performance of this assignment is 21 days from the date of assignment. No deliverables be accepted after midnight of the DDD date posted in the Course Syllabus. A note on program grading: The instructor will test your program by compiling your Character.cpp and Character.h files with a driver program containing a main() function. This driver will exhaustively test your source code. |
The class file and its' associated header file must be capable of being compiled and linked in with the instructor's driver program (which will contain main) for testing. Do not turn in your source file containing main. It will not be used for testing. |
|
|