/*======== Fall 2022 - CS 112 Week 7 Lab Exercise - Problem 2 - dynamically-allocated objects and dynamic arrays of objects compile using: g++ 112lab07-ex2.cpp PlayerChar.cpp -o 112lab07-ex2 run using: ./112lab07-ex2 Do NOT remove any of the comments below -- ADD the specified statement(s) after each of them. ========*/ /*--- by: ***PUT BOTH of YOUR NAMES HERE*** last modified: 2022-10-07 ---*/ #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include "PlayerChar.h" using namespace std; int main() { cout << boolalpha; //*** Make COPIES of Week 5 Lecture 2's: //*** //*** * PlayerChar.h //*** * PlayerChar.cpp //*** //*** ...in your folder for today's lab //*** DECLARE a pointer to a PlayerChar named player_ptr //*** WRITE a statement that causes player_ptr to point to an //*** appropriate dynamically-allocated chunk of memory //*** such that PlayerChar's 5-argument constructor will be //*** used //*** WRITE a statement to CHANGE the role of the PlayerChar //*** object pointed to by player_ptr to be "bard" //*** WRITE a statement to print to the screen the current //*** data fields of the PlayerChar object pointed to by //*** player_ptr (you can choose either one of the two reasonable //*** PlayerChar methods for this) //*** since you are now done using player_ptr, //*** DEALLOCATE/free the memory that player_ptr is pointing to, //*** and then set player_ptr to point to nothing (following //*** CS 112 course coding standards) //*** DECLARE a pointer to a PlayerChar named party //*** WRITE statements to the screen declaring an int local variable, //*** asking the user HOW many players will be in today's party, //*** reading in what they enter //*** WRITE a statement that causes party to point to an //*** appropriate dynamically-allocated ARRAY of the size entered //*** by the user above //*** WRITE a loop that asks the user to enter at least the //*** names, exp, and roles, (and, optionally, also the //*** strength and/or hp), //*** for that many players, and creates PlayerChar //*** objects and puts them into party accordingly //*** WRITE a loop that averages the exp of PlayerChars in the array party //*** (declare and initialize needed local variable(s) before this loop) //*** PRINT a message to the screen including the average exp //*** computed above of the PlayerChar objects in //*** the array party //*** WRITE a loop displaying the contents of party (using your choice //*** of the two reasonable methods for this) //*** DEALLOCATE/free the entire dynamically-allocated array party //*** and then set party to point to nothing (following //*** CS 112 course coding standards) return EXIT_SUCCESS; }