static void Main(string[] args) { Common_Code.ShowHeader(); WeekSelect(); // Calls CenterWrite method and sends it the given string to display centered in console Common_Code.CenterWrite("Press Enter to open the log folder and exit the program..."); Console.ReadLine(); Common_Code.OpenLogFolder(); }
private static string TFileSelect() { var textDir = Common_Code.textDir; // Creates array of file names in textDir string[] textFiles = Directory.GetFiles(textDir); // Removes path from each string in textFiles array, based on textDir string length for (int i = 0; i < textFiles.Length; i++) { textFiles[i] = textFiles[i].Remove(0, textDir.Length); } // Displays filename for each file in textFiles array, numbered 1, 2, 3, etc, by count var count = 0; foreach (string file in textFiles) { count += 1; Console.WriteLine("{0}: {1}", count, file); } // Tests input for valid integer input, based on number of files in the textFiles array (i.e. the number of files in the textDir folder) // Then subtracts 1 from fileInput so the user's input matches array index var fileInput = 0; do { var request = string.Format("Enter text file to use (1 to {0})", textFiles.Length); Common_Code.CenterWrite(request); var input = Console.ReadLine(); int.TryParse(input, out fileInput); } while ((fileInput <= 0) && (fileInput > textFiles.Length)); fileInput -= 1; return(textFiles[fileInput]); }
/// <summary> /// Prompts the user to select which section (week) to run /// </summary> /// <remarks>Week input do-while loop had a bug almost the whole semester where it wasn't actually doing anything because I used && (AND) instead of || (OR). Whoops.</remarks> private static void WeekSelect() { // Tests input for valid integers (1 through 16), asks again if input is invalid var weekInput = 0; do { Common_Code.CenterWrite("Enter class week (1 to 16)"); var input = Console.ReadLine(); int.TryParse(input, out weekInput); } while ((weekInput <= 0) || (weekInput > 16)); var labWeek = string.Format("Week {0} was a lab week. Please choose a different week.", weekInput); var futureWeek = string.Format("We aren't at week {0} yet. Please choose a different week.", weekInput); // Sends user to Week_#_Class.Method based on input, restarts WeekSelect method if incorrect input // Defaults to restarting WeekSelect method switch (weekInput) { case 1: Week_1_Class.TextToASCIIdec(); break; case 2: Week_2_Class.PoemReadWrite(); break; case 3: // Sends user to choose which search method to use // Figure we might implement more searches later on down the line // Can just point back to this case for those weeks Common_Code.ChooseSearch(); break; case 4: Console.WriteLine(labWeek); WeekSelect(); break; case 5: Week_5_Class.FindUppercaseT(); break; case 6: Week_6_Class.VirtualStacks(); break; case 7: goto case 4; case 8: Week_8_Class.VirtualQueue(); break; case 9: goto case 4; case 10: // Create new instance of Week_10_Class and start the BubbleSortAndLog method from that class var week_10 = new Week_10_Class(); week_10.BubbleSortAndLog(); break; case 11: Week_11_Class.FrequencySortAndLog(); break; case 12: goto case 16; case 13: goto case 16; case 14: goto case 16; case 15: goto case 16; case 16: Week_12_Class.SortComparisons(); break; default: Console.WriteLine("Entered {0} week, ended in default case - please select a valid week", weekInput); WeekSelect(); break; } }