The class will be called "Item" and will represent an item in the game that can be carried and used by a player (such as a weapon or a tool). The Item Class The Item class will have only one property: A string description. The Item class will have exactly 3 methods: There will be a default constructor that takes no parameters. This constructor will give a generic, default description of the Item. There will be a constructor that takes a string parameter, and it will initialize the Item's description based on the parameter. There will be a method called "print" that will print the Item's description to standard output.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question
100%

You will create a couple of classes that could be used to create a Text Adventure game.

The class will be called "Item" and will represent an item in the game that can be carried and used by a player (such as a weapon or a tool).

The Item Class

The Item class will have only one property:

  1. A string description.

The Item class will have exactly 3 methods:

  1. There will be a default constructor that takes no parameters. This constructor will give a generic, default description of the Item.
  2. There will be a constructor that takes a string parameter, and it will initialize the Item's description based on the parameter.
  3. There will be a method called "print" that will print the Item's description to standard output.

PLEASE MAKE SURE ITS POSSIBLE TO COMPILE WITH THIS CODE. THANKS.

#include "Item.h"

#include <iostream>

#include <string> using namespace std;

int main()

{

Item sword("Sword of Destiny");

Item potion("Healing Potion");

Item key("Key of Wisdom");

string name;

cout << "Enter your name: ";

getline(cin, name);

Player user(name);

user.print();

cout << "USER PICKS UP SWORD:" << endl;

user.pickUpItem(sword);

user.print();

cout << "USER MOVES NORTH:" << endl;

user.move(NORTH);

user.print();

cout << "USER PICKS UP POTION:" << endl;

user.pickUpItem(potion);

user.print();

cout << "USER PUTS DOWN ITEM:" << endl;

user.putDownItem();

user.print();

cout << "USER MOVES WEST:" << endl;

user.move(WEST);

user.print();

cout << "USER PICKS UP KEY:" << endl;

user.pickUpItem(key);

user.print();

}

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT