From debd40d5465f4e4b9753b120fb03de19960794b1 Mon Sep 17 00:00:00 2001 From: unlockable Date: Sat, 24 Jun 2023 12:47:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0close=20file=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 大作业/StudentInfoManager.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/大作业/StudentInfoManager.cpp b/大作业/StudentInfoManager.cpp index 51a85ec..dc5ac28 100644 --- a/大作业/StudentInfoManager.cpp +++ b/大作业/StudentInfoManager.cpp @@ -92,7 +92,8 @@ bool StudentInfoManager::promptForFileName() { if (tempFile.exists() && tempFile.is_regular_file()) { int backSpaceCount = 0; bool overWrite = false; - std::cout << "The file already exists. Replace? (y / n): " + std::cout << "The file " << tempFile.path() + << " already exists. Replace? (y / n): " << std::flush; std::cout << "no" << std::flush; @@ -755,6 +756,8 @@ void StudentInfoManager::displayHelp() { std::cout << "Next Page (j)\n"; std::cout << "Previous Page (k)\n"; std::cout << "Show (h)elp\n"; + std::cout << "(W)rite to disk\n"; + std::cout << "(C)lose file\n"; std::cout << "(Q)uit" << resetOutputColor << std::endl; waitForAnyInput(); } @@ -851,6 +854,11 @@ void StudentInfoManager::mainloop() { backSpaceCount = 13; cmd = infoManagerCommand::home::saveFile; } + else if (commandLetter == 'c') { + std::cout << "Close file" << std::flush; + backSpaceCount = 10; + cmd = infoManagerCommand::home::closeFile; + } else if (commandLetter == 'q') { std::cout << "Quit" << std::flush; backSpaceCount = 4;