Difference between revisions of "Deduct points from score if invalid word entered"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
 
Line 21: Line 21:
 
                         Console.WriteLine("Not a valid attempt, you lose your turn.");
 
                         Console.WriteLine("Not a valid attempt, you lose your turn.");
 
                         PlayerScore = PlayerScore - 10;
 
                         PlayerScore = PlayerScore - 10;
 +
                        Console.WriteLine();
 +
                    }
 +
// something here...
 +
</syntaxhighlight>
 +
 +
Another thing you could do is deduct a number of points equal to what the word's score would have been if it was valid, so longer invalid words cost you more points than shorter invalid words.
 +
 +
<syntaxhighlight lang=Csharp>
 +
// something here ...
 +
if (!ValidWord)
 +
                    {
 +
                        Console.WriteLine();
 +
                        Console.WriteLine("Not a valid attempt, you lose your turn.");
 +
                        PlayerScore = PlayerScore - GetScoreForWord(Choice, TileDictionary);
 
                         Console.WriteLine();
 
                         Console.WriteLine();
 
                     }
 
                     }
 
// something here...
 
// something here...
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 10:37, 20 November 2017

Under HaveTurn, you'll see this bit of code:

// something here ...
if (!ValidWord)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Not a valid attempt, you lose your turn.");
                        Console.WriteLine();
                    }
// something here...

You can deduct a number of points from the player's score by adding one line:

// something here ...
if (!ValidWord)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Not a valid attempt, you lose your turn.");
                        PlayerScore = PlayerScore - 10;
                        Console.WriteLine();
                    }
// something here...

Another thing you could do is deduct a number of points equal to what the word's score would have been if it was valid, so longer invalid words cost you more points than shorter invalid words.

// something here ...
if (!ValidWord)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Not a valid attempt, you lose your turn.");
                        PlayerScore = PlayerScore - GetScoreForWord(Choice, TileDictionary);
                        Console.WriteLine();
                    }
// something here...