Question: can someone write this code in c++ that works on xcode?? Create a class named Dragon. It contains: One private instance variable: name of the
can someone write this code in c++ that works on xcode??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 FireDragon 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
Get step-by-step solutions from verified subject matter experts
