Now the VocEnhancer application Solution Explorer will look such as follows.
- using System;
- using System.IO;
-
- namespace VohEnhancer
- {
- public class hint_Words_utility
- {
- public static int ReadWordsFromHintFile(string[] Hintwords)
- {
-
- string guessfilename = "C:\\Users\\vithal\\Desktop\\guess.txt";
-
- if (File.Exists(guessfilename) == false)
-
- return -1;
-
- StreamReader guessRead = new StreamReader(guessfilename);
-
- int cguessount = 0;
-
- for (int i = 0; i < 50; i++)
- {
-
- if (guessRead.EndOfStream == true)
-
- break;
- Hintwords[cguessount++] = guessRead.ReadLine();
-
-
- }
-
- guessRead.Close();
-
- return cguessount;
-
- }
-
-
- public static string GetHints()
- {
-
- string[] Hintwords = new string[50];
- int count = ReadWordsFromHintFile(Hintwords);
- Random r = new Random();
- int guessX = (int)(r.Next(count));
- String secretWord = Hintwords[guessX];
-
- return secretWord;
- }
- }
- }
Now open the "CountUtility.cs"
file where we have created some entities, in other words varibales, to do a count then write the following code in it.
Now in the preceding class file we have written all the logic required to create the VocEnhancer application.
- I have used the same function for all three modes, please use the same logic as level one but provide a different word file path for each function, I hope you will do that since you are smart enough for that.
We are now done with the code, now run the console application in any of the following ways:
- Press F5
- Directly clicking on the .exe file from the bin folder of the VocEnhancer application.
- Using any option you wish to and that you know
After running the VocEnhancer application the following Level selection console screen will be as:
Now select any mode from the above, I will select Level1 Mode, so I need to press 1 from my keyboard. The following console screen will be displayed with options and words to be guessed.
Now, if you want to change the word then write "flip" and press Enter, it will show the next word as:
Now enter an incorrect guess, it will show the following message:
And the chances will be reduced by one and after four incorrect attempts:
If you attempt five incorrect guesses then the VocEnhancer application will exit from mode and show the following message.
Now type "P" and press Enter because we want to play again. It will start again from the start of the application, now after guessing the correct option, it will show the following screen:
From the preceding screen it's clear that our application is working and after each correct answer, the marks are increased by one. I hope you have done it.
Note:
- For detailed code please download the Zip file attached above.
- Don't forget to create Text Files for words.
Request and suggestion for students
- Please don't use the code as is, use the example above as a guide and try improve it so in the future and for your career it's useful for you.
- Don't buy any project from an outsider, do it as your own skill, it will definitely be useful for getting a job quickly and easily.
- Invest your time and money in technical skill improvement instead of investing money for buying projects and if possible choose Microsoft technology for your career.
- For free guidance for any college project, you can contact with me or refer to the C# Corner site but don't buy any project in your final year.
Summary
I hope this application is useful for students. If you have any suggestion related to this article or if you want any additional requirements in the above application then please contact me.