Question: Part 1 - lab (50%) The Army Class the class Code an Army class that holds the information for an Army. The class must have

 Part 1 - lab (50%) The Army Class the class Codean Army class that holds the information for an Army. The classmust have private data members to include the following information: a) the

Part 1 - lab (50%) The Army Class the class Code an Army class that holds the information for an Army. The class must have private data members to include the following information: a) the nationality of an Army, b) the number of units in an Army, and e) the power of an Army. Declare one C++ constant namely MAX_NAME_LEN and set it to 50. Declare three private data members. 1. Declare an array to hold the nationality of an Army, not exceeding MAX_NAME_LEN characters. 2. Declare an integer variable for the number of units in an Army. 3. Declare a double variable for the power of an Army. Store your class definition in a header file named Army.h and your member function definitions in an implementation file named Army.opp. Public Member functions Declare and implement the following member functions. setEmpty: void setEmpty () ; This member function initializes the Army object to a safe empty state. An Army is in an empty state when it has an empty nationality and no units.createArmy; void creatermyfconst char* country, double powJI int troops); It uses three input parameters to initialize an Army object. It receives the nationality of an il-'trmyr the number of units in an Army and the power of the Army. ltvalidates the data values received and uses these data values to set the respective data members. only if all of them are valid. All the data values are valid if a) the first parameter is not nullptr and the length of the name is greater than zero. b) the number of units is greater than zero c) the power is greater than zero. Note: Only copy the first MAX_NAME_LEN characters from the input parameter to the cString data member that holds the nationality of an Army. (you could use strncpyl or your own utility function for this 3 If the data values are invalid. the memberfunction initializes the Army object to a safe empty state. updateUnits: void updateUnitsfin't troops}; Update your Army by incrementing the units with the amount of provided troops also the power of the Army will be increased by a value equal to 25% of the newly provided troops. checkNationality: const char* checkNationalityfj const; This query returns the nationality of an Army. checkCapacity: int checkCapacity() const; This query returns the number of units in an Army. checkPower: double checkPower() const; This query returns the power of an Army. isEmpty: bool isEmpty () const; This query returns true if the Army object is in a safe empty state; false otherwise. isStrongerThan: bool isStrongerThan (const Army& army )const; This function returns true if the Army has more power than the incoming Army, and returns false otherwise. Global (stand-alone) functions battle: void battle ( Army& arml, Army& arm?) ; This function will force both armies to fight. If both armies are valid, the losing Army will lose 50%% of their unit count PS: - you might want to use the isStrongerThan function to check which Army will win - you might want to use the updateUnits function to update the losing country. Passed value needs to be casted to an int display: void displayDetails (const Army* armies, int size); This function sends the information about an Army array to standard output in the following format if the object holds valid data values. Armies reporting to battle: Each Army in the array will be printed in the following format. Nationality: 100000XXXXXX, Units Count : XXXX, Power left: X. X Power left has one digit after the decimal point

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!