Skip to content
This repository has been archived by the owner on Jul 4, 2021. It is now read-only.

Commit

Permalink
fixed #3
Browse files Browse the repository at this point in the history
  • Loading branch information
mobergmann committed Aug 1, 2020
1 parent 2e2d2a6 commit 30ba706
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions synonym-finder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ static void Main(string[] args)
// get all search results
// HtmlNodeCollection collection_list = doc.DocumentNode.SelectNodes("//section[@class='vignette']/h2/a/strong");

HtmlNodeCollection tmp_collection_1 = doc.DocumentNode.SelectNodes("//section[@class='vignette']/h2/a");
HtmlNodeCollection tmp_collection = doc.DocumentNode.SelectNodes("//section[@class='vignette']/h2/a");

// if no results were found ask for new word
if (tmp_collection_1 == null)
if (tmp_collection == null)
{
// inform user
Console.ForegroundColor = ConsoleColor.Red;
Expand All @@ -125,7 +125,7 @@ static void Main(string[] args)
}

// extract search results
foreach (HtmlNode node in tmp_collection_1)
foreach (HtmlNode node in tmp_collection)
{
SearchResult result = new SearchResult
{
Expand All @@ -146,12 +146,12 @@ static void Main(string[] args)
// print the search results with an integer for selection
for (int i = 0; i < searchResults.Count; i++)
{
Console.WriteLine($"{ i }: { ReduceString(searchResults[i].word) }");
Console.WriteLine($"{i}: {searchResults[i].word}");
}

// choose no word
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine($"{tmp_collection_1.Count}: Keine Eingabe");
Console.WriteLine($"{tmp_collection.Count}: Keine Eingabe");
Console.ResetColor();

#endregion
Expand All @@ -166,7 +166,6 @@ static void Main(string[] args)
REPEAT:
{
userChoiceNotParsed = Console.ReadLine();
Console.WriteLine();

// check if input is a number
if (!Int32.TryParse(userChoiceNotParsed, out int number))
Expand All @@ -181,7 +180,7 @@ static void Main(string[] args)
userChoice = Int32.Parse(userChoiceNotParsed);

// check if Choice is in bounds of available options
if (userChoice > tmp_collection_1.Count || userChoice < 0)
if (userChoice > tmp_collection.Count || userChoice < 0)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("Bitte geben sie eine Zahl an, welche auch repräsentiert ist.");
Expand All @@ -191,7 +190,7 @@ static void Main(string[] args)
}
}

if (userChoice == tmp_collection_1.Count)
if (userChoice == tmp_collection.Count)
{
// print an empty Line
Console.WriteLine();
Expand All @@ -200,7 +199,7 @@ static void Main(string[] args)
else
{
// get the html document of the given text
doc = GetDoc(url_get + ReduceString(tmp_collection_1[userChoice].InnerText));
doc = GetDoc(searchResults[userChoice].link);
}

#endregion
Expand Down Expand Up @@ -239,7 +238,7 @@ static void Main(string[] args)
Console.WriteLine();
continue;
}
while (true); // if something else than y
while (true);
}

/// <summary>
Expand Down

0 comments on commit 30ba706

Please sign in to comment.