1
1
namespace Bookdisplayer
2
2
{
3
- public class Program
3
+ public static class Program
4
4
{
5
- public static void Main ( string [ ] args )
5
+ public static void Main ( )
6
6
{
7
7
Console . BackgroundColor = ConsoleColor . DarkMagenta ;
8
8
Console . ForegroundColor = ConsoleColor . White ;
@@ -27,14 +27,47 @@ public static void BookGrabber()
27
27
Console . WriteLine ( foldername . Replace ( BookDir + "\\ " , "" ) ) ;
28
28
}
29
29
}
30
+ // Stack Overflow - javadch
31
+ public static string Capitalize ( this string word )
32
+ {
33
+ return word . Substring ( 0 , 1 ) . ToUpper ( ) + word . Substring ( 1 ) . ToLower ( ) ;
34
+ }
35
+ // Provided by GPT
36
+ public static string CapitalizeWithSpaces ( this string sentence )
37
+ {
38
+ string [ ] words = sentence . Split ( ' ' ) ;
39
+ for ( int i = 0 ; i < words . Length ; i ++ )
40
+ {
41
+ words [ i ] = words [ i ] . Capitalize ( ) ;
42
+ }
43
+
44
+ return string . Join ( " " , words ) ;
45
+ }
30
46
public static void PageReader ( )
31
47
{
32
48
string BookDir = Path . GetFullPath ( Path . Combine ( Directory . GetCurrentDirectory ( ) , $ "Books") ) ;
33
49
Console . Write ( "What Book would you like to read from the above options?: " ) ;
34
50
string Book = Console . ReadLine ( ) ;
51
+ Book = CapitalizeWithSpaces ( Book ) ;
52
+ Console . WriteLine ( Book ) ;
35
53
if ( Directory . Exists ( Path . Combine ( BookDir , Book ) ) )
36
54
{
37
55
Console . WriteLine ( $ "Book Selected { Book } ") ;
56
+ } else
57
+ {
58
+ int A = 0 ;
59
+ int B = 0 ;
60
+ while ( A == B )
61
+ {
62
+ Console . Write ( "That was not a option, Try Again!: " ) ;
63
+ Book = Console . ReadLine ( ) ;
64
+ Book = CapitalizeWithSpaces ( Book ) ;
65
+ if ( Directory . Exists ( Path . Combine ( BookDir , Book ) ) )
66
+ {
67
+ Console . WriteLine ( $ "Book Selected { Book } ") ;
68
+ A ++ ;
69
+ }
70
+ }
38
71
}
39
72
List < string > Pages = new List < string > ( ) ;
40
73
for ( int i = 0 ; ; i ++ )
@@ -69,6 +102,7 @@ public static void PageReader()
69
102
{
70
103
if ( currentPage >= 0 && currentPage <= Pages . Count )
71
104
{
105
+ Console . Clear ( ) ;
72
106
Console . WriteLine ( "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" ) ;
73
107
Console . WriteLine ( $ "Book: { Book } \n Page: { string . Join ( ", " , Pages . ElementAt ( currentPage ) ) } ") ;
74
108
Console . WriteLine ( "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" ) ;
@@ -129,6 +163,7 @@ public static void Functions(string Option, ref int currentPage, ref bool BookFi
129
163
else if ( Option == "X" )
130
164
{
131
165
BookFinishedForNow = true ;
166
+ Main ( ) ;
132
167
}
133
168
else
134
169
{
@@ -166,6 +201,7 @@ public static void Functions(string Option, ref int currentPage, ref bool BookFi
166
201
{
167
202
BookFinishedForNow = true ;
168
203
y ++ ;
204
+ Main ( ) ;
169
205
}
170
206
}
171
207
}
0 commit comments