Skip to content

Commit 3e6f0e0

Browse files
committed
Improving solution and project for FileDisplayer project.
1 parent d4c7b02 commit 3e6f0e0

6 files changed

Lines changed: 58 additions & 25 deletions

File tree

source/code/projects/FileDisplayer/FileDisplayer/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ demo file.
6161
2,Phillip,Summers,76,82,91
6262
3,Kristine,Travis,78,82,83
6363
4,Marty,Gave,67,73,72
64-
5,Harley,Test,78,91,72
65-
"
64+
5,Harley,Test,78,91,72"
6665
);
6766
sr.Close();
6867
}

source/code/projects/FileDisplayerSolution/FileDisplayerSolution/FileDisplayer.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
using System;
22
using System.IO;
33

4-
/*
5-
* Foreword: note that the project
6-
* asks the method to display an error
7-
* message if something goes wrong. A more
8-
* principled approach would require the
9-
* method to send an exception back to
10-
* the main routine, and to let it handle
11-
* the error as it sees fit.
12-
*/
13-
144
static class FileDisplayer
155
{
166
public static void Display(string exP)
@@ -209,7 +199,7 @@ public static void DisplayWinnerCSV(string exP)
209199
{
210200
StreamReader sw = new StreamReader(exP);
211201
sw.ReadLine(); // Skipping the first line
212-
202+
213203
string cLine = sw.ReadLine();
214204
string[] cLineSplit = cLine.Split(',');
215205
string winnerSoFar =

source/code/projects/FileDisplayerSolution/FileDisplayerSolution/Program.cs

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,69 @@ static void Main()
99
* We first create three
1010
* string variables where
1111
* our three demo files
12-
* are located.
12+
* are located, and created.
1313
*/
1414
string directoryPath = AppDomain
1515
.CurrentDomain
1616
.BaseDirectory;
1717
string ex0 = Path.Combine(directoryPath, "ex0.txt");
18+
try
19+
{
20+
StreamWriter sr = new StreamWriter(ex0);
21+
sr.WriteLine(
22+
@"This is the first demo file. It contains a long first line that will not wrap nicely on some display.
23+
It also contains another line that contains the word line also.
24+
It will be used to test our methods.
25+
"
26+
);
27+
sr.Close();
28+
}
29+
catch (Exception ex)
30+
{
31+
Console.WriteLine(
32+
"Something went wrong setting up the project.\nPlease, contact your instructor, sharing the following message:\n"
33+
+ ex.Message
34+
);
35+
}
1836
string ex1 = Path.Combine(directoryPath, "ex1.txt");
37+
try
38+
{
39+
StreamWriter sr = new StreamWriter(ex1);
40+
sr.WriteLine(
41+
@"A very short
42+
demo file.
43+
"
44+
);
45+
sr.Close();
46+
}
47+
catch (Exception ex)
48+
{
49+
Console.WriteLine(
50+
"Something went wrong setting up the project.\nPlease, contact your instructor, sharing the following message:\n"
51+
+ ex.Message
52+
);
53+
}
1954
string ex2 = Path.Combine(directoryPath, "ex2.csv");
55+
try
56+
{
57+
StreamWriter sr = new StreamWriter(ex2);
58+
sr.WriteLine(
59+
@"Index,First Name,Last Name,Lap 1, Lap 2, Lap 3
60+
1,Shelby,Terrell,78,80,82
61+
2,Phillip,Summers,76,82,91
62+
3,Kristine,Travis,78,82,83
63+
4,Marty,Gave,67,73,72
64+
5,Harley,Test,78,91,72"
65+
);
66+
sr.Close();
67+
}
68+
catch (Exception ex)
69+
{
70+
Console.WriteLine(
71+
"Something went wrong setting up the project.\nPlease, contact your instructor, sharing the following message:\n"
72+
+ ex.Message
73+
);
74+
}
2075

2176
// Testing the "Display" Method:
2277
Console.WriteLine("*****\n* Testing Display\n*****");

source/code/projects/FileDisplayerSolution/FileDisplayerSolution/bin/Debug/ex0.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

source/code/projects/FileDisplayerSolution/FileDisplayerSolution/bin/Debug/ex1.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

source/code/projects/FileDisplayerSolution/FileDisplayerSolution/bin/Debug/ex2.csv

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)