TEXT FILE IS ALREADY GIVEN, JUST NEED TO READ IN THE PROGRAM. Learning objective
ID: 3836789 • Letter: T
Question
TEXT FILE IS ALREADY GIVEN, JUST NEED TO READ IN THE PROGRAM.
Learning objectives: The intent of this programing project is to allow you the opportunity to demonstrate your ability to solve problems using procedural C++ programming. This project HANG MAN will focus on file I/O and string manipulation in the implementation of the game Hangman. Program Description: In this project, you will write a C++ program that simulates playing the game Hangman. This version of the game will be limited to words with up to eight letters. The program should operate as follows: 1. The program must use a function that displays the hangman's gallows (see below). This function accepts an integer for the total number of incorrect guesses. This number will range from zero, representing the start of the game, to eight representing the end of the game. L L L L L L L L L Game Two Three Four Five Six Seven Game Start Incorrect Incorrect Incorrect Incorrect Incorrect Incorrect Incorrect Over Guess Guesses Guesses Guesses Guesses Guesses Guesses 2. Each time a game is played, the program will randomly select an unknown word from a file called words txt. Each of the thirty words in the file will be... Limited to a maximum of eight letters in length. No letter will ever appear more than once in any word. All words will be in lower case. 3. The program should then display the hangman's gallows, and a string of asterisk representing the unknown word, and a prompt for the letter to be guest.Explanation / Answer
import java.util.Scanner;
/* category AVLNode */
category AVLNode
builder */
public AVLNode()
/* creator */
public AVLNode(int n)
}
/* category AVLTree */
category AVLTree
personal AVLNode root;
/* creator */
public AVLTree()
/* perform to envision if tree is empty */
public Boolean isEmpty()
come back root == null;
}
/* build the tree logically empty */
public void makeEmpty()
/* perform to insert information */
public void insert(int data)
/* perform to induce height of node */
non-public int height(AVLNode t )
come back t == null ? -1 : t.height;
}
/* perform to GHB of left/right node */
non-public int max(int lhs, int rhs)
come back lhs > rhs ? lhs : rhs;
}
/* perform to insert information recursively */
non-public AVLNode insert(int x, AVLNode t)
a pair of )
if( x < t.left.data )
t = rotateWithLeftChild( t );
else
t = doubleWithLeftChild( t );
}
else if( x > t.data )
two )
if( x > t.right.data)
t = rotateWithRightChild( t );
else
t = doubleWithRightChild( t );
}
else
; // Duplicate; do nothing
t.height = max( height( t.left ), height( t.right ) ) + 1;
return t;
}
/* Rotate binary tree node with left kid */
non-public AVLNode rotateWithLeftChild(AVLNode k2)
Dapsang.left;
k2.left = k1.right;
k1.right = k2;
k2.height = max( height( Mount Godwin Austen.left ), height( k2.right ) ) + 1;
k1.height = max( height( k1.left ), k2.height ) + 1;
return k1;
}
/* Rotate binary tree node with right kid */
non-public AVLNode rotateWithRightChild(AVLNode k1)
{
AVLNode Mount Godwin Austen = k1.right;
k1.right = k2.left;
k2.left = k1;
k1.height = max( height( k1.left ), height( k1.right ) ) + 1;
k2.height = max( height( Mount Godwin Austen.right ), k1.height ) + 1;
return k2;
}
/**
* Double rotate binary tree node: 1st left kid
* with its right kid; then node k3 with new left child */
non-public AVLNode doubleWithLeftChild(AVLNode k3)
come back rotateWithLeftChild( k3 );
}
/**
* Double rotate binary tree node: 1st right kid
* with its left kid; then node k1 with new right child */
non-public AVLNode doubleWithRightChild(AVLNode k1)
come rotateWithRightChild( k1 );
}
/* Functions to count range of nodes */
public int countNodes()
come back countNodes(root);
}
non-public int countNodes(AVLNode r)
}
/* Functions to look for a part */
public Boolean search(int val)
come back search(root, val);
}
non-public Boolean search(AVLNode r, int val)
{
Boolean found = false;
whereas ((r != null) && !found)
found = search(r, val);
}
come found;
}
/* perform for inorder traversal */
public void inorder()
non-public void inorder(AVLNode r)
non-public void preorder(AVLNode r)
non-public void postorder(AVLNode r)
making object of AVLTree */
AVLTree avlt = new AVLTree();
System.out.println("AVLTree Tree Test ");
char ch;
/* Perform tree operations */
do
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.