Create a class Hangman with the following private attributes:
 Words: should be a static array of character pointers with 5 elements.
 Word Name: should be a pointer to a character.
 Chosen Letters: should be a pointer to a Boolean.
 Letter: should be a character attribute.
 Number of Trials: should be an integer attribute.
 Word Length: should be an integer attribute.
The class Hangman should contain the following behaviors:
 Constructor with no arguments:
o Declare and initialize a random number between 0 and 4.
o Assign Word Length to the length of a text inside Words based on the generated random number.
o Dynamically allocate Word Name and Chosen Letters based on the Word Length.
o Assign Word Name to the chosen random text from Words.
o Set the Number of Trials to 0 and initialize the array Chosen Letters to false.
 Destructor:
o Dynamically de-allocate Word Name and Chosen Letters.
o Print on the screen the value of Word Name with the sentence “has been removed”.
 Constant get function for Number of Trials.
 Check Value:
o The function should not take any parameters.
o If the value of Letter found within the array Word Name, set the same element index of Chosen Letters to true and return true; otherwise return false.
 Word Complete:
o The function should not take any parameters.
o The function must return false if one element inside Chosen Letters is equal to false; otherwise return true.
 Overloaded operators (<<, >>, ++):
o operator<< must output the correct letters on screen; otherwise print an underscore “_”.
o operator>> must input the letter chosen by the user into the attribute Letter.
o operator++ must increment the value of Number of Trials.

3 Years
Discussion Span
Last Post by Ancient Dragon

What part of that assignment do you need help with? Do you know how to create a class? Do you even know what a class is? If not then you should read your textbook about them.

class Hangman
    // put the public methods here

    // put the data items here

Edited by Ancient Dragon

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.