Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- namespace Oktatas
- {
- // https://github.com/laszlonemeth/magyarispell/tree/master/szotar
- public class Akasztofa_Template
- {
- static string[] dictFiles = new string[]
- {
- "resources/alap/fonev.1"
- };
- static Regex rx = new Regex(@"^(\w*)",
- RegexOptions.Compiled | RegexOptions.IgnoreCase);
- List<string> words = new List<string>();
- List<char> guesses = new List<char>();
- Random rnd = new Random();
- public void run()
- {
- readDict();
- string word = pickWord();
- // ...
- bool allFound = displayMaskedWord(word);
- // ...
- char c = askForChar();
- // ...
- guesses.Add(c);
- }
- private void readDict()
- {
- foreach (string dicFile in dictFiles)
- {
- System.IO.StreamReader file = new System.IO.StreamReader(dicFile);
- string line;
- while ((line = file.ReadLine()) != null)
- {
- MatchCollection matches = rx.Matches(line);
- Match match = rx.Match(line);
- if (match.Success)
- {
- // System.Console.Write(line + " -> '");
- // System.Console.WriteLine(match.Value + "'");
- if (match.Value.Length > 0)
- {
- words.Add(match.Value);
- }
- }
- }
- file.Close();
- }
- }
- private string pickWord()
- {
- return "alma";
- }
- private bool displayMaskedWord(string word)
- {
- Console.Write(" ");
- bool allFound = true;
- for(int i=0; i<4/* ... */; i++)
- {
- Console.Write(".");
- }
- Console.WriteLine();
- return allFound;
- }
- private char askForChar()
- {
- while (true)
- {
- Console.Write(" ? ");
- string line = Console.ReadLine();
- if (line.Length > 0)
- {
- return line[0];
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement