Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Is for C++ thank you. Description The purpose of this challenge is to write an all-encompassing program which will include various flow control structures, loops,

Is for C++ thank you.

Description

The purpose of this challenge is to write an all-encompassing program which will include various flow control structures, loops, file access, functions and object-oriented concepts.

Requirements

Acquire the file called enable1.txt. This file contains all the words that are considered valid in Words With Friends.

Milestone 1

Create a class called Words.

In Words,

Create two private int variables minlen, maxlen. Create an overloaded constructor to set these variables.

Create a private int variable called count

Create a private pointer to a string: string * choices

Create a function int count_candidates(). This function will open the file enable1.txt and count all the words in the file whose lengths are between minlen and maxlen. This function will return the resulting count.

Create a function void load_words().

In this function, create a dynamic string array of size count. Have choices point to this newly created array.

This function will open the file enable1.txt again. Similar to count_candidates(), this function will go through the entire file identifying all the words whose lengths are between minlenand maxlen. Add the qualifying words into the choices array as they are identified.

Create a function string pick_word(). This function will return a single random string out of the choicesarray.

In the constructor, call count_candidates() and load_words().

You might want to consider disposing of choices in a destructor.

For this milestone, use main to instantiate an instance of Words. Ask the user for two integer values as minand max. Pass these two values into your Words instances constructor. Also, test to see if you can display a single word by calling pick_word().

Sample main() for Milestone 1

int main() { int min, max; cout << "Enter min: "; cin >> min; cout << "Enter max; "; cin >> max; Words words(min, max); cout << words.pick_word() << endl; } 

Sample Interaction for Milestone 1

[Run your program] Enter min: 27 Enter max: 29 electroencephalographically 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago