Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jeff West - Quiz Section 9

Similar presentations


Presentation on theme: "Jeff West - Quiz Section 9"— Presentation transcript:

1 Jeff West - Quiz Section 9
CSE 143 Section AD Quiz Section 9 7/17/2001 Jeff West - Quiz Section 9

2 Jeff West - Quiz Section 9
Announcements I’d like to welcome as much feedback as possible about how well quiz sections are preparing you so please feel free to talk to me about them… I have linked a feedback form from the Section AD web page if you want to remain anonymous… Grades are on the course website – check to make sure yours are right ;) There is a midterm in Thursday… if there is anything at all that is unclear to you please me or visit my office hours! 7/17/2001 Jeff West - Quiz Section 9

3 Jeff West - Quiz Section 9
Character As a game designer, we have created the following class for a character: class Character { public: Character(string newName, int newLevel, int newExp); void drawCharacter(); private: string name; // character’s name int level; // current level int experience; // current experience }; 7/17/2001 Jeff West - Quiz Section 9

4 Jeff West - Quiz Section 9
CharacterList We want to store all of the users that are in the game in a CharacterList so that we could run the following code: CharacterList players1, players2; players.addPlayer(“Jeff”, 50, 50000); players2 = players1; CharacterList players3 = players1; List as many useful functions as you can to make this CharacterList as efficient as possible. HINT: SEE SLIDE N-35 7/17/2001 Jeff West - Quiz Section 9

5 Jeff West - Quiz Section 9
CharacterList class CharacterList { public: CharacterList(); // default constructor CharacterList(const CharacterList&); // copy constructor CharacterList& CharacterList::operator=(CharacterList& other); // controls assignment of CharacterLists ~CharacterList(); // destructor void copy(CharacterList& other); // copy’s other’s values to this instance void cleanup(); // cleans up this instance of the class bool isEmpty(); // is list empty? int length(); // how big is list? void addPlayer(string newName, int newLevel, int newExp); // insert a new character Character listDelete(int position); // deletes character at this location Character listRetrieve(int position); // returns character at this location private: Character* characters; // characters[0…capacity-1] is space allocated for this vector int size; // characters are store in characters[0…size-1] int capacity; // current maximum array size void ensureCapacity(int n); // ensure the list can hold at least n elements void growArray(int n); // set size of the list to n elements }; 7/17/2001 Jeff West - Quiz Section 9

6 CharacterList Implemented…
Go ahead, implement it ;)… I don’t have slides to implement it for ya this time  Each of the top six functions is extremely important… make sure you understand how they work and why they’re there! 7/17/2001 Jeff West - Quiz Section 9

7 Jeff West - Quiz Section 9
What About operator+… Once again, no slide prepared to give you the answer…  Try implementing operator+ so that it will return a CharacterList that includes all of the elements in BOTH of the CharacterLists that are being added. You can assume that all characters are unique. 7/17/2001 Jeff West - Quiz Section 9

8 Jeff West - Quiz Section 9
Review That’s sorta up to you… ask me anything… the only question I have received in the last four or five days was a question about the const keyword: 7/17/2001 Jeff West - Quiz Section 9


Download ppt "Jeff West - Quiz Section 9"

Similar presentations


Ads by Google