Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone write this in C++ that works on xcode!! Create a class named Dragon. It contains: One private instance variable: name (of the type

can someone write this in C++ that works on xcode!!
image text in transcribed
Create a class named Dragon. It contains: One private instance variable: name (of the type string) Two constructors - a default constructor with no arguments, and a constructor which takes a string argument for the name One public pure virtual function attack() that returns a string value that is a description of the common behavior for all dragons of the class. The Dragon class will return a string "I don't attack anyone!" . Two public methods: getName string name) and setName Create the two classes Water Dragon and Fire Dragon that both publicly inherit from Dragon A class called Water Dragon contains one private instance variable for water capacity with an appropriate data type, one overloaded constructor that sets a value for the water capacity. The Water Dragon attack function returns "Attack with water!" A class called Fire Dragon contains one private instance variable for heat degree with an appropriate data type, one overloaded constructor that sets a value for the heat degree. The Fire Dragon attack function returns "Attack with fire!" All member variables for each class must have getter and setter functions. Both classes should have the values for member variable(s) passed in and set in the constructor. Both classes must override the attack() function of the base class. Use appropriate access modifiers in each class to enforce information hiding (public/private). Finally, test all classes by creating objects and all functions in the main function

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

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions