From dc5486f0521b070629449e9eb1701267340a6292 Mon Sep 17 00:00:00 2001 From: kNoAPP Date: Wed, 9 Jun 2021 11:13:43 -0700 Subject: [PATCH 1/6] Updated Chapters 2/3/4 with corrections --- Errata.md | 6 ++++++ .../Listing02.15.UsingStaticDirectives.cs | 4 ++-- .../Listing02.17.Error-StringIsImmutable.cs | 2 +- .../Listing03.09.ArrayDeclarationWithAssignment.cs | 2 +- ...ing03.10.ArrayAssignmentFollowingDeclaration.cs | 2 +- ...3.11.ArrayAssignmentWithNewDuringDeclaration.cs | 2 +- ...12.DeclarationAndAssignmentWithTheNewKeyword.cs | 2 +- .../Listing03.20.DeclaringAndAccessingAnArray.cs | 2 +- ...g03.21.SwappingDataBetweenPositionsInAnArray.cs | 2 +- src/Chapter03/Listing03.27.Slicing.cs | 13 ++++--------- .../Listing03.28.AdditionalArrayMethods.cs | 2 +- src/Chapter04/Listing04.02.Negative.cs | 2 +- src/Chapter04/Listing04.07.UnexpectedInequality.cs | 14 ++++---------- .../Listing04.18.ComparingPrefixAndPostfix.cs | 4 ++-- src/Shared/Program.cs | 2 +- 15 files changed, 28 insertions(+), 33 deletions(-) diff --git a/Errata.md b/Errata.md index be24ef426..f0c6d91ee 100644 --- a/Errata.md +++ b/Errata.md @@ -15,6 +15,12 @@ Salim Gangji | 1 | 12 | First paragraph: For a single Pieter Le Roux | 1 | 31 | Last Line: Table 1.2 shows four different C# comment types. The program in Listing 1.18 Listing 1.19 includes two of these. Benjamin Michaelis | 1 | 31 | Last Line: Table 1.2 shows four different C# comment types. The program in Listing 1.19 includes twothree of these. Salim Gangji | 2 | 51 | Output 2.3: 1.61803398874985 1.618033988749895 +Alden Bansemer | 2 | 55 | Listing 2.9: `result == number` `{result} == {number}`. Output 2.7: `result == number` `1.61803398874989 == 1.61803398874989`. +Alden Bansemer | 3 | 89 | Listing 3.4: Changed `class 3.2->3.Uppercase` to match source `class Uppercase`. +Alden Bansemer | 3 | 113 | Output 3.2: `TypeScript` replaced with `Visual Basic` as last element in sorted array and first element in the reversed, sorted array. +Alden Bansemer | 3 | 114 | Output 3.3: Added missing second line of output: `3`. +Alden Bansemer | 4 | 129 | Listing 4.7: Removed Trace.Assert to match codebase. Removed example #4, float converted to double now matches the double. +Alden Bansemer | 4 | 130 | Output 4.6: Updated results of Listing 4.7 to remove `4.20000006258488 != 4.20000028610229`. Pieter Le Roux | 5 | 215 | Output 5.4: ERROR: You must specify the URL to be downloaded and the file name **Usage:** Downloader.exe Pieter Le Roux | 6 | 285 | Last Line in second paragraph: "DO use nameof for the paramName argument passed into exceptions like ArgumentNullException and ArgumentNullException that take such a parameter. For more information, see Chapter 18." Pieter Le Roux | 7 | 359 | return @$"FirstName: { FirstName + NewLine }" + $"LastName: { LastName + NewLine }"+ $"Address: { Address + NewLine }"; diff --git a/src/Chapter02/Listing02.15.UsingStaticDirectives.cs b/src/Chapter02/Listing02.15.UsingStaticDirectives.cs index 9152a032d..64554ab32 100644 --- a/src/Chapter02/Listing02.15.UsingStaticDirectives.cs +++ b/src/Chapter02/Listing02.15.UsingStaticDirectives.cs @@ -1,9 +1,9 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_15 { using static System.Console; - class HeyYou + public class HeyYou { - static void Main() + public static void Main() { string firstName; string lastName; diff --git a/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs b/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs index e95cee19d..3202d6368 100644 --- a/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs +++ b/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs @@ -9,7 +9,7 @@ public static void Main() System.Console.Write("Enter text: "); text = System.Console.ReadLine(); - //UNEXPECTED: Does not convert text to uppercase + // UNEXPECTED: Does not convert text to uppercase text.ToUpper(); System.Console.WriteLine(text); diff --git a/src/Chapter03/Listing03.09.ArrayDeclarationWithAssignment.cs b/src/Chapter03/Listing03.09.ArrayDeclarationWithAssignment.cs index c2484938c..4ac76c1e1 100644 --- a/src/Chapter03/Listing03.09.ArrayDeclarationWithAssignment.cs +++ b/src/Chapter03/Listing03.09.ArrayDeclarationWithAssignment.cs @@ -5,7 +5,7 @@ public class Program public static void Main() { string[] languages = { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript" }; } } diff --git a/src/Chapter03/Listing03.10.ArrayAssignmentFollowingDeclaration.cs b/src/Chapter03/Listing03.10.ArrayAssignmentFollowingDeclaration.cs index 2dedf58c2..a71e9fefa 100644 --- a/src/Chapter03/Listing03.10.ArrayAssignmentFollowingDeclaration.cs +++ b/src/Chapter03/Listing03.10.ArrayAssignmentFollowingDeclaration.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages; languages = new string[] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript" }; } } diff --git a/src/Chapter03/Listing03.11.ArrayAssignmentWithNewDuringDeclaration.cs b/src/Chapter03/Listing03.11.ArrayAssignmentWithNewDuringDeclaration.cs index 6158a7f93..733929cba 100644 --- a/src/Chapter03/Listing03.11.ArrayAssignmentWithNewDuringDeclaration.cs +++ b/src/Chapter03/Listing03.11.ArrayAssignmentWithNewDuringDeclaration.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript" }; } } diff --git a/src/Chapter03/Listing03.12.DeclarationAndAssignmentWithTheNewKeyword.cs b/src/Chapter03/Listing03.12.DeclarationAndAssignmentWithTheNewKeyword.cs index 6aa3b5299..d9cad152e 100644 --- a/src/Chapter03/Listing03.12.DeclarationAndAssignmentWithTheNewKeyword.cs +++ b/src/Chapter03/Listing03.12.DeclarationAndAssignmentWithTheNewKeyword.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[9] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript" }; } } diff --git a/src/Chapter03/Listing03.20.DeclaringAndAccessingAnArray.cs b/src/Chapter03/Listing03.20.DeclaringAndAccessingAnArray.cs index 7ae326e7d..e94f61a1f 100644 --- a/src/Chapter03/Listing03.20.DeclaringAndAccessingAnArray.cs +++ b/src/Chapter03/Listing03.20.DeclaringAndAccessingAnArray.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript"}; // Retrieve fifth item in languages array (TypeScript) string language = languages[4]; diff --git a/src/Chapter03/Listing03.21.SwappingDataBetweenPositionsInAnArray.cs b/src/Chapter03/Listing03.21.SwappingDataBetweenPositionsInAnArray.cs index 89862b835..32bf9ae37 100644 --- a/src/Chapter03/Listing03.21.SwappingDataBetweenPositionsInAnArray.cs +++ b/src/Chapter03/Listing03.21.SwappingDataBetweenPositionsInAnArray.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript" }; // Save "C++" to variable called language string language = languages[3]; diff --git a/src/Chapter03/Listing03.27.Slicing.cs b/src/Chapter03/Listing03.27.Slicing.cs index 3e4cc7199..48170b6cd 100644 --- a/src/Chapter03/Listing03.27.Slicing.cs +++ b/src/Chapter03/Listing03.27.Slicing.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript"}; System.Console.WriteLine($@" 0..3: { @@ -16,7 +16,7 @@ public static void Main() string.Join(", ", languages[^3..^0]) // Python, Lisp, JavaScript }"); System.Console.WriteLine($@" 3..^3: { - string.Join(", ", languages[3..^3]) // C++, TypeScript, Pascal + string.Join(", ", languages[3..^3]) // C++, TypeScript, Visual Basic }"); System.Console.WriteLine($@" ..^6: { string.Join(", ", languages[..^6]) // C#, COBOL, Java @@ -25,16 +25,11 @@ public static void Main() string.Join(", ", languages[6..]) // Python, Lisp, JavaScript }"); System.Console.WriteLine($@" ..: { - // C#, COBOL, Java, C++, TypeScript, Pascal, Python, Lisp, JavaScript + // C#, COBOL, Java, C++, TypeScript, Visual Basic, Python, Lisp, JavaScript string.Join(", ", languages[..]) // Python, Lisp, JavaScript }"); - - - - - System.Console.WriteLine($@" ..: { - // C#, COBOL, Java, C++, TypeScript, Pascal, Python, Lisp, JavaScript + // C#, COBOL, Java, C++, TypeScript, Visual Basic, Python, Lisp, JavaScript string.Join(", ", languages[0..^0]) // Python, Lisp, JavaScript }"); } diff --git a/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs b/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs index b5378d18d..7d7d22568 100644 --- a/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs +++ b/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[]{ "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript"}; System.Array.Sort(languages); diff --git a/src/Chapter04/Listing04.02.Negative.cs b/src/Chapter04/Listing04.02.Negative.cs index bd7964141..af851f9fc 100644 --- a/src/Chapter04/Listing04.02.Negative.cs +++ b/src/Chapter04/Listing04.02.Negative.cs @@ -5,7 +5,7 @@ public class Program public static void Main() { //National Debt to the Penny - decimal debt = -18125876697430.99M; + decimal debt = -28382607800141.79M; System.Console.WriteLine(debt); } diff --git a/src/Chapter04/Listing04.07.UnexpectedInequality.cs b/src/Chapter04/Listing04.07.UnexpectedInequality.cs index 05221197d..29536f0be 100644 --- a/src/Chapter04/Listing04.07.UnexpectedInequality.cs +++ b/src/Chapter04/Listing04.07.UnexpectedInequality.cs @@ -22,25 +22,19 @@ public static void Main() System.Console.WriteLine( $"(float){(float)decimalNumber}M != {floatNumber}F"); - // Removing - float converted to double now matches the double - //Trace.Assert(doubleNumber1 != (double)floatNumber); - //// 4. Displays: 4.20000028610229 != 4.20000028610229 - //System.Console.WriteLine( - // $"{doubleNumber1} != {(double)floatNumber}"); - - // 5. Displays: 4.200000286102295 != 4.2 + // 4. Displays: 4.200000286102295 != 4.2 System.Console.WriteLine( $"{doubleNumber1} != {doubleNumber2}"); - // 6. Displays: 4.2000003F != 4.2D + // 5. Displays: 4.2000003F != 4.2D System.Console.WriteLine( $"{floatNumber}F != {doubleNumber2}D"); - // 7. Displays: 4.199999809265137 != 4.2 + // 6. Displays: 4.199999809265137 != 4.2 System.Console.WriteLine( $"{(double)4.2F} != {4.2D}"); - // 8. Displays: 4.2F != 4.2D + // 7. Displays: 4.2F != 4.2D System.Console.WriteLine( $"{4.2F}F != {4.2D}D"); } diff --git a/src/Chapter04/Listing04.18.ComparingPrefixAndPostfix.cs b/src/Chapter04/Listing04.18.ComparingPrefixAndPostfix.cs index 61b3b1b15..a916fc49c 100644 --- a/src/Chapter04/Listing04.18.ComparingPrefixAndPostfix.cs +++ b/src/Chapter04/Listing04.18.ComparingPrefixAndPostfix.cs @@ -8,9 +8,9 @@ public static void Main() // Displays 123, 124, 125 System.Console.WriteLine($"{x++}, {x++}, {x}"); // x now contains the value 125 - // Displays 126, 127, 128 + // Displays 126, 127, 127 System.Console.WriteLine($"{++x}, {++x}, {x}"); - // x now contains the value 128 + // x now contains the value 127 } } } diff --git a/src/Shared/Program.cs b/src/Shared/Program.cs index 345f95220..dfff7e5f8 100644 --- a/src/Shared/Program.cs +++ b/src/Shared/Program.cs @@ -45,7 +45,7 @@ public static void Main(string[] args) { input = ParseListingName(input); - Regex reg = new Regex($"{input}\\.+"); + Regex reg = new Regex($"Listing{input}\\.+"); IEnumerable targets = assembly.GetTypes().Where(type => { From 7735e87ab4b7605af6257805ffc73e25ac1b1102 Mon Sep 17 00:00:00 2001 From: kNoAPP Date: Wed, 9 Jun 2021 11:13:43 -0700 Subject: [PATCH 2/6] Updated Chapters 2/3/4 with corrections --- Errata.md | 6 ++++++ .../Listing02.15.UsingStaticDirectives.cs | 4 ++-- .../Listing02.17.Error-StringIsImmutable.cs | 2 +- .../Listing03.09.ArrayDeclarationWithAssignment.cs | 2 +- ...ing03.10.ArrayAssignmentFollowingDeclaration.cs | 2 +- ...3.11.ArrayAssignmentWithNewDuringDeclaration.cs | 2 +- ...12.DeclarationAndAssignmentWithTheNewKeyword.cs | 2 +- .../Listing03.20.DeclaringAndAccessingAnArray.cs | 2 +- ...g03.21.SwappingDataBetweenPositionsInAnArray.cs | 2 +- src/Chapter03/Listing03.27.Slicing.cs | 13 ++++--------- .../Listing03.28.AdditionalArrayMethods.cs | 2 +- src/Chapter04/Listing04.02.Negative.cs | 2 +- src/Chapter04/Listing04.07.UnexpectedInequality.cs | 14 ++++---------- .../Listing04.18.ComparingPrefixAndPostfix.cs | 4 ++-- src/Shared/Program.cs | 2 +- 15 files changed, 28 insertions(+), 33 deletions(-) diff --git a/Errata.md b/Errata.md index be24ef426..f0c6d91ee 100644 --- a/Errata.md +++ b/Errata.md @@ -15,6 +15,12 @@ Salim Gangji | 1 | 12 | First paragraph: For a single Pieter Le Roux | 1 | 31 | Last Line: Table 1.2 shows four different C# comment types. The program in Listing 1.18 Listing 1.19 includes two of these. Benjamin Michaelis | 1 | 31 | Last Line: Table 1.2 shows four different C# comment types. The program in Listing 1.19 includes twothree of these. Salim Gangji | 2 | 51 | Output 2.3: 1.61803398874985 1.618033988749895 +Alden Bansemer | 2 | 55 | Listing 2.9: `result == number` `{result} == {number}`. Output 2.7: `result == number` `1.61803398874989 == 1.61803398874989`. +Alden Bansemer | 3 | 89 | Listing 3.4: Changed `class 3.2->3.Uppercase` to match source `class Uppercase`. +Alden Bansemer | 3 | 113 | Output 3.2: `TypeScript` replaced with `Visual Basic` as last element in sorted array and first element in the reversed, sorted array. +Alden Bansemer | 3 | 114 | Output 3.3: Added missing second line of output: `3`. +Alden Bansemer | 4 | 129 | Listing 4.7: Removed Trace.Assert to match codebase. Removed example #4, float converted to double now matches the double. +Alden Bansemer | 4 | 130 | Output 4.6: Updated results of Listing 4.7 to remove `4.20000006258488 != 4.20000028610229`. Pieter Le Roux | 5 | 215 | Output 5.4: ERROR: You must specify the URL to be downloaded and the file name **Usage:** Downloader.exe Pieter Le Roux | 6 | 285 | Last Line in second paragraph: "DO use nameof for the paramName argument passed into exceptions like ArgumentNullException and ArgumentNullException that take such a parameter. For more information, see Chapter 18." Pieter Le Roux | 7 | 359 | return @$"FirstName: { FirstName + NewLine }" + $"LastName: { LastName + NewLine }"+ $"Address: { Address + NewLine }"; diff --git a/src/Chapter02/Listing02.15.UsingStaticDirectives.cs b/src/Chapter02/Listing02.15.UsingStaticDirectives.cs index 9152a032d..64554ab32 100644 --- a/src/Chapter02/Listing02.15.UsingStaticDirectives.cs +++ b/src/Chapter02/Listing02.15.UsingStaticDirectives.cs @@ -1,9 +1,9 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_15 { using static System.Console; - class HeyYou + public class HeyYou { - static void Main() + public static void Main() { string firstName; string lastName; diff --git a/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs b/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs index e95cee19d..3202d6368 100644 --- a/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs +++ b/src/Chapter02/Listing02.17.Error-StringIsImmutable.cs @@ -9,7 +9,7 @@ public static void Main() System.Console.Write("Enter text: "); text = System.Console.ReadLine(); - //UNEXPECTED: Does not convert text to uppercase + // UNEXPECTED: Does not convert text to uppercase text.ToUpper(); System.Console.WriteLine(text); diff --git a/src/Chapter03/Listing03.09.ArrayDeclarationWithAssignment.cs b/src/Chapter03/Listing03.09.ArrayDeclarationWithAssignment.cs index c2484938c..4ac76c1e1 100644 --- a/src/Chapter03/Listing03.09.ArrayDeclarationWithAssignment.cs +++ b/src/Chapter03/Listing03.09.ArrayDeclarationWithAssignment.cs @@ -5,7 +5,7 @@ public class Program public static void Main() { string[] languages = { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript" }; } } diff --git a/src/Chapter03/Listing03.10.ArrayAssignmentFollowingDeclaration.cs b/src/Chapter03/Listing03.10.ArrayAssignmentFollowingDeclaration.cs index 2dedf58c2..a71e9fefa 100644 --- a/src/Chapter03/Listing03.10.ArrayAssignmentFollowingDeclaration.cs +++ b/src/Chapter03/Listing03.10.ArrayAssignmentFollowingDeclaration.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages; languages = new string[] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript" }; } } diff --git a/src/Chapter03/Listing03.11.ArrayAssignmentWithNewDuringDeclaration.cs b/src/Chapter03/Listing03.11.ArrayAssignmentWithNewDuringDeclaration.cs index 6158a7f93..733929cba 100644 --- a/src/Chapter03/Listing03.11.ArrayAssignmentWithNewDuringDeclaration.cs +++ b/src/Chapter03/Listing03.11.ArrayAssignmentWithNewDuringDeclaration.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript" }; } } diff --git a/src/Chapter03/Listing03.12.DeclarationAndAssignmentWithTheNewKeyword.cs b/src/Chapter03/Listing03.12.DeclarationAndAssignmentWithTheNewKeyword.cs index 6aa3b5299..d9cad152e 100644 --- a/src/Chapter03/Listing03.12.DeclarationAndAssignmentWithTheNewKeyword.cs +++ b/src/Chapter03/Listing03.12.DeclarationAndAssignmentWithTheNewKeyword.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[9] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript" }; } } diff --git a/src/Chapter03/Listing03.20.DeclaringAndAccessingAnArray.cs b/src/Chapter03/Listing03.20.DeclaringAndAccessingAnArray.cs index 7ae326e7d..e94f61a1f 100644 --- a/src/Chapter03/Listing03.20.DeclaringAndAccessingAnArray.cs +++ b/src/Chapter03/Listing03.20.DeclaringAndAccessingAnArray.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript"}; // Retrieve fifth item in languages array (TypeScript) string language = languages[4]; diff --git a/src/Chapter03/Listing03.21.SwappingDataBetweenPositionsInAnArray.cs b/src/Chapter03/Listing03.21.SwappingDataBetweenPositionsInAnArray.cs index 89862b835..32bf9ae37 100644 --- a/src/Chapter03/Listing03.21.SwappingDataBetweenPositionsInAnArray.cs +++ b/src/Chapter03/Listing03.21.SwappingDataBetweenPositionsInAnArray.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript" }; // Save "C++" to variable called language string language = languages[3]; diff --git a/src/Chapter03/Listing03.27.Slicing.cs b/src/Chapter03/Listing03.27.Slicing.cs index 3e4cc7199..48170b6cd 100644 --- a/src/Chapter03/Listing03.27.Slicing.cs +++ b/src/Chapter03/Listing03.27.Slicing.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript"}; System.Console.WriteLine($@" 0..3: { @@ -16,7 +16,7 @@ public static void Main() string.Join(", ", languages[^3..^0]) // Python, Lisp, JavaScript }"); System.Console.WriteLine($@" 3..^3: { - string.Join(", ", languages[3..^3]) // C++, TypeScript, Pascal + string.Join(", ", languages[3..^3]) // C++, TypeScript, Visual Basic }"); System.Console.WriteLine($@" ..^6: { string.Join(", ", languages[..^6]) // C#, COBOL, Java @@ -25,16 +25,11 @@ public static void Main() string.Join(", ", languages[6..]) // Python, Lisp, JavaScript }"); System.Console.WriteLine($@" ..: { - // C#, COBOL, Java, C++, TypeScript, Pascal, Python, Lisp, JavaScript + // C#, COBOL, Java, C++, TypeScript, Visual Basic, Python, Lisp, JavaScript string.Join(", ", languages[..]) // Python, Lisp, JavaScript }"); - - - - - System.Console.WriteLine($@" ..: { - // C#, COBOL, Java, C++, TypeScript, Pascal, Python, Lisp, JavaScript + // C#, COBOL, Java, C++, TypeScript, Visual Basic, Python, Lisp, JavaScript string.Join(", ", languages[0..^0]) // Python, Lisp, JavaScript }"); } diff --git a/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs b/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs index b5378d18d..7d7d22568 100644 --- a/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs +++ b/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[]{ "C#", "COBOL", "Java", - "C++", "TypeScript", "Pascal", + "C++", "TypeScript", "Visual Basic", "Python", "Lisp", "JavaScript"}; System.Array.Sort(languages); diff --git a/src/Chapter04/Listing04.02.Negative.cs b/src/Chapter04/Listing04.02.Negative.cs index bd7964141..af851f9fc 100644 --- a/src/Chapter04/Listing04.02.Negative.cs +++ b/src/Chapter04/Listing04.02.Negative.cs @@ -5,7 +5,7 @@ public class Program public static void Main() { //National Debt to the Penny - decimal debt = -18125876697430.99M; + decimal debt = -28382607800141.79M; System.Console.WriteLine(debt); } diff --git a/src/Chapter04/Listing04.07.UnexpectedInequality.cs b/src/Chapter04/Listing04.07.UnexpectedInequality.cs index 05221197d..29536f0be 100644 --- a/src/Chapter04/Listing04.07.UnexpectedInequality.cs +++ b/src/Chapter04/Listing04.07.UnexpectedInequality.cs @@ -22,25 +22,19 @@ public static void Main() System.Console.WriteLine( $"(float){(float)decimalNumber}M != {floatNumber}F"); - // Removing - float converted to double now matches the double - //Trace.Assert(doubleNumber1 != (double)floatNumber); - //// 4. Displays: 4.20000028610229 != 4.20000028610229 - //System.Console.WriteLine( - // $"{doubleNumber1} != {(double)floatNumber}"); - - // 5. Displays: 4.200000286102295 != 4.2 + // 4. Displays: 4.200000286102295 != 4.2 System.Console.WriteLine( $"{doubleNumber1} != {doubleNumber2}"); - // 6. Displays: 4.2000003F != 4.2D + // 5. Displays: 4.2000003F != 4.2D System.Console.WriteLine( $"{floatNumber}F != {doubleNumber2}D"); - // 7. Displays: 4.199999809265137 != 4.2 + // 6. Displays: 4.199999809265137 != 4.2 System.Console.WriteLine( $"{(double)4.2F} != {4.2D}"); - // 8. Displays: 4.2F != 4.2D + // 7. Displays: 4.2F != 4.2D System.Console.WriteLine( $"{4.2F}F != {4.2D}D"); } diff --git a/src/Chapter04/Listing04.18.ComparingPrefixAndPostfix.cs b/src/Chapter04/Listing04.18.ComparingPrefixAndPostfix.cs index 61b3b1b15..a916fc49c 100644 --- a/src/Chapter04/Listing04.18.ComparingPrefixAndPostfix.cs +++ b/src/Chapter04/Listing04.18.ComparingPrefixAndPostfix.cs @@ -8,9 +8,9 @@ public static void Main() // Displays 123, 124, 125 System.Console.WriteLine($"{x++}, {x++}, {x}"); // x now contains the value 125 - // Displays 126, 127, 128 + // Displays 126, 127, 127 System.Console.WriteLine($"{++x}, {++x}, {x}"); - // x now contains the value 128 + // x now contains the value 127 } } } diff --git a/src/Shared/Program.cs b/src/Shared/Program.cs index 345f95220..dfff7e5f8 100644 --- a/src/Shared/Program.cs +++ b/src/Shared/Program.cs @@ -45,7 +45,7 @@ public static void Main(string[] args) { input = ParseListingName(input); - Regex reg = new Regex($"{input}\\.+"); + Regex reg = new Regex($"Listing{input}\\.+"); IEnumerable targets = assembly.GetTypes().Where(type => { From 11741fc89279cc8b5a926102a49ac6eeb14b9b54 Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Sun, 19 Dec 2021 17:40:44 -0800 Subject: [PATCH 3/6] Fix Test 3.27 --- src/Chapter03.Tests/Listing03.27.Slicing.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Chapter03.Tests/Listing03.27.Slicing.cs b/src/Chapter03.Tests/Listing03.27.Slicing.cs index d01bdd938..5403fa467 100644 --- a/src/Chapter03.Tests/Listing03.27.Slicing.cs +++ b/src/Chapter03.Tests/Listing03.27.Slicing.cs @@ -11,11 +11,11 @@ public void Main_GetLengthOfDimensionOf3DArray_ReturnsLength() const string expected = @" 0..3: C#, COBOL, Java ^3..^0: Python, Lisp, JavaScript - 3..^3: C++, TypeScript, Pascal + 3..^3: C++, TypeScript, Visual Basic ..^6: C#, COBOL, Java 6..: Python, Lisp, JavaScript - ..: C#, COBOL, Java, C++, TypeScript, Pascal, Python, Lisp, JavaScript - ..: C#, COBOL, Java, C++, TypeScript, Pascal, Python, Lisp, JavaScript"; + ..: C#, COBOL, Java, C++, TypeScript, Visual Basic, Python, Lisp, JavaScript + ..: C#, COBOL, Java, C++, TypeScript, Visual Basic, Python, Lisp, JavaScript"; IntelliTect.TestTools.Console.ConsoleAssert.Expect( expected, Program.Main); From d6e2f4dc17d1953dae07257c7d191d129c0b3bc4 Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Sun, 19 Dec 2021 17:42:21 -0800 Subject: [PATCH 4/6] Making changes to keep test passing but get rid of pascal as a language Will update manuscript accordingly --- src/Chapter03/Listing03.28.AdditionalArrayMethods.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs b/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs index 7d7d22568..31390a1f7 100644 --- a/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs +++ b/src/Chapter03/Listing03.28.AdditionalArrayMethods.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[]{ "C#", "COBOL", "Java", - "C++", "TypeScript", "Visual Basic", + "C++", "TypeScript", "Swift", "Python", "Lisp", "JavaScript"}; System.Array.Sort(languages); From 4255c58138ba2267584d5061efbaf32a325c7362 Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Sun, 19 Dec 2021 17:48:29 -0800 Subject: [PATCH 5/6] Updated value to match v8.0 book --- src/Chapter04.Tests/Listing04.02.Negative.Tests.cs | 2 +- src/Chapter04/Listing04.02.Negative.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Chapter04.Tests/Listing04.02.Negative.Tests.cs b/src/Chapter04.Tests/Listing04.02.Negative.Tests.cs index fa4b0de5e..c14b54aee 100644 --- a/src/Chapter04.Tests/Listing04.02.Negative.Tests.cs +++ b/src/Chapter04.Tests/Listing04.02.Negative.Tests.cs @@ -8,7 +8,7 @@ public class ProgramTests [TestMethod] public void MainTest() { - const string expected = @"-18125876697430.99"; + const string expected = @"-26457079712930.80"; IntelliTect.TestTools.Console.ConsoleAssert.Expect( expected, Program.Main); diff --git a/src/Chapter04/Listing04.02.Negative.cs b/src/Chapter04/Listing04.02.Negative.cs index af851f9fc..832c625eb 100644 --- a/src/Chapter04/Listing04.02.Negative.cs +++ b/src/Chapter04/Listing04.02.Negative.cs @@ -5,7 +5,7 @@ public class Program public static void Main() { //National Debt to the Penny - decimal debt = -28382607800141.79M; + decimal debt = -26457079712930.80M; System.Console.WriteLine(debt); } From c35e64a30ca3525051fe52f25a3e8544fe0a7a75 Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Sun, 19 Dec 2021 17:52:54 -0800 Subject: [PATCH 6/6] Update 3.27 to match 3.28 --- src/Chapter03.Tests/Listing03.27.Slicing.cs | 6 +++--- src/Chapter03/Listing03.27.Slicing.cs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Chapter03.Tests/Listing03.27.Slicing.cs b/src/Chapter03.Tests/Listing03.27.Slicing.cs index 5403fa467..00d136d98 100644 --- a/src/Chapter03.Tests/Listing03.27.Slicing.cs +++ b/src/Chapter03.Tests/Listing03.27.Slicing.cs @@ -11,11 +11,11 @@ public void Main_GetLengthOfDimensionOf3DArray_ReturnsLength() const string expected = @" 0..3: C#, COBOL, Java ^3..^0: Python, Lisp, JavaScript - 3..^3: C++, TypeScript, Visual Basic + 3..^3: C++, TypeScript, Swift ..^6: C#, COBOL, Java 6..: Python, Lisp, JavaScript - ..: C#, COBOL, Java, C++, TypeScript, Visual Basic, Python, Lisp, JavaScript - ..: C#, COBOL, Java, C++, TypeScript, Visual Basic, Python, Lisp, JavaScript"; + ..: C#, COBOL, Java, C++, TypeScript, Swift, Python, Lisp, JavaScript + ..: C#, COBOL, Java, C++, TypeScript, Swift, Python, Lisp, JavaScript"; IntelliTect.TestTools.Console.ConsoleAssert.Expect( expected, Program.Main); diff --git a/src/Chapter03/Listing03.27.Slicing.cs b/src/Chapter03/Listing03.27.Slicing.cs index 48170b6cd..4b912987b 100644 --- a/src/Chapter03/Listing03.27.Slicing.cs +++ b/src/Chapter03/Listing03.27.Slicing.cs @@ -6,7 +6,7 @@ public static void Main() { string[] languages = new string[] { "C#", "COBOL", "Java", - "C++", "TypeScript", "Visual Basic", + "C++", "TypeScript", "Swift", "Python", "Lisp", "JavaScript"}; System.Console.WriteLine($@" 0..3: { @@ -16,7 +16,7 @@ public static void Main() string.Join(", ", languages[^3..^0]) // Python, Lisp, JavaScript }"); System.Console.WriteLine($@" 3..^3: { - string.Join(", ", languages[3..^3]) // C++, TypeScript, Visual Basic + string.Join(", ", languages[3..^3]) // C++, TypeScript, Swift }"); System.Console.WriteLine($@" ..^6: { string.Join(", ", languages[..^6]) // C#, COBOL, Java @@ -25,11 +25,11 @@ public static void Main() string.Join(", ", languages[6..]) // Python, Lisp, JavaScript }"); System.Console.WriteLine($@" ..: { - // C#, COBOL, Java, C++, TypeScript, Visual Basic, Python, Lisp, JavaScript + // C#, COBOL, Java, C++, TypeScript, Swift, Python, Lisp, JavaScript string.Join(", ", languages[..]) // Python, Lisp, JavaScript }"); System.Console.WriteLine($@" ..: { - // C#, COBOL, Java, C++, TypeScript, Visual Basic, Python, Lisp, JavaScript + // C#, COBOL, Java, C++, TypeScript, Swift, Python, Lisp, JavaScript string.Join(", ", languages[0..^0]) // Python, Lisp, JavaScript }"); }