diff --git a/GradeManagement.xcodeproj/project.pbxproj b/GradeManagement.xcodeproj/project.pbxproj new file mode 100644 index 0000000..48a43e9 --- /dev/null +++ b/GradeManagement.xcodeproj/project.pbxproj @@ -0,0 +1,329 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 904388E8294019B30042BDBF /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 904388E7294019B30042BDBF /* main.swift */; }; + 904388EF29401B2A0042BDBF /* Modules.swift in Sources */ = {isa = PBXBuildFile; fileRef = 904388EE29401B2A0042BDBF /* Modules.swift */; }; + 904389062940748F0042BDBF /* AddStudent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 904389052940748F0042BDBF /* AddStudent.swift */; }; + 904389082940749D0042BDBF /* DeleteStudent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 904389072940749D0042BDBF /* DeleteStudent.swift */; }; + 9043890A2940752F0042BDBF /* UpdateGrade.swift in Sources */ = {isa = PBXBuildFile; fileRef = 904389092940752F0042BDBF /* UpdateGrade.swift */; }; + 9043890C2940753B0042BDBF /* RemoveGrade.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9043890B2940753B0042BDBF /* RemoveGrade.swift */; }; + 9043890E294075500042BDBF /* ReportCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9043890D294075500042BDBF /* ReportCard.swift */; }; + 90438913294075C00042BDBF /* Exit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90438912294075C00042BDBF /* Exit.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 904388E2294019B30042BDBF /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 904388E4294019B30042BDBF /* GradeManagement */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = GradeManagement; sourceTree = BUILT_PRODUCTS_DIR; }; + 904388E7294019B30042BDBF /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 904388EE29401B2A0042BDBF /* Modules.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modules.swift; sourceTree = ""; }; + 904389052940748F0042BDBF /* AddStudent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddStudent.swift; sourceTree = ""; }; + 904389072940749D0042BDBF /* DeleteStudent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteStudent.swift; sourceTree = ""; }; + 904389092940752F0042BDBF /* UpdateGrade.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateGrade.swift; sourceTree = ""; }; + 9043890B2940753B0042BDBF /* RemoveGrade.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoveGrade.swift; sourceTree = ""; }; + 9043890D294075500042BDBF /* ReportCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportCard.swift; sourceTree = ""; }; + 90438912294075C00042BDBF /* Exit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Exit.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 904388E1294019B30042BDBF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 904388DB294019B30042BDBF = { + isa = PBXGroup; + children = ( + 904388E6294019B30042BDBF /* GradeManagement */, + 904388E5294019B30042BDBF /* Products */, + ); + sourceTree = ""; + }; + 904388E5294019B30042BDBF /* Products */ = { + isa = PBXGroup; + children = ( + 904388E4294019B30042BDBF /* GradeManagement */, + ); + name = Products; + sourceTree = ""; + }; + 904388E6294019B30042BDBF /* GradeManagement */ = { + isa = PBXGroup; + children = ( + 90438911294075630042BDBF /* Modules */, + 90438904294074750042BDBF /* Utils */, + 904388E7294019B30042BDBF /* main.swift */, + ); + path = GradeManagement; + sourceTree = ""; + }; + 90438904294074750042BDBF /* Utils */ = { + isa = PBXGroup; + children = ( + 904389052940748F0042BDBF /* AddStudent.swift */, + 904389072940749D0042BDBF /* DeleteStudent.swift */, + 904389092940752F0042BDBF /* UpdateGrade.swift */, + 9043890B2940753B0042BDBF /* RemoveGrade.swift */, + 9043890D294075500042BDBF /* ReportCard.swift */, + 90438912294075C00042BDBF /* Exit.swift */, + ); + path = Utils; + sourceTree = ""; + }; + 90438911294075630042BDBF /* Modules */ = { + isa = PBXGroup; + children = ( + 904388EE29401B2A0042BDBF /* Modules.swift */, + ); + path = Modules; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 904388E3294019B30042BDBF /* GradeManagement */ = { + isa = PBXNativeTarget; + buildConfigurationList = 904388EB294019B30042BDBF /* Build configuration list for PBXNativeTarget "GradeManagement" */; + buildPhases = ( + 904388E0294019B30042BDBF /* Sources */, + 904388E1294019B30042BDBF /* Frameworks */, + 904388E2294019B30042BDBF /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = GradeManagement; + productName = GradeManagement; + productReference = 904388E4294019B30042BDBF /* GradeManagement */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 904388DC294019B30042BDBF /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1400; + LastUpgradeCheck = 1400; + TargetAttributes = { + 904388E3294019B30042BDBF = { + CreatedOnToolsVersion = 14.0; + }; + }; + }; + buildConfigurationList = 904388DF294019B30042BDBF /* Build configuration list for PBXProject "GradeManagement" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 904388DB294019B30042BDBF; + productRefGroup = 904388E5294019B30042BDBF /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 904388E3294019B30042BDBF /* GradeManagement */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 904388E0294019B30042BDBF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9043890E294075500042BDBF /* ReportCard.swift in Sources */, + 904389082940749D0042BDBF /* DeleteStudent.swift in Sources */, + 904388E8294019B30042BDBF /* main.swift in Sources */, + 904388EF29401B2A0042BDBF /* Modules.swift in Sources */, + 9043890C2940753B0042BDBF /* RemoveGrade.swift in Sources */, + 9043890A2940752F0042BDBF /* UpdateGrade.swift in Sources */, + 904389062940748F0042BDBF /* AddStudent.swift in Sources */, + 90438913294075C00042BDBF /* Exit.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 904388E9294019B30042BDBF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 12.3; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 904388EA294019B30042BDBF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 12.3; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 904388EC294019B30042BDBF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 904388ED294019B30042BDBF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 904388DF294019B30042BDBF /* Build configuration list for PBXProject "GradeManagement" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 904388E9294019B30042BDBF /* Debug */, + 904388EA294019B30042BDBF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 904388EB294019B30042BDBF /* Build configuration list for PBXNativeTarget "GradeManagement" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 904388EC294019B30042BDBF /* Debug */, + 904388ED294019B30042BDBF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 904388DC294019B30042BDBF /* Project object */; +} diff --git a/GradeManagement.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/GradeManagement.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/GradeManagement.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/GradeManagement.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/GradeManagement.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/GradeManagement.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/GradeManagement.xcodeproj/project.xcworkspace/xcuserdata/bagjaeu.xcuserdatad/UserInterfaceState.xcuserstate b/GradeManagement.xcodeproj/project.xcworkspace/xcuserdata/bagjaeu.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..01d2ab5 Binary files /dev/null and b/GradeManagement.xcodeproj/project.xcworkspace/xcuserdata/bagjaeu.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/GradeManagement.xcodeproj/xcuserdata/bagjaeu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/GradeManagement.xcodeproj/xcuserdata/bagjaeu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..ce07c16 --- /dev/null +++ b/GradeManagement.xcodeproj/xcuserdata/bagjaeu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,24 @@ + + + + + + + + + diff --git a/GradeManagement.xcodeproj/xcuserdata/bagjaeu.xcuserdatad/xcschemes/xcschememanagement.plist b/GradeManagement.xcodeproj/xcuserdata/bagjaeu.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..0af47ad --- /dev/null +++ b/GradeManagement.xcodeproj/xcuserdata/bagjaeu.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + GradeManagement.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/GradeManagement/Modules/Modules.swift b/GradeManagement/Modules/Modules.swift new file mode 100644 index 0000000..6ca0a4b --- /dev/null +++ b/GradeManagement/Modules/Modules.swift @@ -0,0 +1,98 @@ +// +// Modules.swift +// GradeManagement +// +// Created by 박재우 on 2022/12/07. +// + +import Foundation + +typealias Student = String + +class Management { + var students: [Student: [ReportCard]] = [:] +} + +struct ReportCard { + var subject: String + var grade: String +} + +enum Pattern: String { + case input = "^[0-9a-zA-Z+]*$" +} + +enum Score: Double { + case APlus = 4.5 + case AZero = 4.0 + case BPlus = 3.5 + case BZero = 3.0 + case CPlus = 2.5 + case CZero = 2.0 + case DPlus = 1.5 + case DZero = 1.0 + case F = 0.0 +} + +enum Grade: String { + case APlus = "A+" + case AZero = "A0" + case BPlus = "B+" + case BZero = "B0" + case CPlus = "C+" + case CZero = "C0" + case DPlus = "D+" + case DZero = "D0" + case F = "F" +} + +enum Commands: String { + case addStudent = "1" + case deleteStudent = "2" + case updateGrade = "3" + case removeGrade = "4" + case reportCard = "5" + case exit = "X" +} + +enum Errors: String { + case main = "뭔가 입력이 잘못되었습니다. 1~5 사이의 숫자 혹은 X를 입력해주세요." + case input = "입력이 잘못되었습니다. 다시 확인해주세요." + case containStudent = "은 이미 존재하는 학생입니다. 추가하지 않습니다." + case searchStudent = " 학생을 찾지 못했습니다." + case searchSubject = " 과목을 찾지 못했습니다." +} + +extension Errors { + func printSelf() { + print(self.rawValue) + } +} +enum Questions: String { + case main = "원하는 기능을 입력해주세요\n1: 학생추가, 2: 학생삭제, 3: 성적추가(변경), 4: 성적삭제, 5: 평점보기, X: 종료" + case addStudent = "추가할 학생의 이름을 입력해주세요." + case deleteStudent = "삭제할 학생의 이름을 입력해주세요" + case updateGrade = "성적을 추가할 학생의 이름, 과목 이름, 성적(A+, A0, F 등)을 띄어쓰기로 구분하여 차례로 작성해주세요." + case removeGrade = "성적을 삭제할 학생의 이름, 과목 이름을 띄어쓰기로 구분하여 차례로 작성해주세요." + case reportCard = "평점을 알고 싶은 학생의 이름을 입력해주세요" +} + +class Operations { + func addStudent(_ student: Student) { + print("\(student) 학생을 추가했습니다.") + } + func deleteStudent(_ student: Student) { + print("\(student) 학생을 삭제하였습니다.") + } + func updateGrade(_ reportCard: ReportCard, of student: Student) { + print("\(student) 학생의 \(reportCard.subject) 과목이 \(reportCard.grade)로 추가(변경)되었습니다.") + } + func removeGrade(_ subject: String, of student: Student) { + print("\(student) 학생의 \(subject) 과목의 성적이 삭제되었습니다.") + } + var exit: String { + return "프로그램을 종료합니다..." + } +} + + diff --git a/GradeManagement/Utils/AddStudent.swift b/GradeManagement/Utils/AddStudent.swift new file mode 100644 index 0000000..57d5962 --- /dev/null +++ b/GradeManagement/Utils/AddStudent.swift @@ -0,0 +1,26 @@ +// +// AddStudent.swift +// GradeManagement +// +// Created by 박재우 on 2022/12/07. +// + +import Foundation + +func addStudent() { + print(Questions.addStudent.rawValue) + guard let student = readLine() else { return } + guard let _ = student.range(of: Pattern.input.rawValue, options: .regularExpression), + student.isEmpty == false else { + print(Errors.input.rawValue) + return + } + let isContain = manager.contains { $0.key == student } + guard isContain == false else { + print(student, terminator: "") + Errors.containStudent.printSelf() + return + } + manager[student] = [] + Operations().addStudent(student) +} diff --git a/GradeManagement/Utils/DeleteStudent.swift b/GradeManagement/Utils/DeleteStudent.swift new file mode 100644 index 0000000..1b15f6e --- /dev/null +++ b/GradeManagement/Utils/DeleteStudent.swift @@ -0,0 +1,25 @@ +// +// DeleteStudent.swift +// GradeManagement +// +// Created by 박재우 on 2022/12/07. +// + +import Foundation + +func deleteStudent() { + print(Questions.deleteStudent.rawValue) + guard let student = readLine() else { return } + guard let _ = student.range(of: Pattern.input.rawValue, options: .regularExpression), + student.isEmpty == false else { + print(Errors.input.rawValue) + return + } + let isContain = manager.contains { $0.key == student } + guard isContain else { + print("\(student)\(Errors.searchStudent.rawValue)") + return + } + manager.removeValue(forKey: student) + Operations().deleteStudent(student) +} diff --git a/GradeManagement/Utils/Exit.swift b/GradeManagement/Utils/Exit.swift new file mode 100644 index 0000000..3341349 --- /dev/null +++ b/GradeManagement/Utils/Exit.swift @@ -0,0 +1,12 @@ +// +// Exit.swift +// GradeManagement +// +// Created by 박재우 on 2022/12/07. +// + +import Foundation + +func exit() { + print(Operations().exit) +} diff --git a/GradeManagement/Utils/RemoveGrade.swift b/GradeManagement/Utils/RemoveGrade.swift new file mode 100644 index 0000000..65ad8a3 --- /dev/null +++ b/GradeManagement/Utils/RemoveGrade.swift @@ -0,0 +1,41 @@ +// +// RemoveGrade.swift +// GradeManagement +// +// Created by 박재우 on 2022/12/07. +// + +import Foundation + +func removeGrade() { + print(Questions.removeGrade.rawValue) + guard let answer = readLine() else { return } + var inputs = answer.components(separatedBy: " ") + guard 2 == inputs.count else { + print(Errors.input.rawValue) + return + } + for input in inputs { + guard let _ = input.range(of: Pattern.input.rawValue, options: .regularExpression), + input.isEmpty == false else { + print(Errors.input.rawValue) + return + } + } + let student = inputs.removeFirst() + let isStudent = manager.contains { $0.key == student } + guard isStudent else { + print("\(student)\(Errors.searchStudent.rawValue)") + return + } + let subject = inputs.removeFirst() + guard let reports = manager[student] else {return} + for index in 0.. String? { + return readLine() +} + +var manager = Management().students +repeat { + print(Questions.main.rawValue) + guard let input = inputCommand() else { break } + switch Commands(rawValue: input) { + case .addStudent: + addStudent() + case .deleteStudent: + deleteStudent() + case .updateGrade: + updateGrade() + case .removeGrade: + removeGrade() + case .reportCard: + reportCard() + default: + print(Errors.main.rawValue) + } +} while input != Commands.exit.rawValue +