We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Inheritance
- Magic Spells
- Discussions
Magic Spells
Magic Spells
Sort by
recency
|
109 Discussions
|
Please Login in order to post a comment
Take my whiskey neat Solution
The question actually contains two parts. One is to practice how to use dynamic casting, the other is to practice the algorithm of how to find the longest common sequence of two strings. Search online for the longest common sequence algorithm and understand the underlying method, and you could solve this challenge!
if (Waterbolt* w = dynamic_cast(spell)) { w->revealWaterpower(); // If the spell is of type Waterbolt, reveal its water power. } else if (Thunderstorm* t = dynamic_cast(spell)) { t->revealThunderpower(); // If the spell is of type Thunderstorm, reveal its thunder power. } else if (Fireball* fi = dynamic_cast(spell)) { fi->revealFirepower(); // If the spell is of type Fireball, reveal its fire power. } else if (Frostbite* fr = dynamic_cast(spell)) { fr->revealFrostpower(); // If the spell is of type Frostbite, reveal its frost power. } else { string spell_name = spell->revealScrollName(); // Extract the name of the spell from the spell. string scroll_name = SpellJournal::read(); // Read the spell journal to get its content. int LCS_2D_arr[spell_name.length()+1][scroll_name.length()+1]; // Create a 2D array to hold LCS values for comparison.
have no idea what outcome does the question want.