File tree Expand file tree Collapse file tree
code/projects/UserFoundSecretWord/UserFoundSecretWord Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System ;
2+
3+ class Program
4+ {
5+ static void Main ( )
6+ {
7+ string stringtest ;
8+ bool booltest = Demo . UserFoundSecretWord ( out stringtest ) ;
9+ Console . WriteLine ( "The method returned " + booltest + " after you entered \" " + stringtest + "\" ." ) ;
10+ }
11+ }
12+
13+ public static class Demo {
14+ // Beginning of solution.
15+ public static bool UserFoundSecretWord ( out string uInput ) {
16+ Console . WriteLine ( "Enter a string" ) ;
17+ uInput = Console . ReadLine ( ) ;
18+ if ( uInput == null ) throw new ArgumentNullException ( ) ;
19+ return uInput . Contains ( "scytale" ) ;
20+ }
21+ // End of solution.
22+ }
Original file line number Diff line number Diff line change @@ -120,6 +120,25 @@ tags:
120120
121121## Problems
122122
123+ #. Knowing that our secret word is "[ scytale] ( https://en.wikipedia.org/wiki/Scytale ) ", write a ` UserFoundSecretWord ` method that
124+
125+ - asks the user for a `string`,
126+ - throws an `ArgumentNullException` exception if the string entered is `null`,
127+ - returns `true` if the string entered contains `"scytale"`, `false` otherwise,
128+ - stores the string entered in the `uInput` reference variable.
129+
130+ with the following header, where you need to fill in `_________`:
131+
132+ ```
133+ public static bool UserFoundSecretWord(_________ string uInput){
134+ ```
135+
136+ <details><summary>Solution</summary>
137+ ```{download="./code/projects/UserFoundSecretWord.zip"}
138+ !include`snippetStart="// Beginning of solution.",snippetEnd="// End of solution."` code/projects/UserFoundSecretWord/UserFoundSecretWord/Program.cs
139+ ```
140+ </details>
141+
123142#. Write the ` AddLog ` method (header included) such that the following:
124143
125144 ```{download="./code/projects/ReferenceMethods.zip"}
You can’t perform that action at this time.
0 commit comments