Encountering Fairies ( c++ with separate header and cpp files for each fairy Functionality You will define a small hierarchy of fairy classes. In main(), you will then instantiate (i.e., create) several fairy objects (from the derived classes ONLY), but no more than 5. When the user encounters a fairy, the fairy will state his/her name and ask what the user wants. In response, the user may: Ask for a wish, Offer to help the fairy, or Say goodbye to the fairy. The user will continue to interact with the fairy until the user chooses the final option, saying goodbye to the fairy. Once the user says goodbye, the game moves on to the next fairy. After the user has encountered all of the fairies, the game is over and the user's points total is displayed. Specifications All interaction will occur through standard input and standard output. Fairy (base class; NEVER instantiated): Must state his/her name and a greeting Must ask what the user wants Must respond to requests for wishes Must respond to offers to help Good Fairy (derived class): Will always grant a wish For each wish granted, the user gets 10 points Will accept an offer for help once, but then decline additional offers The user earns 50 points for the offer to help Can grant up to 5 wishes Evil Fairy (derived class): Will always deny the user's wish; i.e., cannot grant any wishes For each wish denied, the user loses 10 points Will always reject an offer of help For each offer rejected, the user loses 50 points Equivocal Fairy (derived class): Will grant the user's wish sometimes (based on a random number generator) For each wish granted, the user gets 10 points For each wish denied, the user loses 10 points Will respond to an offer of help with the statement, "I'll think about it" Can grant up to 3 wishes No fairy may disclose what type it is, nor may the user ask. The user must figure out the type of fairy encountered by assessing the responses. Inherit the members and methods that you can, redefining only when necessary. Interaction Here is a sample interaction: Hello, my name is Pixie! What is your choice? Enter a number as follows: 1) Ask for a wish    2) Offer to help me    3) say goodbye ? 2 You have offered to help me. How wonderful! You earn 50 points. What is your choice? Enter a number as follows: 1) Ask for a wish    2) Offer to help me    3) say goodbye ? 3 Goodbye to you, too! Hello, my name is Esmeralda! What is your choice? Enter a number as follows: ...

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 Encountering Fairies ( c++ with separate header and cpp files for each fairy

  • Functionality

    You will define a small hierarchy of fairy classes. In main(), you will then instantiate (i.e., create) several fairy objects (from the derived classes ONLY), but no more than 5. When the user encounters a fairy, the fairy will state his/her name and ask what the user wants. In response, the user may:

    • Ask for a wish,
    • Offer to help the fairy, or
    • Say goodbye to the fairy.

    The user will continue to interact with the fairy until the user chooses the final option, saying goodbye to the fairy. Once the user says goodbye, the game moves on to the next fairy. After the user has encountered all of the fairies, the game is over and the user's points total is displayed.

  • Specifications

    • All interaction will occur through standard input and standard output.
    • Fairy (base class; NEVER instantiated):
      • Must state his/her name and a greeting
      • Must ask what the user wants
      • Must respond to requests for wishes
      • Must respond to offers to help
    • Good Fairy (derived class):
      • Will always grant a wish
      • For each wish granted, the user gets 10 points
      • Will accept an offer for help once, but then decline additional offers
      • The user earns 50 points for the offer to help
      • Can grant up to 5 wishes
    • Evil Fairy (derived class):
      • Will always deny the user's wish; i.e., cannot grant any wishes
      • For each wish denied, the user loses 10 points
      • Will always reject an offer of help
      • For each offer rejected, the user loses 50 points
    • Equivocal Fairy (derived class):
      • Will grant the user's wish sometimes (based on a random number generator)
      • For each wish granted, the user gets 10 points
      • For each wish denied, the user loses 10 points
      • Will respond to an offer of help with the statement, "I'll think about it"
      • Can grant up to 3 wishes
    • No fairy may disclose what type it is, nor may the user ask. The user must figure out the type of fairy encountered by assessing the responses.
    • Inherit the members and methods that you can, redefining only when necessary.
  • Interaction

    Here is a sample interaction:

    Hello, my name is Pixie! What is your choice? Enter a number as follows: 1) Ask for a wish    2) Offer to help me    3) say goodbye ? 2 You have offered to help me. How wonderful! You earn 50 points. What is your choice? Enter a number as follows: 1) Ask for a wish    2) Offer to help me    3) say goodbye ? 3 Goodbye to you, too! Hello, my name is Esmeralda! What is your choice? Enter a number as follows: ...
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education