static string newData; // New data static void Main(string[] args) { // Sets up the file system FileSystem.Setup(); // Reads data from the files and stores it courses = FileSystem.ReadCurrentCourseFiles(); competedCourses = FileSystem.ReadCompletedCourseFiles(); // Sets up the screens SetUp(); // Loops until the end of the program while (endProg == false) { Console.Clear(); // Screens with set choices switch (currScreen) { // Branching screens // Branching screens that lead to other screens case Screens.MainScreen: currColor = ConsoleColor.DarkMagenta; currScreen = (Screens)MainScreen.RunScreen(); returnScreen = Screens.MainScreen; break; case Screens.Editcourses: currColor = ConsoleColor.DarkRed; currScreen = (Screens)EditCoursesScreen.RunScreen(); returnScreen = Screens.Editcourses; break; case Screens.GradeManagement: currColor = ConsoleColor.DarkGreen; GradeManagementScreen.Title = "Grade Management Screen for " + courses.GetCourse(courseIndex).Name; currScreen = (Screens)GradeManagementScreen.RunScreen(); returnScreen = Screens.GradeManagement; break; case Screens.GpaManager: currColor = ConsoleColor.DarkBlue; currScreen = (Screens)GpaManagerScreen.RunScreen(); returnScreen = Screens.GpaManager; break; } // Checks if we need to pick a course, category, or grade // current courses if (currScreen == Screens.ViewCourse || currScreen == Screens.DeleteCourse || currScreen == Screens.GradeManagement || currScreen == Screens.AddOldCompletedCourse || currScreen == Screens.InputExpectedAssignments) { nextScreen = currScreen; // Runs the screen, updates the screen before hand currColor = ConsoleColor.DarkYellow; UpdateCourseScreen(); Console.Clear(); courseIndex = (int)PickCourseScreen.RunScreen(); // Checks to see if the user picked a course or wanted to exit (return to prev screen) if (courseIndex >= 0) { currScreen = nextScreen; } else { currScreen = returnScreen; } } // category if (currScreen == Screens.AddNewGrade || currScreen == Screens.DeleteGrade || currScreen == Screens.InputExpectedAssignments) { nextScreen = currScreen; // Runs the screen, updates the screen before hand currColor = ConsoleColor.DarkYellow; UpdateCatagoryScreen(); Console.Clear(); catagoryIndex = (int)PickCatagoryScreen.RunScreen(); // Checks to see if the user picked a course or wanted to exit (return to prev screen) if (catagoryIndex >= 0) { currScreen = nextScreen; } else { currScreen = returnScreen; } } // grade if (currScreen == Screens.DeleteGrade) { nextScreen = currScreen; // Runs the screen, updates the screen before hand currColor = ConsoleColor.DarkYellow; UpdateGradeScreen(); Console.Clear(); gradeIndex = (int)PickGradeScreen.RunScreen(); // Checks to see if the user picked a course or wanted to exit (return to prev screen) if (gradeIndex >= 0) { currScreen = nextScreen; } else { currScreen = returnScreen; } } Console.Clear(); // Secondary screens (Without branches) (WILL HAVE A RETURNSCREEN) switch (currScreen) { case Screens.ExitProg: // Ends prog endProg = true; break; case Screens.AddNewCourse: // Creates new course Course newCourse = courses.AddNewCourse(false); // Updates the file system FileSystem.CreateCourseFiles(newCourse); // Tells the user the course has been created Console.WriteLine(Environment.NewLine + "Course created!"); Program.PrintPressAnyKeyToContinue(); currScreen = returnScreen; break; case Screens.ViewCourse: // Runs the viewCourseInfo just for that course courses.GetCourse(courseIndex).ViewCourseInfo(); currScreen = returnScreen; break; case Screens.ViewGradeInfo: // Runs the viewGradeInfo just for that course courses.GetCourse(courseIndex).ViewGradeInfo(); currScreen = returnScreen; break; case Screens.AddNewGrade: // Creates a new grade Grade newGrade = courses.GetCourse(courseIndex).GetCatagory(catagoryIndex).AddNewGrade(); // Updates the file system FileSystem.UpdateGradeFiles(courses.GetCourse(courseIndex), catagoryIndex, newGrade); FileSystem.UpdateGradeHist(courses.GetCourse(courseIndex).GetPercGrade(), courses.GetCourse(courseIndex)); courses.GetCourse(courseIndex).AddGradeHist(courses.GetCourse(courseIndex).GetPercGrade()); // Tells the user the grade has been created Console.SetCursorPosition(2, 12); Console.WriteLine("Grade created!"); Console.SetCursorPosition(2, Program.WindowHeight - 1); Program.PrintPressAnyKeyToContinue(); currScreen = returnScreen; break; case Screens.DeleteCourse: // Asks the user if we want to delete this course bool needDelete = courses.DeleteCourse(courseIndex); // If so, delete course if (needDelete) { FileSystem.DeleteCourseFiles(courses.GetCourse(courseIndex)); // Removes the course from the courses vector courses.RemoveCourse(courseIndex); } currScreen = returnScreen; break; case Screens.DeleteGrade: // Gets the course that we need to delete needDelete = courses.GetCourse(courseIndex).GetCatagory(catagoryIndex).DeleteGrade(gradeIndex); // Checks if the user wants to delete the grade if (needDelete) { FileSystem.DeleteGradeInfo(courses.GetCourse(courseIndex), catagoryIndex, gradeIndex); FileSystem.UpdateGradeHist(courses.GetCourse(courseIndex).GetPercGrade(), courses.GetCourse(courseIndex)); courses.GetCourse(courseIndex).AddGradeHist(courses.GetCourse(courseIndex).GetPercGrade()); // Tells the user the course has been deleted Console.SetCursorPosition(2, 5); Console.WriteLine("Grade Deleted!"); Console.SetCursorPosition(2, Program.WindowHeight - 1); Program.PrintPressAnyKeyToContinue(); } currScreen = returnScreen; break; case Screens.ViewCompletedCourses: competedCourses.ViewCompetedCourses(); currScreen = returnScreen; break; case Screens.AddNewCompletedCourse: newCourse = competedCourses.AddNewCourse(true); FileSystem.UpdateCompletedCourseFiles(newCourse); currScreen = returnScreen; break; case Screens.ProjectGPA: courses.ProjectGpa(competedCourses.GetGradePointsEarned(), competedCourses.GetGradePointsTotal()); currScreen = returnScreen; break; case Screens.WhatDoINeedOnFinal: courses.ViewFinalNeeds(); currScreen = returnScreen; break; case Screens.AddOldCompletedCourse: newCourse = courses.AddOldCompletedCourse(courseIndex); competedCourses.CreateCourse(newCourse); // Deletes the old course in files, updates the files for completed course FileSystem.DeleteCourseFiles(newCourse); FileSystem.UpdateCompletedCourseFiles(newCourse); currScreen = returnScreen; break; case Screens.InputExpectedAssignments: // Save old data oldData = Convert.ToString(courses.GetCourse(courseIndex).GetCatagory(catagoryIndex).ExpAssignments); newData = Convert.ToString(courses.GetCourse(courseIndex).GetCatagory(catagoryIndex).InputExpAssignments()); FileSystem.UpdateExpAssignmentInfo(newData, courses.GetCourse(courseIndex), catagoryIndex); currScreen = returnScreen; break; case Screens.ViewGradeHist: courses.GetCourse(courseIndex).ViewGradeHist(); currScreen = returnScreen; break; } } }
private static void UpdateCatagoryScreen() { // BUG IS HERE, NEED TO FIND A WAY TO UPDATE ALL OF CATAGORIES, NOT JUST A SPECIFIC COURSE PickCatagoryScreen.SetChoices(courses.GetCourse(courseIndex).CreateChoices()); PickCatagoryScreen.SetLogic(courses.GetCourse(courseIndex).CreateLogic()); }