Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the game one can create arbitrary many characters, that are being tracked by the game. The program has the following functions: A name HP

In the game one can create arbitrary many characters, that are being tracked by the game.

The program has the following functions:

A name HP weaponname weapondamage:Add character: Adds a character with givenname. The character has initiallyHPhit points, and the given weapon, with maximum damage as indicated in weapondamage. For example: A Bilbo 25 Dagger 8.(1 p)

H attacker target:Attack: Character attacker will attack towards character target. As the result targets hit points will be decremented by the damage caused by the weapon (that can be randomized, if you wish). The outcome of attack must be printed to the user. For example: H Bilbo Smeagol. An example output could then be: Bilbo attacked Smeagol with Dagger by 6 damage. Smeagol has 8 hit points remaining. Bilbo gained 6 experience points(1 p)

L:List characters: Prints all characters added to the game, each on their own line. For each character all the above described properties must be printed (name, HP, Exp, Weapon). The characters should be ordered by their experience points: the chactacter with most experience points will be printed first. However, the dead characters should be printed at the end of the list, regardless of their experience points. If output works, but the order is wrong, you will get one point. If the order is correct, you will getmax. 2 points.

W filename: Saves all characters in the game (including the dead ones) to file named filename.(1 p)

O tiedosto: Loads characters from file name filename, replacing the current setup in memory.(1 p)

Q:Exit program: Quits program and releases all allocated memory. This function is must be implemented in order to detect possible memory leaks.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions