I think I have this part figured out now. i thought this would be the easy part! Here's what i got:
Step 2 in my asignment is to modify this to use a class called "scramble" that looks like this:Code:#include <cstring> #include <cstdlib> #include <iomanip> #include <fstream> #include <iostream> #include <string> using namespace std; bool check(string, string); int main() { bool match; string scrambled; string PossibleWord[12]={"will", "check", "it", "against", "list", "and", "return", "hello", "True", "or", "False", "Swap"}; cout << "Please enter scrambled word: "; cin >> scrambled; for (int i=0;i<13;i++) { if (scrambled.size()==PossibleWord[i].size()) { match=(check(PossibleWord[i], scrambled)); } if (match) { cout<< "Match!\nThe word is " << PossibleWord[i] << ".\n"; break; } } system ("pause"); } bool check(string p, string s) { bool match; int count=0; int ssize= s.size(); char temp[ssize]; temp[ssize]='\0'; for (int r=0;r<ssize;r++) { temp[r]=s[r]; } for (int i=0; i<ssize; i++) { for (int d=0; d< ssize; d++) { if (temp[i]==p[d]) { temp[i]='\0'; count++; } } } if (count==ssize) { match = true; return match; } else match=false; return match; }
I am also supposed to make a "driver"? Does that just refer to the main()?Code:class Scramble { private: string PossibleWord[]; int size; bool Check (string T,string S){} // Is this the word? public: Scramble (string List[], int Size); // constructor string Descramble(string Scrambled); // the game player };




Reply With Quote