├── .gitignore ├── 1.png ├── 2.jpg ├── 3.png ├── 4.png ├── Bank ├── README.txt ├── bank1 │ ├── .idea │ │ ├── .gitignore │ │ ├── discord.xml │ │ ├── misc.xml │ │ └── modules.xml │ ├── CMakeLists.txt │ ├── account.cpp │ ├── account.h │ ├── bmyi.txt │ ├── cmake-build-debug │ │ ├── .cmake │ │ │ └── api │ │ │ │ └── v1 │ │ │ │ ├── query │ │ │ │ ├── cache-v2 │ │ │ │ ├── cmakeFiles-v1 │ │ │ │ ├── codemodel-v2 │ │ │ │ └── toolchains-v1 │ │ │ │ └── reply │ │ │ │ ├── cache-v2-ba942b43c5ec3b3e8841.json │ │ │ │ ├── cmakeFiles-v1-d63596660d0551dc33a5.json │ │ │ │ ├── codemodel-v2-44de45566d9caa0f9d80.json │ │ │ │ ├── directory-.-Debug-f5ebdc15457944623624.json │ │ │ │ ├── index-2022-09-09T09-53-00-0343.json │ │ │ │ ├── target-bank1-Debug-eb1b46047537d73569aa.json │ │ │ │ └── toolchains-v1-9002b9f304a9a6bc85b8.json │ │ ├── .ninja_deps │ │ ├── .ninja_log │ │ ├── CMakeCache.txt │ │ ├── CMakeFiles │ │ │ ├── 3.21.1 │ │ │ │ ├── CMakeCCompiler.cmake │ │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ │ ├── CMakeSystem.cmake │ │ │ │ ├── CompilerIdC │ │ │ │ │ ├── CMakeCCompilerId.c │ │ │ │ │ └── CMakeCCompilerId.o │ │ │ │ └── CompilerIdCXX │ │ │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ │ │ └── CMakeCXXCompilerId.o │ │ │ ├── CMakeError.log │ │ │ ├── CMakeOutput.log │ │ │ ├── TargetDirectories.txt │ │ │ ├── bank1.dir │ │ │ │ ├── account.cpp.o │ │ │ │ └── step_1.cpp.o │ │ │ ├── clion-environment.txt │ │ │ ├── clion-log.txt │ │ │ ├── cmake.check_cache │ │ │ └── rules.ninja │ │ ├── Testing │ │ │ └── Temporary │ │ │ │ └── LastTest.log │ │ ├── bank1 │ │ ├── build.ninja │ │ └── cmake_install.cmake │ └── step_1.cpp ├── bank2 │ ├── .idea │ │ ├── .gitignore │ │ ├── discord.xml │ │ ├── misc.xml │ │ └── modules.xml │ ├── CMakeLists.txt │ ├── account.cpp │ ├── account.h │ ├── cmake-build-debug │ │ ├── .cmake │ │ │ └── api │ │ │ │ └── v1 │ │ │ │ ├── query │ │ │ │ ├── cache-v2 │ │ │ │ ├── cmakeFiles-v1 │ │ │ │ ├── codemodel-v2 │ │ │ │ └── toolchains-v1 │ │ │ │ └── reply │ │ │ │ ├── cache-v2-483adab9b81d44133ad8.json │ │ │ │ ├── cmakeFiles-v1-f82d4ffd9fc8534b9ec5.json │ │ │ │ ├── codemodel-v2-6bfcdc927a06534c0991.json │ │ │ │ ├── directory-.-Debug-f5ebdc15457944623624.json │ │ │ │ ├── index-2022-09-06T06-54-10-0870.json │ │ │ │ ├── target-bank2-Debug-6be1d7408f1169842fb6.json │ │ │ │ └── toolchains-v1-9002b9f304a9a6bc85b8.json │ │ ├── .ninja_deps │ │ ├── .ninja_log │ │ ├── CMakeCache.txt │ │ ├── CMakeFiles │ │ │ ├── 3.21.1 │ │ │ │ ├── CMakeCCompiler.cmake │ │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ │ ├── CMakeSystem.cmake │ │ │ │ ├── CompilerIdC │ │ │ │ │ ├── CMakeCCompilerId.c │ │ │ │ │ └── CMakeCCompilerId.o │ │ │ │ └── CompilerIdCXX │ │ │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ │ │ └── CMakeCXXCompilerId.o │ │ │ ├── CMakeError.log │ │ │ ├── CMakeOutput.log │ │ │ ├── TargetDirectories.txt │ │ │ ├── bank2.dir │ │ │ │ ├── account.cpp.o │ │ │ │ ├── date.cpp.o │ │ │ │ └── step_2.cpp.o │ │ │ ├── clion-environment.txt │ │ │ ├── clion-log.txt │ │ │ ├── cmake.check_cache │ │ │ └── rules.ninja │ │ ├── Testing │ │ │ └── Temporary │ │ │ │ └── LastTest.log │ │ ├── bank2 │ │ ├── build.ninja │ │ └── cmake_install.cmake │ ├── date.cpp │ ├── date.h │ └── step_2.cpp ├── bank3 │ ├── .idea │ │ ├── .gitignore │ │ ├── discord.xml │ │ ├── misc.xml │ │ └── modules.xml │ ├── Account.cpp │ ├── Account.h │ ├── Accumulator.cpp │ ├── Accumulator.h │ ├── CMakeLists.txt │ ├── CreditAccount.cpp │ ├── CreditAccount.h │ ├── SavingsAccount.cpp │ ├── SavingsAccount.h │ ├── cmake-build-debug │ │ ├── .cmake │ │ │ └── api │ │ │ │ └── v1 │ │ │ │ ├── query │ │ │ │ ├── cache-v2 │ │ │ │ ├── cmakeFiles-v1 │ │ │ │ ├── codemodel-v2 │ │ │ │ └── toolchains-v1 │ │ │ │ └── reply │ │ │ │ ├── cache-v2-d881dac7efc8f9676fe8.json │ │ │ │ ├── cmakeFiles-v1-80c78055caf2cf6f2191.json │ │ │ │ ├── codemodel-v2-f68c509b912e9638cf9f.json │ │ │ │ ├── directory-.-Debug-f5ebdc15457944623624.json │ │ │ │ ├── index-2022-09-20T15-14-14-0171.json │ │ │ │ ├── target-bank3-Debug-c7e52aa5204a94fd35d8.json │ │ │ │ └── toolchains-v1-5b833b81ddf072f33d87.json │ │ ├── .ninja_deps │ │ ├── .ninja_log │ │ ├── CMakeCache.txt │ │ ├── CMakeFiles │ │ │ ├── 3.21.1 │ │ │ │ ├── CMakeCCompiler.cmake │ │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ │ ├── CMakeSystem.cmake │ │ │ │ ├── CompilerIdC │ │ │ │ │ ├── CMakeCCompilerId.c │ │ │ │ │ └── CMakeCCompilerId.o │ │ │ │ └── CompilerIdCXX │ │ │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ │ │ └── CMakeCXXCompilerId.o │ │ │ ├── CMakeError.log │ │ │ ├── CMakeOutput.log │ │ │ ├── TargetDirectories.txt │ │ │ ├── bank3.dir │ │ │ │ ├── Account.cpp.o │ │ │ │ ├── Accumulator.cpp.o │ │ │ │ ├── CreditAccount.cpp.o │ │ │ │ ├── SavingsAccount.cpp.o │ │ │ │ ├── date.cpp.o │ │ │ │ └── step_3.cpp.o │ │ │ ├── clion-environment.txt │ │ │ ├── clion-log.txt │ │ │ ├── cmake.check_cache │ │ │ └── rules.ninja │ │ ├── Testing │ │ │ └── Temporary │ │ │ │ └── LastTest.log │ │ ├── bank3 │ │ ├── build.ninja │ │ └── cmake_install.cmake │ ├── date.cpp │ ├── date.h │ └── step_3.cpp ├── bank4 │ ├── .idea │ │ ├── .gitignore │ │ ├── discord.xml │ │ ├── misc.xml │ │ └── modules.xml │ ├── Account.cpp │ ├── Account.h │ ├── Accumulator.cpp │ ├── Accumulator.h │ ├── CMakeLists.txt │ ├── CreditAccount.cpp │ ├── CreditAccount.h │ ├── SavingsAccount.cpp │ ├── SavingsAccount.h │ ├── cmake-build-debug │ │ ├── .cmake │ │ │ └── api │ │ │ │ └── v1 │ │ │ │ ├── query │ │ │ │ ├── cache-v2 │ │ │ │ ├── cmakeFiles-v1 │ │ │ │ ├── codemodel-v2 │ │ │ │ └── toolchains-v1 │ │ │ │ └── reply │ │ │ │ ├── cache-v2-a4e8bfb2e77133bb52c3.json │ │ │ │ ├── cmakeFiles-v1-89b56682d07e52053cd7.json │ │ │ │ ├── codemodel-v2-c51d1cce3aad8e85aa58.json │ │ │ │ ├── directory-.-Debug-f5ebdc15457944623624.json │ │ │ │ ├── index-2022-09-29T10-11-50-0072.json │ │ │ │ ├── target-bank4-Debug-617c77a44c50f8f69830.json │ │ │ │ └── toolchains-v1-5b833b81ddf072f33d87.json │ │ ├── .ninja_deps │ │ ├── .ninja_log │ │ ├── CMakeCache.txt │ │ ├── CMakeFiles │ │ │ ├── 3.21.1 │ │ │ │ ├── CMakeCCompiler.cmake │ │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ │ ├── CMakeSystem.cmake │ │ │ │ ├── CompilerIdC │ │ │ │ │ ├── CMakeCCompilerId.c │ │ │ │ │ └── CMakeCCompilerId.o │ │ │ │ └── CompilerIdCXX │ │ │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ │ │ └── CMakeCXXCompilerId.o │ │ │ ├── CMakeError.log │ │ │ ├── CMakeOutput.log │ │ │ ├── TargetDirectories.txt │ │ │ ├── bank4.dir │ │ │ │ ├── Account.cpp.o │ │ │ │ ├── Accumulator.cpp.o │ │ │ │ ├── CreditAccount.cpp.o │ │ │ │ ├── SavingsAccount.cpp.o │ │ │ │ ├── date.cpp.o │ │ │ │ └── step_4.cpp.o │ │ │ ├── clion-environment.txt │ │ │ ├── clion-log.txt │ │ │ ├── cmake.check_cache │ │ │ └── rules.ninja │ │ ├── Testing │ │ │ └── Temporary │ │ │ │ └── LastTest.log │ │ ├── bank3 │ │ ├── bank4 │ │ ├── build.ninja │ │ └── cmake_install.cmake │ ├── date.cpp │ ├── date.h │ └── step_4.cpp ├── bank5 │ ├── .idea │ │ ├── .gitignore │ │ ├── discord.xml │ │ ├── misc.xml │ │ └── modules.xml │ ├── Account.cpp │ ├── Account.h │ ├── Accumulator.cpp │ ├── Accumulator.h │ ├── CMakeLists.txt │ ├── CreditAccount.cpp │ ├── CreditAccount.h │ ├── SavingsAccount.cpp │ ├── SavingsAccount.h │ ├── cmake-build-debug │ │ ├── .cmake │ │ │ └── api │ │ │ │ └── v1 │ │ │ │ ├── query │ │ │ │ ├── cache-v2 │ │ │ │ ├── cmakeFiles-v1 │ │ │ │ ├── codemodel-v2 │ │ │ │ └── toolchains-v1 │ │ │ │ └── reply │ │ │ │ ├── cache-v2-8c8c1d9689a17d9f1bec.json │ │ │ │ ├── cmakeFiles-v1-170bd5f23d0a01d92b1b.json │ │ │ │ ├── codemodel-v2-a3056065330bf3a62973.json │ │ │ │ ├── directory-.-Debug-f5ebdc15457944623624.json │ │ │ │ ├── index-2022-09-23T02-17-01-0587.json │ │ │ │ ├── target-bank5-Debug-00c479d5685656b3a2bd.json │ │ │ │ └── toolchains-v1-5b833b81ddf072f33d87.json │ │ ├── .ninja_deps │ │ ├── .ninja_log │ │ ├── CMakeCache.txt │ │ ├── CMakeFiles │ │ │ ├── 3.21.1 │ │ │ │ ├── CMakeCCompiler.cmake │ │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ │ ├── CMakeSystem.cmake │ │ │ │ ├── CompilerIdC │ │ │ │ │ ├── CMakeCCompilerId.c │ │ │ │ │ └── CMakeCCompilerId.o │ │ │ │ └── CompilerIdCXX │ │ │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ │ │ └── CMakeCXXCompilerId.o │ │ │ ├── CMakeError.log │ │ │ ├── CMakeOutput.log │ │ │ ├── TargetDirectories.txt │ │ │ ├── bank5.dir │ │ │ │ ├── Account.cpp.o │ │ │ │ ├── Accumulator.cpp.o │ │ │ │ ├── CreditAccount.cpp.o │ │ │ │ ├── SavingsAccount.cpp.o │ │ │ │ ├── date.cpp.o │ │ │ │ └── step_5.cpp.o │ │ │ ├── clion-environment.txt │ │ │ ├── clion-log.txt │ │ │ ├── cmake.check_cache │ │ │ └── rules.ninja │ │ ├── Testing │ │ │ └── Temporary │ │ │ │ └── LastTest.log │ │ ├── bank3 │ │ ├── bank4 │ │ ├── bank5 │ │ ├── build.ninja │ │ └── cmake_install.cmake │ ├── date.cpp │ ├── date.h │ └── step_5.cpp ├── bank6 │ ├── .idea │ │ ├── .gitignore │ │ ├── discord.xml │ │ ├── misc.xml │ │ └── modules.xml │ ├── Account.cpp │ ├── Account.h │ ├── Accumulator.cpp │ ├── Accumulator.h │ ├── CMakeLists.txt │ ├── CreditAccount.cpp │ ├── CreditAccount.h │ ├── SavingsAccount.cpp │ ├── SavingsAccount.h │ ├── cmake-build-debug │ │ ├── .cmake │ │ │ └── api │ │ │ │ └── v1 │ │ │ │ ├── query │ │ │ │ ├── cache-v2 │ │ │ │ ├── cmakeFiles-v1 │ │ │ │ ├── codemodel-v2 │ │ │ │ └── toolchains-v1 │ │ │ │ └── reply │ │ │ │ ├── cache-v2-e9b9bbf2be78f39624e3.json │ │ │ │ ├── cmakeFiles-v1-e03521b9cc20a8a85d4e.json │ │ │ │ ├── codemodel-v2-7662594af196df4321ba.json │ │ │ │ ├── directory-.-Debug-f5ebdc15457944623624.json │ │ │ │ ├── index-2022-09-29T14-13-33-0348.json │ │ │ │ ├── target-bank6-Debug-b21e929b387aa6f8aa53.json │ │ │ │ └── toolchains-v1-5b833b81ddf072f33d87.json │ │ ├── .ninja_deps │ │ ├── .ninja_log │ │ ├── CMakeCache.txt │ │ ├── CMakeFiles │ │ │ ├── 3.21.1 │ │ │ │ ├── CMakeCCompiler.cmake │ │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ │ ├── CMakeSystem.cmake │ │ │ │ ├── CompilerIdC │ │ │ │ │ ├── CMakeCCompilerId.c │ │ │ │ │ └── CMakeCCompilerId.o │ │ │ │ └── CompilerIdCXX │ │ │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ │ │ └── CMakeCXXCompilerId.o │ │ │ ├── CMakeError.log │ │ │ ├── CMakeOutput.log │ │ │ ├── TargetDirectories.txt │ │ │ ├── bank6.dir │ │ │ │ ├── Account.cpp.o │ │ │ │ ├── Accumulator.cpp.o │ │ │ │ ├── CreditAccount.cpp.o │ │ │ │ ├── SavingsAccount.cpp.o │ │ │ │ ├── date.cpp.o │ │ │ │ └── step_6.cpp.o │ │ │ ├── clion-environment.txt │ │ │ ├── clion-log.txt │ │ │ ├── cmake.check_cache │ │ │ └── rules.ninja │ │ ├── Testing │ │ │ └── Temporary │ │ │ │ └── LastTest.log │ │ ├── bank3 │ │ ├── bank4 │ │ ├── bank5 │ │ ├── bank6 │ │ ├── build.ninja │ │ └── cmake_install.cmake │ ├── commands3333.txt │ ├── date.cpp │ ├── date.h │ └── step_6.cpp ├── bank7 │ ├── .idea │ │ ├── .gitignore │ │ ├── discord.xml │ │ ├── inspectionProfiles │ │ │ └── Project_Default.xml │ │ ├── misc.xml │ │ └── modules.xml │ ├── Account.cpp │ ├── Account.h │ ├── Accumulator.cpp │ ├── Accumulator.h │ ├── CMakeLists.txt │ ├── CreditAccount.cpp │ ├── CreditAccount.h │ ├── SavingsAccount.cpp │ ├── SavingsAccount.h │ ├── commands.txt │ ├── date.cpp │ ├── date.h │ └── step_7.cpp ├── qtbank │ ├── .idea │ │ ├── .gitignore │ │ ├── discord.xml │ │ ├── misc.xml │ │ └── modules.xml │ ├── Account.cpp │ ├── Account.h │ ├── Accumulator.cpp │ ├── Accumulator.h │ ├── CreditAccount.cpp │ ├── CreditAccount.h │ ├── SavingsAccount.cpp │ ├── SavingsAccount.h │ ├── bankusers.cpp │ ├── bankusers.h │ ├── date.cpp │ ├── date.h │ ├── insidewindow.cpp │ ├── insidewindow.h │ ├── insidewindow.ui │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ ├── md5.cpp │ ├── md5.h │ ├── qtbank.pro │ └── qtbank.pro.user └── 程序设计实践II银行实验报告.docx ├── CMakeLists.txt ├── HarryPotterSearch ├── HarryPotterSearch │ ├── HP2--Harry_Potter_and_the_Chamber_of_Secrets_Book_2_.txt │ ├── HP7--Harry_Potter_and_the_Deathly_Hallows_Book_7_.txt │ ├── HarryPotterSearch.pro │ ├── HarryPotterSearch.pro.user │ ├── J.K. Rowling - HP 0 - Harry Potter Prequel.txt │ ├── J.K. Rowling - HP 3 - Harry Potter and the Prisoner of Azkaban.txt │ ├── J.K. Rowling - HP 4 - Harry Potter and the Goblet of Fire.txt │ ├── J.K. Rowling - HP 6 - Harry Potter and the Half-Blood Prince.txt │ ├── J.K. Rowling - Quidditch Through the Ages.txt │ ├── J.K. Rowling - The Tales of Beedle the Bard.txt │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ └── mainwindow.ui ├── mainn.cpp └── 哈利波特检索实验报告.docx ├── README.md ├── exercise1 ├── 1-1 │ ├── 1-1_who_catched_the_most_scholarship.rap │ └── 1. 流程图绘制2:要求绘制解决问题的算法(谁拿了最多奖学金).docx ├── 1-2 │ ├── 1-2_search_the_number.rap │ └── 2. 流程图绘制1:要求绘制解决问题的算法.docx ├── vr1_1.cpp ├── vr1_2.cpp └── vr1_3.cpp ├── exercise2 ├── vr2_1.cpp ├── vr2_2.cpp ├── vr2_3.cpp ├── vr2_4.cpp └── vr2_5.cpp ├── exercise3 ├── vr3_1.cpp ├── vr3_2.cpp ├── vr3_3.cpp ├── vr3_4.cpp └── vr3_5.cpp ├── exercise4 ├── vr4-1 │ ├── error.multiplication.cpp │ └── right_multiplication.cpp ├── vr4-2 │ ├── error.calc.cpp │ ├── right_calc.cpp │ └── this_is_really_right.cpp ├── vr4-3 │ ├── error.bubble_sort.cpp │ └── right_bubble_sort.cpp └── vr4-4 │ ├── error.seat.cpp │ └── right_seat.cpp ├── exercise5 ├── take_a_coin.cpp ├── vr5_1.cpp ├── vr5_2.cpp ├── vr5_3.cpp ├── vr5_4.cpp ├── vr5_5.cpp ├── vr5_6.cpp ├── vr5_7.cpp └── vr5_8.cpp ├── planebattle ├── .idea │ ├── .gitignore │ ├── encodings.xml │ ├── misc.xml │ └── modules.xml ├── Bullet.cpp ├── Bullet.h ├── CMakeLists.txt ├── ConsoleOperator.cpp ├── ConsoleOperator.h ├── EnemyPlane.cpp ├── EnemyPlane.h ├── MyPlane.cpp ├── MyPlane.h ├── TheMap.cpp ├── TheMap.h ├── img.png ├── main.cpp ├── readme.png └── 飞机大战的游戏设计.docx └── qt_plane ├── .idea ├── .gitignore ├── misc.xml └── modules.xml ├── Bullet.cpp ├── Bullet.h ├── CMakeLists.txt ├── CMakeLists.txt.user ├── Enemy.png ├── EnemyPlane.cpp ├── EnemyPlane.h ├── MyPlane.cpp ├── MyPlane.h ├── Myplane.png ├── TheMap.cpp ├── TheMap.h ├── bullet.png ├── cmake-build-debug ├── .cmake │ └── api │ │ └── v1 │ │ └── query │ │ ├── cache-v2 │ │ ├── cmakeFiles-v1 │ │ ├── codemodel-v2 │ │ └── toolchains-v1 ├── CMakeCache.txt └── CMakeFiles │ ├── 3.25.2 │ ├── CMakeCXXCompiler.cmake │ ├── CMakeDetermineCompilerABI_CXX.bin │ ├── CMakeRCCompiler.cmake │ ├── CMakeSystem.cmake │ └── CompilerIdCXX │ │ ├── CMakeCXXCompilerId.cpp │ │ └── a.exe │ ├── CMakeOutput.log │ ├── clion-Debug-log.txt │ ├── clion-environment.txt │ └── cmake.check_cache ├── gameui.cpp ├── gameui.h ├── gameui.ui ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui └── qt做的plane.docx /.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | # 基于编辑器的 HTTP 客户端请求 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml/ 9 | /cmake-build-debug/ 10 | /.idea/ 11 | -------------------------------------------------------------------------------- /1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/1.png -------------------------------------------------------------------------------- /2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/2.jpg -------------------------------------------------------------------------------- /3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/3.png -------------------------------------------------------------------------------- /4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/4.png -------------------------------------------------------------------------------- /Bank/ README.txt: -------------------------------------------------------------------------------- 1 | qtbank是带图形界面的银行7(请使用Qt5.12.12编译,或者更高版本) 2 | 3 | bank7是不带图形界面的银行7 4 | bank1~6是不带图形界面的银行1~6 5 | 请使用Cmake,或者Clion -------------------------------------------------------------------------------- /Bank/bank1/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | # 基于编辑器的 HTTP 客户端请求 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /Bank/bank1/.idea/discord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /Bank/bank1/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Bank/bank1/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Bank/bank1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | project(bank1) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | include_directories(.) 7 | 8 | add_executable(bank1 9 | account.cpp 10 | account.h 11 | step_1.cpp) 12 | -------------------------------------------------------------------------------- /Bank/bank1/account.h: -------------------------------------------------------------------------------- 1 | #ifndef __ACCOUNT__ 2 | #define __ACCOUNT__ 3 | 4 | class SavingsAccount; 5 | 6 | class SavingsAccount 7 | { 8 | private: 9 | /* data */ 10 | int _id;//账户 11 | double _balance;//余额 12 | double _rate;//年利率 13 | int _lastDate; 14 | double _accumulation;//积累 15 | public: 16 | SavingsAccount(int date, int id, double rate); 17 | ~SavingsAccount(); 18 | void record(int date, double amount); 19 | double accumulate(int date); 20 | int getId(); 21 | double getBalance(); 22 | double getRate(); 23 | void show(); 24 | void deposit(int date, double amount); 25 | void withdraw(int date, double amount); 26 | void settle(int date); 27 | }; 28 | 29 | 30 | #endif -------------------------------------------------------------------------------- /Bank/bank1/bmyi.txt: -------------------------------------------------------------------------------- 1 | g++ -c step_1.cpp 2 | g++ -c account.cpp 3 | g++ -o output step_1.o account.o -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/.cmake/api/v1/query/cache-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/.cmake/api/v1/query/cache-v2 -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/.cmake/api/v1/query/codemodel-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/.cmake/api/v1/query/toolchains-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-44de45566d9caa0f9d80.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations" : 3 | [ 4 | { 5 | "directories" : 6 | [ 7 | { 8 | "build" : ".", 9 | "jsonFile" : "directory-.-Debug-f5ebdc15457944623624.json", 10 | "minimumCMakeVersion" : 11 | { 12 | "string" : "3.21" 13 | }, 14 | "projectIndex" : 0, 15 | "source" : ".", 16 | "targetIndexes" : 17 | [ 18 | 0 19 | ] 20 | } 21 | ], 22 | "name" : "Debug", 23 | "projects" : 24 | [ 25 | { 26 | "directoryIndexes" : 27 | [ 28 | 0 29 | ], 30 | "name" : "bank1", 31 | "targetIndexes" : 32 | [ 33 | 0 34 | ] 35 | } 36 | ], 37 | "targets" : 38 | [ 39 | { 40 | "directoryIndex" : 0, 41 | "id" : "bank1::@6890427a1f51a3e7e1df", 42 | "jsonFile" : "target-bank1-Debug-eb1b46047537d73569aa.json", 43 | "name" : "bank1", 44 | "projectIndex" : 0 45 | } 46 | ] 47 | } 48 | ], 49 | "kind" : "codemodel", 50 | "paths" : 51 | { 52 | "build" : "/Users/cakeal/Desktop/class/bank1/cmake-build-debug", 53 | "source" : "/Users/cakeal/Desktop/class/bank1" 54 | }, 55 | "version" : 56 | { 57 | "major" : 2, 58 | "minor" : 3 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json: -------------------------------------------------------------------------------- 1 | { 2 | "backtraceGraph" : 3 | { 4 | "commands" : [], 5 | "files" : [], 6 | "nodes" : [] 7 | }, 8 | "installers" : [], 9 | "paths" : 10 | { 11 | "build" : ".", 12 | "source" : "." 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/.ninja_deps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/.ninja_deps -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/.ninja_log: -------------------------------------------------------------------------------- 1 | # ninja log v5 2 | 1 1302 1662718271514275513 CMakeFiles/bank1.dir/step_1.cpp.o f38b552bf1f29735 3 | 0 1320 1662718271538695038 CMakeFiles/bank1.dir/account.cpp.o 7580fdddf0a7b5b2 4 | 1320 1403 1662718271625495303 bank1 4acd96818f805514 5 | 5 1948 1662795080310257457 CMakeFiles/bank1.dir/step_1.cpp.o f38b552bf1f29735 6 | 4 1961 1662795080330264116 CMakeFiles/bank1.dir/account.cpp.o 7580fdddf0a7b5b2 7 | 1961 2120 1662795080492382399 bank1 4acd96818f805514 8 | -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/3.21.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Darwin-21.6.0") 2 | set(CMAKE_HOST_SYSTEM_NAME "Darwin") 3 | set(CMAKE_HOST_SYSTEM_VERSION "21.6.0") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Darwin-21.6.0") 9 | set(CMAKE_SYSTEM_NAME "Darwin") 10 | set(CMAKE_SYSTEM_VERSION "21.6.0") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/CMakeError.log: -------------------------------------------------------------------------------- 1 | Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. 2 | Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc 3 | Build flags: 4 | Id flags: 5 | 6 | The output was: 7 | 1 8 | ld: library not found for -lSystem 9 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 10 | 11 | 12 | Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. 13 | Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ 14 | Build flags: 15 | Id flags: 16 | 17 | The output was: 18 | 1 19 | ld: library not found for -lc++ 20 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 21 | 22 | 23 | -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /Users/cakeal/Desktop/class/bank1/cmake-build-debug/CMakeFiles/rebuild_cache.dir 2 | /Users/cakeal/Desktop/class/bank1/cmake-build-debug/CMakeFiles/edit_cache.dir 3 | /Users/cakeal/Desktop/class/bank1/cmake-build-debug/CMakeFiles/bank1.dir 4 | -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/bank1.dir/account.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/CMakeFiles/bank1.dir/account.cpp.o -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/bank1.dir/step_1.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/CMakeFiles/bank1.dir/step_1.cpp.o -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/clion-environment.txt: -------------------------------------------------------------------------------- 1 | ToolSet: 1.0 (local)Options: 2 | 3 | Options:-DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/clion-log.txt: -------------------------------------------------------------------------------- 1 | /Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -G Ninja /Users/cakeal/Desktop/class/bank1 2 | -- Configuring done 3 | -- Generating done 4 | -- Build files have been written to: /Users/cakeal/Desktop/class/bank1/cmake-build-debug 5 | -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/Testing/Temporary/LastTest.log: -------------------------------------------------------------------------------- 1 | Start testing: Sep 10 15:31 CST 2 | ---------------------------------------------------------- 3 | End testing: Sep 10 15:31 CST 4 | -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/bank1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank1/cmake-build-debug/bank1 -------------------------------------------------------------------------------- /Bank/bank1/cmake-build-debug/cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /Users/cakeal/Desktop/class/bank1 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr/local") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "Debug") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Is this installation the result of a crosscompile? 31 | if(NOT DEFINED CMAKE_CROSSCOMPILING) 32 | set(CMAKE_CROSSCOMPILING "FALSE") 33 | endif() 34 | 35 | # Set default install directory permissions. 36 | if(NOT DEFINED CMAKE_OBJDUMP) 37 | set(CMAKE_OBJDUMP "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump") 38 | endif() 39 | 40 | if(CMAKE_INSTALL_COMPONENT) 41 | set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") 42 | else() 43 | set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") 44 | endif() 45 | 46 | string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT 47 | "${CMAKE_INSTALL_MANIFEST_FILES}") 48 | file(WRITE "/Users/cakeal/Desktop/class/bank1/cmake-build-debug/${CMAKE_INSTALL_MANIFEST}" 49 | "${CMAKE_INSTALL_MANIFEST_CONTENT}") 50 | -------------------------------------------------------------------------------- /Bank/bank1/step_1.cpp: -------------------------------------------------------------------------------- 1 | #include "account.h" 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | //建立几个账户 8 | SavingsAccount sa0(1, 21325302, 0.015); 9 | SavingsAccount sa1(1, 58320212, 0.015); 10 | //几笔账目 11 | sa0.deposit(5, 5000); 12 | sa1.deposit(25, 10000); 13 | sa0.deposit(45, 5500); 14 | sa1.withdraw(60, 4000); 15 | //开户后第90天到了银行的计息日,结算所有账户的年息 16 | sa0.settle(90); 17 | sa1.settle(90); 18 | //输出各个账户信息 19 | sa0.show(); 20 | cout << endl; 21 | sa1.show(); 22 | cout << endl; 23 | // cout << "Total: " << SavingsAccount::getTotal() << endl; 24 | // system("pause"); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Bank/bank2/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | # 基于编辑器的 HTTP 客户端请求 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /Bank/bank2/.idea/discord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /Bank/bank2/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Bank/bank2/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Bank/bank2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | project(bank2) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | include_directories(.) 7 | 8 | add_executable(bank2 9 | account.cpp 10 | account.h 11 | date.cpp 12 | date.h 13 | step_2.cpp) 14 | -------------------------------------------------------------------------------- /Bank/bank2/account.h: -------------------------------------------------------------------------------- 1 | #ifndef __ACCOUNT__ 2 | #define __ACCOUNT__ 3 | 4 | #include 5 | #include "date.h" 6 | using namespace std; 7 | 8 | class SavingsAccount; 9 | 10 | class SavingsAccount 11 | { 12 | private: 13 | /* data */ 14 | string _id;//账户 15 | double _balance;//余额 16 | double _rate;//年利率 17 | int _lastDate; 18 | double _accumulation;//积累 19 | static double total; // 所有用户总金额 20 | public: 21 | SavingsAccount(Date date, string id, double rate); 22 | ~SavingsAccount(); 23 | void record(int date, double amount); 24 | double accumulate(int date); 25 | int getId(); 26 | double getBalance(); 27 | double getRate(); 28 | void show(); 29 | void deposit(Date date, double amount, const char *things); 30 | void withdraw(Date date, double amount, const char *things); 31 | void settle(Date date); 32 | static double getTotal(); 33 | 34 | }; 35 | 36 | 37 | 38 | #endif -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/.cmake/api/v1/query/cache-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/.cmake/api/v1/query/cache-v2 -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/.cmake/api/v1/query/codemodel-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/.cmake/api/v1/query/toolchains-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-6bfcdc927a06534c0991.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations" : 3 | [ 4 | { 5 | "directories" : 6 | [ 7 | { 8 | "build" : ".", 9 | "jsonFile" : "directory-.-Debug-f5ebdc15457944623624.json", 10 | "minimumCMakeVersion" : 11 | { 12 | "string" : "3.21" 13 | }, 14 | "projectIndex" : 0, 15 | "source" : ".", 16 | "targetIndexes" : 17 | [ 18 | 0 19 | ] 20 | } 21 | ], 22 | "name" : "Debug", 23 | "projects" : 24 | [ 25 | { 26 | "directoryIndexes" : 27 | [ 28 | 0 29 | ], 30 | "name" : "bank2", 31 | "targetIndexes" : 32 | [ 33 | 0 34 | ] 35 | } 36 | ], 37 | "targets" : 38 | [ 39 | { 40 | "directoryIndex" : 0, 41 | "id" : "bank2::@6890427a1f51a3e7e1df", 42 | "jsonFile" : "target-bank2-Debug-6be1d7408f1169842fb6.json", 43 | "name" : "bank2", 44 | "projectIndex" : 0 45 | } 46 | ] 47 | } 48 | ], 49 | "kind" : "codemodel", 50 | "paths" : 51 | { 52 | "build" : "/Users/cakeal/Desktop/class/bank2/cmake-build-debug", 53 | "source" : "/Users/cakeal/Desktop/class/bank2" 54 | }, 55 | "version" : 56 | { 57 | "major" : 2, 58 | "minor" : 3 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json: -------------------------------------------------------------------------------- 1 | { 2 | "backtraceGraph" : 3 | { 4 | "commands" : [], 5 | "files" : [], 6 | "nodes" : [] 7 | }, 8 | "installers" : [], 9 | "paths" : 10 | { 11 | "build" : ".", 12 | "source" : "." 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/.ninja_deps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/.ninja_deps -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/3.21.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Darwin-21.6.0") 2 | set(CMAKE_HOST_SYSTEM_NAME "Darwin") 3 | set(CMAKE_HOST_SYSTEM_VERSION "21.6.0") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Darwin-21.6.0") 9 | set(CMAKE_SYSTEM_NAME "Darwin") 10 | set(CMAKE_SYSTEM_VERSION "21.6.0") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/CMakeError.log: -------------------------------------------------------------------------------- 1 | Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. 2 | Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc 3 | Build flags: 4 | Id flags: 5 | 6 | The output was: 7 | 1 8 | ld: library not found for -lSystem 9 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 10 | 11 | 12 | Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. 13 | Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ 14 | Build flags: 15 | Id flags: 16 | 17 | The output was: 18 | 1 19 | ld: library not found for -lc++ 20 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 21 | 22 | 23 | -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /Users/cakeal/Desktop/class/bank2/cmake-build-debug/CMakeFiles/rebuild_cache.dir 2 | /Users/cakeal/Desktop/class/bank2/cmake-build-debug/CMakeFiles/edit_cache.dir 3 | /Users/cakeal/Desktop/class/bank2/cmake-build-debug/CMakeFiles/bank2.dir 4 | -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/bank2.dir/account.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/CMakeFiles/bank2.dir/account.cpp.o -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/bank2.dir/date.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/CMakeFiles/bank2.dir/date.cpp.o -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/bank2.dir/step_2.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/CMakeFiles/bank2.dir/step_2.cpp.o -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/clion-environment.txt: -------------------------------------------------------------------------------- 1 | ToolSet: 1.0 (local)Options: 2 | 3 | Options:-DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/clion-log.txt: -------------------------------------------------------------------------------- 1 | /Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -G Ninja /Users/cakeal/Desktop/class/bank2 2 | -- The C compiler identification is AppleClang 13.1.6.13160021 3 | -- The CXX compiler identification is AppleClang 13.1.6.13160021 4 | -- Detecting C compiler ABI info 5 | -- Detecting C compiler ABI info - done 6 | -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped 7 | -- Detecting C compile features 8 | -- Detecting C compile features - done 9 | -- Detecting CXX compiler ABI info 10 | -- Detecting CXX compiler ABI info - done 11 | -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped 12 | -- Detecting CXX compile features 13 | -- Detecting CXX compile features - done 14 | -- Configuring done 15 | -- Generating done 16 | -- Build files have been written to: /Users/cakeal/Desktop/class/bank2/cmake-build-debug 17 | -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/Testing/Temporary/LastTest.log: -------------------------------------------------------------------------------- 1 | Start testing: Sep 23 18:27 CST 2 | ---------------------------------------------------------- 3 | End testing: Sep 23 18:27 CST 4 | -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/bank2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank2/cmake-build-debug/bank2 -------------------------------------------------------------------------------- /Bank/bank2/cmake-build-debug/cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /Users/cakeal/Desktop/class/bank2 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr/local") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "Debug") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Is this installation the result of a crosscompile? 31 | if(NOT DEFINED CMAKE_CROSSCOMPILING) 32 | set(CMAKE_CROSSCOMPILING "FALSE") 33 | endif() 34 | 35 | # Set default install directory permissions. 36 | if(NOT DEFINED CMAKE_OBJDUMP) 37 | set(CMAKE_OBJDUMP "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump") 38 | endif() 39 | 40 | if(CMAKE_INSTALL_COMPONENT) 41 | set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") 42 | else() 43 | set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") 44 | endif() 45 | 46 | string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT 47 | "${CMAKE_INSTALL_MANIFEST_FILES}") 48 | file(WRITE "/Users/cakeal/Desktop/class/bank2/cmake-build-debug/${CMAKE_INSTALL_MANIFEST}" 49 | "${CMAKE_INSTALL_MANIFEST_CONTENT}") 50 | -------------------------------------------------------------------------------- /Bank/bank2/date.cpp: -------------------------------------------------------------------------------- 1 | #include "date.h" 2 | using namespace std; 3 | 4 | int TransTheDays(int year, int month, int day); 5 | 6 | Date::Date(int year, int month, int day) 7 | { 8 | _year = year; 9 | _month = month; 10 | _day = day; 11 | the_days_from_the_begin = TransTheDays(year, month, day); 12 | } 13 | 14 | Date::~Date() 15 | { 16 | } 17 | 18 | //用于转换年月日为为1900年1月1日距今多少天 19 | int TransTheDays(int year, int month, int day) 20 | { 21 | int the_days_form_the_begin = 0; //定义一个量,表示最后算出来的天数,距离1900年1月1日多少天 22 | //每个月的天数(不是闰年) 23 | int days_in_month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 24 | bool is_a_leap_year = false; //是否是闰年 25 | //判断是否是闰年 26 | if (year % 400 == 0) is_a_leap_year = true; 27 | else if (year % 100 == 0) is_a_leap_year = false; 28 | else if (year % 4 == 0) is_a_leap_year = true; 29 | //通过这个计算,算出当年1月1日到1900年1月1日多少天 30 | the_days_form_the_begin += (year - 1900) * 365 + (year - 1900) / 4 - (year - 1900) / 100 + (year - 1900 + 300) / 400; 31 | for(int i = 1; i < month; i++){//按月累加进总天数 32 | the_days_form_the_begin += days_in_month[i]; 33 | } 34 | //如果超过2月,那么加上是否是闰年的布尔值,如果是闰年就是1,不是闰年就加上0 35 | if(month > 2) the_days_form_the_begin += (int)is_a_leap_year; 36 | the_days_form_the_begin += day - 1; //当月距离第一天有几天 37 | if(day == 1) the_days_form_the_begin += 1; 38 | // cout< 5 | 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | Date date(2008, 11, 1); //起始日期 11 | //建立几个账户 12 | SavingsAccount accounts[] = { 13 | SavingsAccount(date, "S3755217", 0.015), 14 | SavingsAccount(date, "02342342", 0.015) 15 | }; 16 | const int n = sizeof(accounts) / sizeof(SavingsAccount); //账户总数 17 | // 11月份的几笔账目 18 | accounts[0].deposit(Date(2008, 11, 5), 5000, "salary"); 19 | accounts[1].deposit(Date(2008, 11, 25), 10000, "sell stock 0323"); 20 | // 12月份的几笔账目 21 | accounts[0].deposit(Date(2008, 12, 5), 5500, "salary"); 22 | accounts[1].withdraw(Date(2008, 12, 20), 4000, "buy a laptop"); 23 | //结算所有账户并输出各个账户信息 24 | cout << endl; 25 | for (int i = 0; i < n; i++) 26 | { 27 | accounts[i].settle(Date(2009, 1, 1)); 28 | accounts[i].show(); 29 | cout << endl; 30 | } 31 | cout << "Total: " << SavingsAccount::getTotal() << endl; 32 | //cout << SavingsAccount::getTotal() < 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /Bank/bank3/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Bank/bank3/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Bank/bank3/Account.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "Account.h" 6 | #include 7 | #include 8 | 9 | double Account::total = 0; 10 | 11 | Account::Account(Date date, std::string id) : id(id){ 12 | } 13 | 14 | Account::~Account() = default; 15 | 16 | void Account::record(Date date, double amount, std::string desc) { 17 | amount = floor(amount * 100 + 0.5) / 100; //保留小数点后两位 18 | balance += amount; 19 | total += amount; 20 | cout << date << "\t#" << id << "\t" << amount << "\t" << balance << "\t" << desc << endl; 21 | } 22 | 23 | std::string Account::getId() const{ 24 | return this->id; 25 | } 26 | 27 | double Account::getBalance() const{ 28 | return this->balance; 29 | } 30 | 31 | double Account::getTotal() { 32 | return total; 33 | } 34 | 35 | void Account::show() const { 36 | cout << id << "\tBalance: " << balance; 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /Bank/bank3/Account.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_ACCOUNT_H 6 | #define BANK3_ACCOUNT_H 7 | 8 | #include "string" 9 | #include "date.h" 10 | 11 | class Account { 12 | protected: 13 | std::string id; 14 | double balance; 15 | static double total; 16 | public: 17 | Account(Date date, std::string id); 18 | ~Account(); 19 | void record(Date date, double amount, std::string desc); // 记录balance变化 20 | //const error(string msg); 21 | std::string getId() const; 22 | double getBalance() const; 23 | void show() const; 24 | static double getTotal(); 25 | }; 26 | 27 | 28 | #endif //BANK3_ACCOUNT_H 29 | -------------------------------------------------------------------------------- /Bank/bank3/Accumulator.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "Accumulator.h" 6 | #include 7 | using namespace std; 8 | 9 | Accumulator::Accumulator(Date date, double value): lastDate(date), value(value), sum(0){} 10 | 11 | const double Accumulator::getSum(Date date) { 12 | double a = sum + value * (date - this->lastDate); 13 | //cout << date - this->lastDate << endl ; 14 | //cout << endl << a << endl; 15 | return a; 16 | } 17 | 18 | void Accumulator::change(Date date, double value) { 19 | sum = getSum(date); 20 | lastDate = date; 21 | this->value = value; 22 | } 23 | 24 | void Accumulator::reset(Date date, double value) { 25 | lastDate = date; 26 | this->value = value; 27 | sum = 0; 28 | } 29 | 30 | Accumulator::~Accumulator() = default; 31 | -------------------------------------------------------------------------------- /Bank/bank3/Accumulator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_ACCUMULATOR_H 6 | #define BANK3_ACCUMULATOR_H 7 | #include "date.h" 8 | 9 | class Accumulator { 10 | private: 11 | Date lastDate; //上次变更值的日子 12 | double value; //余额或者欠款 13 | double sum; //余额或欠款累加 14 | public: 15 | Accumulator(Date date, double value); 16 | ~Accumulator(); 17 | const double getSum(Date date); 18 | void change(Date date, double value); 19 | void reset(Date date, double value); 20 | }; 21 | 22 | 23 | #endif //BANK3_ACCUMULATOR_H 24 | -------------------------------------------------------------------------------- /Bank/bank3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | project(bank3) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(bank3 7 | date.cpp date.h 8 | Account.cpp Account.h 9 | SavingsAccount.cpp SavingsAccount.h 10 | Accumulator.cpp Accumulator.h 11 | CreditAccount.cpp CreditAccount.h 12 | step_3.cpp) 13 | -------------------------------------------------------------------------------- /Bank/bank3/CreditAccount.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "CreditAccount.h" 6 | #include "iostream" 7 | using namespace std; 8 | 9 | CreditAccount::CreditAccount(Date date, std::string id, double credit, double rate, double fee): 10 | Account(date, id), acc(date, 0), credit(credit), rate(rate), fee(fee) { 11 | cout << date << "\t#" << id << " created" << endl; 12 | } 13 | 14 | double CreditAccount::getRate() const{ 15 | return this->rate; 16 | } 17 | 18 | double CreditAccount::getCredit() const{ 19 | return this->credit; 20 | } 21 | 22 | double CreditAccount::getFee() const { 23 | return this->fee; 24 | } 25 | 26 | double CreditAccount::getAvailableCredit() const { 27 | if(balance > 0) return credit; 28 | else return credit + balance; 29 | } 30 | 31 | void CreditAccount::deposit(Date date, double amount, std::string desc) { 32 | record(date, amount, desc); 33 | acc.change(date, getDebt()); 34 | } 35 | 36 | void CreditAccount::withdraw(Date date, double amount, std::string desc) { 37 | if(amount + getBalance() > credit){ 38 | //todo 39 | } 40 | else { 41 | record(date, -amount, desc); 42 | acc.change(date, getDebt()); 43 | } 44 | } 45 | 46 | void CreditAccount::settle(Date date) { 47 | double interest = acc.getSum(date) * rate; 48 | //cout << interest << endl; 49 | if(interest != 0){ 50 | record(date, interest, "interest"); 51 | } 52 | if(date.getMonth() == 1){ 53 | record(date, -fee, "annual fee"); 54 | } 55 | acc.reset(date, getDebt()); 56 | } 57 | 58 | double CreditAccount::getDebt() const { 59 | //cout << balance << endl; 60 | if(balance < 0) return balance; 61 | else return 0; 62 | } 63 | 64 | void CreditAccount::show() const { 65 | Account::show(); 66 | cout << "\t" << "Available credit: " << getAvailableCredit(); 67 | } 68 | 69 | CreditAccount::~CreditAccount() = default;; -------------------------------------------------------------------------------- /Bank/bank3/CreditAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_CREDITACCOUNT_H 6 | #define BANK3_CREDITACCOUNT_H 7 | #include "string" 8 | #include "Account.h" 9 | #include "Accumulator.h" 10 | 11 | class CreditAccount : public Account{ 12 | private: 13 | Accumulator acc; 14 | double credit; 15 | double rate; 16 | double fee; 17 | public: 18 | CreditAccount(Date date, std::string id, double credit, double rate, double fee); 19 | ~CreditAccount(); 20 | double getDebt() const; 21 | double getCredit() const; 22 | double getRate() const; 23 | double getFee() const; 24 | double getAvailableCredit() const; 25 | void deposit(Date date, double amount, std::string desc); 26 | void withdraw(Date date, double amount, std::string desc); 27 | void settle(Date date); 28 | void show() const; 29 | }; 30 | 31 | 32 | #endif //BANK3_CREDITACCOUNT_H 33 | -------------------------------------------------------------------------------- /Bank/bank3/SavingsAccount.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "SavingsAccount.h" 6 | #include "Accumulator.h" 7 | #include "iostream" 8 | using namespace std; 9 | 10 | SavingsAccount::SavingsAccount(Date date, std::string id, double rate) : Account(date, id), acc(date, 0), rate(rate) { 11 | cout << date << "\t#" << id << " created" << endl; 12 | } 13 | 14 | void SavingsAccount::deposit(Date date, double amount, std::string desc) { 15 | record(date, amount, desc); 16 | acc.change(date, getBalance()); 17 | } 18 | 19 | void SavingsAccount::withdraw(Date date, double amount, std::string desc) { 20 | if(amount <= getBalance()) { 21 | record(date, -amount, desc); 22 | acc.change(date, getBalance()); 23 | } 24 | } 25 | 26 | double SavingsAccount::getRate() const{ 27 | return this->rate; 28 | } 29 | 30 | void SavingsAccount::settle(Date date) { 31 | double a = acc.getSum(date); 32 | int days = (date - Date(date.getYear() - 1, 1, 1)) + 1; 33 | double interest = a * rate / days; 34 | //cout << days << endl; 35 | //cout << a << endl; 36 | // cout << interest << endl; 37 | record(date, interest, "interest"); 38 | acc.change(date, interest); 39 | acc.reset(date, getBalance()); 40 | } 41 | 42 | -------------------------------------------------------------------------------- /Bank/bank3/SavingsAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_SAVINGSACCOUNT_H 6 | #define BANK3_SAVINGSACCOUNT_H 7 | 8 | #include 9 | #include "Account.h" 10 | #include "Accumulator.h" 11 | 12 | class SavingsAccount :public Account{ 13 | private: 14 | Accumulator acc; 15 | double rate; 16 | public: 17 | SavingsAccount(Date date, std::string id, double rate); 18 | double getRate() const; 19 | void deposit(Date date, double amount, std::string desc); 20 | void withdraw(Date date, double amount, std::string desc); 21 | void settle(Date date); 22 | }; 23 | 24 | 25 | #endif //BANK3_SAVINGSACCOUNT_H 26 | -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/.cmake/api/v1/query/cache-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/.cmake/api/v1/query/cache-v2 -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/.cmake/api/v1/query/codemodel-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/.cmake/api/v1/query/toolchains-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-f68c509b912e9638cf9f.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations" : 3 | [ 4 | { 5 | "directories" : 6 | [ 7 | { 8 | "build" : ".", 9 | "jsonFile" : "directory-.-Debug-f5ebdc15457944623624.json", 10 | "minimumCMakeVersion" : 11 | { 12 | "string" : "3.21" 13 | }, 14 | "projectIndex" : 0, 15 | "source" : ".", 16 | "targetIndexes" : 17 | [ 18 | 0 19 | ] 20 | } 21 | ], 22 | "name" : "Debug", 23 | "projects" : 24 | [ 25 | { 26 | "directoryIndexes" : 27 | [ 28 | 0 29 | ], 30 | "name" : "bank3", 31 | "targetIndexes" : 32 | [ 33 | 0 34 | ] 35 | } 36 | ], 37 | "targets" : 38 | [ 39 | { 40 | "directoryIndex" : 0, 41 | "id" : "bank3::@6890427a1f51a3e7e1df", 42 | "jsonFile" : "target-bank3-Debug-c7e52aa5204a94fd35d8.json", 43 | "name" : "bank3", 44 | "projectIndex" : 0 45 | } 46 | ] 47 | } 48 | ], 49 | "kind" : "codemodel", 50 | "paths" : 51 | { 52 | "build" : "/Users/cakeal/Desktop/class/bank3/cmake-build-debug", 53 | "source" : "/Users/cakeal/Desktop/class/bank3" 54 | }, 55 | "version" : 56 | { 57 | "major" : 2, 58 | "minor" : 3 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json: -------------------------------------------------------------------------------- 1 | { 2 | "backtraceGraph" : 3 | { 4 | "commands" : [], 5 | "files" : [], 6 | "nodes" : [] 7 | }, 8 | "installers" : [], 9 | "paths" : 10 | { 11 | "build" : ".", 12 | "source" : "." 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/.ninja_deps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/.ninja_deps -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/3.21.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Darwin-21.6.0") 2 | set(CMAKE_HOST_SYSTEM_NAME "Darwin") 3 | set(CMAKE_HOST_SYSTEM_VERSION "21.6.0") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Darwin-21.6.0") 9 | set(CMAKE_SYSTEM_NAME "Darwin") 10 | set(CMAKE_SYSTEM_VERSION "21.6.0") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/CMakeError.log: -------------------------------------------------------------------------------- 1 | Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. 2 | Compiler: /Library/Developer/CommandLineTools/usr/bin/cc 3 | Build flags: 4 | Id flags: 5 | 6 | The output was: 7 | 1 8 | ld: library not found for -lSystem 9 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 10 | 11 | 12 | Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. 13 | Compiler: /Library/Developer/CommandLineTools/usr/bin/c++ 14 | Build flags: 15 | Id flags: 16 | 17 | The output was: 18 | 1 19 | ld: library not found for -lc++ 20 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 21 | 22 | 23 | -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /Users/cakeal/Desktop/class/bank3/cmake-build-debug/CMakeFiles/rebuild_cache.dir 2 | /Users/cakeal/Desktop/class/bank3/cmake-build-debug/CMakeFiles/edit_cache.dir 3 | /Users/cakeal/Desktop/class/bank3/cmake-build-debug/CMakeFiles/bank3.dir 4 | -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/Account.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/Account.cpp.o -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/Accumulator.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/Accumulator.cpp.o -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/CreditAccount.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/CreditAccount.cpp.o -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/SavingsAccount.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/SavingsAccount.cpp.o -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/date.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/date.cpp.o -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/step_3.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/CMakeFiles/bank3.dir/step_3.cpp.o -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/clion-environment.txt: -------------------------------------------------------------------------------- 1 | ToolSet: 1.0 (local)Options: 2 | 3 | Options:-DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/clion-log.txt: -------------------------------------------------------------------------------- 1 | /Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -G Ninja /Users/cakeal/Desktop/class/bank3 2 | -- Configuring done 3 | -- Generating done 4 | -- Build files have been written to: /Users/cakeal/Desktop/class/bank3/cmake-build-debug 5 | -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/Testing/Temporary/LastTest.log: -------------------------------------------------------------------------------- 1 | Start testing: Sep 23 18:35 CST 2 | ---------------------------------------------------------- 3 | End testing: Sep 23 18:35 CST 4 | -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/bank3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank3/cmake-build-debug/bank3 -------------------------------------------------------------------------------- /Bank/bank3/cmake-build-debug/cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /Users/cakeal/Desktop/class/bank3 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr/local") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "Debug") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Is this installation the result of a crosscompile? 31 | if(NOT DEFINED CMAKE_CROSSCOMPILING) 32 | set(CMAKE_CROSSCOMPILING "FALSE") 33 | endif() 34 | 35 | # Set default install directory permissions. 36 | if(NOT DEFINED CMAKE_OBJDUMP) 37 | set(CMAKE_OBJDUMP "/Library/Developer/CommandLineTools/usr/bin/objdump") 38 | endif() 39 | 40 | if(CMAKE_INSTALL_COMPONENT) 41 | set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") 42 | else() 43 | set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") 44 | endif() 45 | 46 | string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT 47 | "${CMAKE_INSTALL_MANIFEST_FILES}") 48 | file(WRITE "/Users/cakeal/Desktop/class/bank3/cmake-build-debug/${CMAKE_INSTALL_MANIFEST}" 49 | "${CMAKE_INSTALL_MANIFEST_CONTENT}") 50 | -------------------------------------------------------------------------------- /Bank/bank3/date.cpp: -------------------------------------------------------------------------------- 1 | #include "date.h" 2 | 3 | Date::Date(int year, int month, int day):year(year), month(month), day(day) 4 | { 5 | totalDays = distance(); 6 | } 7 | 8 | Date::~Date() 9 | = default; 10 | 11 | //用于转换年月日为为1900年1月1日距今多少天 12 | int Date::distance() const 13 | { 14 | int the_days_form_the_begin = 0; 15 | int days_in_month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 16 | the_days_form_the_begin += (year - 1900) * 365 + (year - 1900) / 4 - (year - 1900) / 100 + (year - 1900 + 300) / 400; 17 | for(int i = 1; i < month; i++){ 18 | the_days_form_the_begin += days_in_month[i]; 19 | } 20 | if(month > 2) the_days_form_the_begin += (int)((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)); 21 | the_days_form_the_begin += day - 1; 22 | if(month == 1 && day == 1) the_days_form_the_begin++; 23 | // cout<totalDays - d.totalDays; 29 | } 30 | 31 | int Date::getYear() const { 32 | return this->year; 33 | } 34 | 35 | int Date::getMonth() const{ 36 | return this->month; 37 | } 38 | 39 | int Date::getDay() const{ 40 | return this->day; 41 | } 42 | 43 | bool Date::isLeapYear() const{ 44 | return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)); 45 | } 46 | 47 | int Date::getTotalDays() const{ 48 | return this->totalDays; 49 | } 50 | 51 | ostream &operator<<(ostream &out, Date &date) { 52 | return out << date.year << "-" << date.month << "-" << date.day; 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /Bank/bank3/date.h: -------------------------------------------------------------------------------- 1 | #ifndef __Date__ 2 | #define __Date__ 3 | 4 | #include "iostream" 5 | using namespace std; 6 | class Date; 7 | 8 | class Date 9 | { 10 | private: 11 | int year, month, day; 12 | int totalDays; // 从1900年1月1日开始 13 | public: 14 | Date(int year, int month, int day); 15 | ~Date(); 16 | int getYear() const; 17 | int getMonth() const; 18 | int getDay() const; 19 | bool isLeapYear() const; 20 | int getTotalDays() const; 21 | int distance() const; //获得从1900年1月1日距今多少天 22 | int operator - (const Date &d) const; //重载运算符,前面的减去后面的 23 | friend ostream & operator<<(ostream &out, Date &date); //cout << date 24 | }; 25 | 26 | #endif -------------------------------------------------------------------------------- /Bank/bank3/step_3.cpp: -------------------------------------------------------------------------------- 1 | //step3.cpp 2 | #include "SavingsAccount.h" 3 | #include "CreditAccount.h" 4 | #include "date.h" 5 | #include 6 | using namespace std; 7 | 8 | int main() { 9 | Date date(2008, 11, 1); //起始日期 10 | //建立几个账户 11 | SavingsAccount sa1(date, "S3755217", 0.015); 12 | SavingsAccount sa2(date, "02342342", 0.015); 13 | CreditAccount ca(date, "C5392394", 10000, 0.0005, 50); 14 | //11月份的几笔账目 15 | sa1.deposit(Date(2008, 11, 5), 5000, "salary"); 16 | ca.withdraw(Date(2008, 11, 15), 2000, "buy a cell"); 17 | sa2.deposit(Date(2008, 11, 25), 10000, "sell stock 0323"); 18 | //结算信用卡 19 | ca.settle(Date(2008, 12, 1)); 20 | //12月份的几笔账目 21 | ca.deposit(Date(2008, 12, 1), 2016, "repay the credit"); 22 | sa1.deposit(Date(2008, 12, 5), 5500, "salary"); 23 | //结算所有账户 24 | sa1.settle(Date(2009, 1, 1)); 25 | sa2.settle(Date(2009, 1, 1)); 26 | ca.settle(Date(2009, 1, 1)); 27 | //输出各个账户信息 28 | cout << endl; 29 | sa1.show(); cout << endl; 30 | sa2.show(); cout << endl; 31 | ca.show(); cout << endl; 32 | cout << "Total: " << Account::getTotal() << endl; 33 | return 0; 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /Bank/bank4/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | # 基于编辑器的 HTTP 客户端请求 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /Bank/bank4/.idea/discord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /Bank/bank4/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Bank/bank4/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Bank/bank4/Account.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "Account.h" 6 | #include 7 | #include 8 | 9 | double Account::total = 0; 10 | 11 | Account::Account(Date date, std::string id) : id(id), balance(0){ 12 | } 13 | 14 | Account::~Account() = default; 15 | 16 | void Account::record(Date date, double amount, std::string desc) { 17 | amount = floor(amount * 100 + 0.5) / 100; //保留小数点后两位 18 | balance += amount; 19 | total += amount; 20 | cout << date << "\t#" << id << "\t" << amount << "\t" << balance << "\t" << desc << endl; 21 | } 22 | 23 | std::string Account::getId() const{ 24 | return this->id; 25 | } 26 | 27 | double Account::getBalance() const{ 28 | return this->balance; 29 | } 30 | 31 | double Account::getTotal() { 32 | return total; 33 | } 34 | 35 | void Account::show() const { 36 | cout << id << "\tBalance: " << balance; 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /Bank/bank4/Account.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_ACCOUNT_H 6 | #define BANK3_ACCOUNT_H 7 | 8 | #include "string" 9 | #include "date.h" 10 | 11 | class Account { 12 | protected: 13 | std::string id; 14 | double balance; 15 | static double total; 16 | public: 17 | Account(Date date, std::string id); 18 | ~Account(); 19 | void record(Date date, double amount, std::string desc); // 记录balance变化 20 | //const error(string msg); 21 | std::string getId() const; 22 | double getBalance() const; 23 | virtual void show() const; 24 | virtual void deposit(Date date, double amount, std::string desc) = 0; 25 | virtual void withdraw(Date date, double amount, std::string desc) = 0; 26 | virtual void settle(Date date) = 0; 27 | static double getTotal(); 28 | }; 29 | 30 | 31 | #endif //BANK3_ACCOUNT_H 32 | -------------------------------------------------------------------------------- /Bank/bank4/Accumulator.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "Accumulator.h" 6 | #include 7 | using namespace std; 8 | 9 | Accumulator::Accumulator(Date date, double value): lastDate(date), value(value), sum(0){} 10 | 11 | const double Accumulator::getSum(Date date) { 12 | double a = sum + value * (date - this->lastDate); 13 | //cout << date - this->lastDate << endl ; 14 | //cout << endl << a << endl; 15 | return a; 16 | } 17 | 18 | void Accumulator::change(Date date, double value) { 19 | sum = getSum(date); 20 | lastDate = date; 21 | this->value = value; 22 | } 23 | 24 | void Accumulator::reset(Date date, double value) { 25 | lastDate = date; 26 | this->value = value; 27 | sum = 0; 28 | } 29 | 30 | Accumulator::~Accumulator() = default; 31 | -------------------------------------------------------------------------------- /Bank/bank4/Accumulator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_ACCUMULATOR_H 6 | #define BANK3_ACCUMULATOR_H 7 | #include "date.h" 8 | 9 | class Accumulator { 10 | private: 11 | Date lastDate; //上次变更值的日子 12 | double value; //余额或者欠款 13 | double sum; //余额或欠款累加 14 | public: 15 | Accumulator(Date date, double value); 16 | ~Accumulator(); 17 | const double getSum(Date date); 18 | void change(Date date, double value); 19 | void reset(Date date, double value); 20 | }; 21 | 22 | 23 | #endif //BANK3_ACCUMULATOR_H 24 | -------------------------------------------------------------------------------- /Bank/bank4/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | project(bank4) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(bank4 7 | date.cpp date.h 8 | Account.cpp Account.h 9 | SavingsAccount.cpp SavingsAccount.h 10 | Accumulator.cpp Accumulator.h 11 | CreditAccount.cpp CreditAccount.h 12 | step_4.cpp) 13 | -------------------------------------------------------------------------------- /Bank/bank4/CreditAccount.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "CreditAccount.h" 6 | #include "iostream" 7 | using namespace std; 8 | 9 | CreditAccount::CreditAccount(Date date, std::string id, double credit, double rate, double fee): 10 | Account(date, id), acc(date, 0), credit(credit), rate(rate), fee(fee) { 11 | cout << date << "\t#" << id << " created" << endl; 12 | } 13 | 14 | double CreditAccount::getRate() const{ 15 | return this->rate; 16 | } 17 | 18 | double CreditAccount::getCredit() const{ 19 | return this->credit; 20 | } 21 | 22 | double CreditAccount::getFee() const { 23 | return this->fee; 24 | } 25 | 26 | double CreditAccount::getAvailableCredit() const { 27 | if(balance > 0) return credit; 28 | else return credit + balance; 29 | } 30 | 31 | void CreditAccount::deposit(Date date, double amount, std::string desc) { 32 | record(date, amount, desc); 33 | acc.change(date, getDebt()); 34 | } 35 | 36 | void CreditAccount::withdraw(Date date, double amount, std::string desc) { 37 | if(amount + getBalance() > credit){ 38 | //todo 39 | } 40 | else { 41 | record(date, -amount, desc); 42 | acc.change(date, getDebt()); 43 | } 44 | } 45 | 46 | void CreditAccount::settle(Date date) { 47 | double interest = acc.getSum(date) * rate; 48 | //cout << interest << endl; 49 | if(interest != 0){ 50 | record(date, interest, "interest"); 51 | } 52 | if(date.getMonth() == 1){ 53 | record(date, -fee, "annual fee"); 54 | } 55 | acc.reset(date, getDebt()); 56 | } 57 | 58 | double CreditAccount::getDebt() const { 59 | //cout << balance << endl; 60 | if(balance < 0) return balance; 61 | else return 0; 62 | } 63 | 64 | void CreditAccount::show() const { 65 | Account::show(); 66 | cout << "\t" << "Available credit: " << getAvailableCredit(); 67 | } 68 | 69 | CreditAccount::~CreditAccount() = default;; -------------------------------------------------------------------------------- /Bank/bank4/CreditAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_CREDITACCOUNT_H 6 | #define BANK3_CREDITACCOUNT_H 7 | #include "string" 8 | #include "Account.h" 9 | #include "Accumulator.h" 10 | 11 | class CreditAccount : public Account{ 12 | private: 13 | Accumulator acc; 14 | double credit; 15 | double rate; 16 | double fee; 17 | public: 18 | CreditAccount(Date date, std::string id, double credit, double rate, double fee); 19 | ~CreditAccount(); 20 | double getDebt() const; 21 | double getCredit() const; 22 | double getRate() const; 23 | double getFee() const; 24 | double getAvailableCredit() const; 25 | void deposit(Date date, double amount, std::string desc) override; 26 | void withdraw(Date date, double amount, std::string desc) override; 27 | void settle(Date date) override; 28 | void show() const override; 29 | }; 30 | 31 | 32 | #endif //BANK3_CREDITACCOUNT_H 33 | -------------------------------------------------------------------------------- /Bank/bank4/SavingsAccount.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "SavingsAccount.h" 6 | #include "Accumulator.h" 7 | #include "iostream" 8 | using namespace std; 9 | 10 | SavingsAccount::SavingsAccount(Date date, std::string id, double rate) : Account(date, id), acc(date, 0), rate(rate) { 11 | cout << date << "\t#" << id << " created" << endl; 12 | } 13 | 14 | void SavingsAccount::deposit(Date date, double amount, std::string desc) { 15 | record(date, amount, desc); 16 | acc.change(date, getBalance()); 17 | } 18 | 19 | void SavingsAccount::withdraw(Date date, double amount, std::string desc) { 20 | if(amount <= getBalance()) { 21 | record(date, -amount, desc); 22 | acc.change(date, getBalance()); 23 | } 24 | } 25 | 26 | double SavingsAccount::getRate() const{ 27 | return this->rate; 28 | } 29 | 30 | void SavingsAccount::settle(Date date) { 31 | if(date.getMonth() != 1) return; 32 | double a = acc.getSum(date); 33 | int days = (date - Date(date.getYear() - 1, 1, 1)) + 1; 34 | double interest = a * rate / days; 35 | //cout << days << endl; 36 | //cout << a << endl; 37 | // cout << interest << endl; 38 | record(date, interest, "interest"); 39 | acc.change(date, interest); 40 | acc.reset(date, getBalance()); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /Bank/bank4/SavingsAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_SAVINGSACCOUNT_H 6 | #define BANK3_SAVINGSACCOUNT_H 7 | 8 | #include 9 | #include "Account.h" 10 | #include "Accumulator.h" 11 | 12 | class SavingsAccount :public Account{ 13 | private: 14 | Accumulator acc; 15 | double rate; 16 | public: 17 | SavingsAccount(Date date, std::string id, double rate); 18 | double getRate() const; 19 | void deposit(Date date, double amount, std::string desc) override; 20 | void withdraw(Date date, double amount, std::string desc) override; 21 | void settle(Date date) override; 22 | }; 23 | 24 | 25 | #endif //BANK3_SAVINGSACCOUNT_H 26 | -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/.cmake/api/v1/query/cache-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/.cmake/api/v1/query/cache-v2 -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/.cmake/api/v1/query/codemodel-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/.cmake/api/v1/query/toolchains-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-c51d1cce3aad8e85aa58.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations" : 3 | [ 4 | { 5 | "directories" : 6 | [ 7 | { 8 | "build" : ".", 9 | "jsonFile" : "directory-.-Debug-f5ebdc15457944623624.json", 10 | "minimumCMakeVersion" : 11 | { 12 | "string" : "3.21" 13 | }, 14 | "projectIndex" : 0, 15 | "source" : ".", 16 | "targetIndexes" : 17 | [ 18 | 0 19 | ] 20 | } 21 | ], 22 | "name" : "Debug", 23 | "projects" : 24 | [ 25 | { 26 | "directoryIndexes" : 27 | [ 28 | 0 29 | ], 30 | "name" : "bank4", 31 | "targetIndexes" : 32 | [ 33 | 0 34 | ] 35 | } 36 | ], 37 | "targets" : 38 | [ 39 | { 40 | "directoryIndex" : 0, 41 | "id" : "bank4::@6890427a1f51a3e7e1df", 42 | "jsonFile" : "target-bank4-Debug-617c77a44c50f8f69830.json", 43 | "name" : "bank4", 44 | "projectIndex" : 0 45 | } 46 | ] 47 | } 48 | ], 49 | "kind" : "codemodel", 50 | "paths" : 51 | { 52 | "build" : "/Users/cakeal/Desktop/程设2/bank4/cmake-build-debug", 53 | "source" : "/Users/cakeal/Desktop/程设2/bank4" 54 | }, 55 | "version" : 56 | { 57 | "major" : 2, 58 | "minor" : 3 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json: -------------------------------------------------------------------------------- 1 | { 2 | "backtraceGraph" : 3 | { 4 | "commands" : [], 5 | "files" : [], 6 | "nodes" : [] 7 | }, 8 | "installers" : [], 9 | "paths" : 10 | { 11 | "build" : ".", 12 | "source" : "." 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/.ninja_deps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/.ninja_deps -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/.ninja_log: -------------------------------------------------------------------------------- 1 | # ninja log v5 2 | 6 1658 1663828697294880420 CMakeFiles/bank4.dir/Accumulator.cpp.o 11bc876320f50852 3 | 736 804 1663771538342704700 bank3 9e0f6c34e9a43895 4 | 4 1674 1663828697318703211 CMakeFiles/bank4.dir/date.cpp.o 632bf93843c293d6 5 | 1 130 1664446310027939280 build.ninja ac24160b2debe197 6 | 4 847 1663829879332358018 CMakeFiles/bank4.dir/step_4.cpp.o 75e223df57d11c18 7 | 1034 1139 1663830181020052832 bank4 1b76bbb5838a6286 8 | 4 1034 1663830180909473483 CMakeFiles/bank4.dir/SavingsAccount.cpp.o 80635a58081ec43a 9 | 4 844 1663829879327911383 CMakeFiles/bank4.dir/Account.cpp.o 8395d60e6ca61560 10 | 7 1695 1663828697342946611 CMakeFiles/bank4.dir/CreditAccount.cpp.o 54fa3449fa2ee70a 11 | 5 1124 1664446317040313741 CMakeFiles/bank4.dir/Accumulator.cpp.o a4b85fd9fafd18f3 12 | 3 1135 1664446317050078226 CMakeFiles/bank4.dir/date.cpp.o 78b2248a5fd99404 13 | 3 1140 1664446317053913844 CMakeFiles/bank4.dir/Account.cpp.o 28eb6496ff7c9d57 14 | 5 1143 1664446317058245370 CMakeFiles/bank4.dir/CreditAccount.cpp.o 273933e8054a17e9 15 | 4 1144 1664446317057341845 CMakeFiles/bank4.dir/SavingsAccount.cpp.o 114d4e738882e1bf 16 | 6 1148 1664446317066307843 CMakeFiles/bank4.dir/step_4.cpp.o 91ed47089043d916 17 | 1148 1215 1664446317136989867 bank4 1b76bbb5838a6286 18 | -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/3.21.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Darwin-21.6.0") 2 | set(CMAKE_HOST_SYSTEM_NAME "Darwin") 3 | set(CMAKE_HOST_SYSTEM_VERSION "21.6.0") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Darwin-21.6.0") 9 | set(CMAKE_SYSTEM_NAME "Darwin") 10 | set(CMAKE_SYSTEM_VERSION "21.6.0") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/CMakeError.log: -------------------------------------------------------------------------------- 1 | Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. 2 | Compiler: /Library/Developer/CommandLineTools/usr/bin/cc 3 | Build flags: 4 | Id flags: 5 | 6 | The output was: 7 | 1 8 | ld: library not found for -lSystem 9 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 10 | 11 | 12 | Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. 13 | Compiler: /Library/Developer/CommandLineTools/usr/bin/c++ 14 | Build flags: 15 | Id flags: 16 | 17 | The output was: 18 | 1 19 | ld: library not found for -lc++ 20 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 21 | 22 | 23 | -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /Users/cakeal/Desktop/程设2/bank4/cmake-build-debug/CMakeFiles/rebuild_cache.dir 2 | /Users/cakeal/Desktop/程设2/bank4/cmake-build-debug/CMakeFiles/edit_cache.dir 3 | /Users/cakeal/Desktop/程设2/bank4/cmake-build-debug/CMakeFiles/bank4.dir 4 | -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/Account.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/Account.cpp.o -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/Accumulator.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/Accumulator.cpp.o -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/CreditAccount.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/CreditAccount.cpp.o -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/SavingsAccount.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/SavingsAccount.cpp.o -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/date.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/date.cpp.o -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/step_4.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/CMakeFiles/bank4.dir/step_4.cpp.o -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/clion-environment.txt: -------------------------------------------------------------------------------- 1 | ToolSet: 1.0 (local)Options: 2 | 3 | Options:-DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/clion-log.txt: -------------------------------------------------------------------------------- 1 | /Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -G Ninja /Users/cakeal/Desktop/程设2/bank4 2 | -- The C compiler identification is AppleClang 14.0.0.14000029 3 | -- The CXX compiler identification is AppleClang 14.0.0.14000029 4 | -- Detecting C compiler ABI info 5 | -- Detecting C compiler ABI info - done 6 | -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped 7 | -- Detecting C compile features 8 | -- Detecting C compile features - done 9 | -- Detecting CXX compiler ABI info 10 | -- Detecting CXX compiler ABI info - done 11 | -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped 12 | -- Detecting CXX compile features 13 | -- Detecting CXX compile features - done 14 | -- Configuring done 15 | -- Generating done 16 | -- Build files have been written to: /Users/cakeal/Desktop/程设2/bank4/cmake-build-debug 17 | -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/Testing/Temporary/LastTest.log: -------------------------------------------------------------------------------- 1 | Start testing: Sep 29 18:12 CST 2 | ---------------------------------------------------------- 3 | End testing: Sep 29 18:12 CST 4 | -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/bank3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/bank3 -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/bank4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank4/cmake-build-debug/bank4 -------------------------------------------------------------------------------- /Bank/bank4/cmake-build-debug/cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /Users/cakeal/Desktop/程设2/bank4 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr/local") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "Debug") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Is this installation the result of a crosscompile? 31 | if(NOT DEFINED CMAKE_CROSSCOMPILING) 32 | set(CMAKE_CROSSCOMPILING "FALSE") 33 | endif() 34 | 35 | # Set default install directory permissions. 36 | if(NOT DEFINED CMAKE_OBJDUMP) 37 | set(CMAKE_OBJDUMP "/Library/Developer/CommandLineTools/usr/bin/objdump") 38 | endif() 39 | 40 | if(CMAKE_INSTALL_COMPONENT) 41 | set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") 42 | else() 43 | set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") 44 | endif() 45 | 46 | string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT 47 | "${CMAKE_INSTALL_MANIFEST_FILES}") 48 | file(WRITE "/Users/cakeal/Desktop/程设2/bank4/cmake-build-debug/${CMAKE_INSTALL_MANIFEST}" 49 | "${CMAKE_INSTALL_MANIFEST_CONTENT}") 50 | -------------------------------------------------------------------------------- /Bank/bank4/date.cpp: -------------------------------------------------------------------------------- 1 | #include "date.h" 2 | 3 | Date::Date(int year, int month, int day):year(year), month(month), day(day) 4 | { 5 | totalDays = distance(); 6 | } 7 | 8 | Date::~Date() 9 | = default; 10 | 11 | //用于转换年月日为为1900年1月1日距今多少天 12 | int Date::distance() const 13 | { 14 | int the_days_form_the_begin = 0; 15 | int days_in_month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 16 | the_days_form_the_begin += (year - 1900) * 365 + (year - 1900) / 4 - (year - 1900) / 100 + (year - 1900 + 300) / 400; 17 | for(int i = 1; i < month; i++){ 18 | the_days_form_the_begin += days_in_month[i]; 19 | } 20 | if(month > 2) the_days_form_the_begin += (int)((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)); 21 | the_days_form_the_begin += day - 1; 22 | if(month == 1 && day == 1) the_days_form_the_begin++; 23 | // cout<totalDays - d.totalDays; 29 | } 30 | 31 | int Date::getYear() const { 32 | return this->year; 33 | } 34 | 35 | int Date::getMonth() const{ 36 | return this->month; 37 | } 38 | 39 | int Date::getDay() const{ 40 | return this->day; 41 | } 42 | 43 | bool Date::isLeapYear() const{ 44 | return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)); 45 | } 46 | 47 | int Date::getTotalDays() const{ 48 | return this->totalDays; 49 | } 50 | 51 | ostream &operator<<(ostream &out, Date &date) { 52 | return out << date.year << "-" << date.month << "-" << date.day; 53 | } 54 | 55 | void Date::show() const { 56 | cout << year << "-" << month << "-" << day; 57 | } 58 | 59 | int Date::getMaxDay() const { 60 | int days_in_month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 61 | return days_in_month[month]; 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /Bank/bank4/date.h: -------------------------------------------------------------------------------- 1 | #ifndef __Date__ 2 | #define __Date__ 3 | 4 | #include "iostream" 5 | using namespace std; 6 | class Date; 7 | 8 | class Date 9 | { 10 | private: 11 | int year, month, day; 12 | int totalDays; // 从1900年1月1日开始 13 | public: 14 | Date(int year, int month, int day); 15 | ~Date(); 16 | int getYear() const; 17 | int getMonth() const; 18 | int getDay() const; 19 | bool isLeapYear() const; 20 | int getTotalDays() const; 21 | int getMaxDay() const; 22 | int distance() const; //获得从1900年1月1日距今多少天 23 | void show() const; 24 | int operator - (const Date &d) const; //重载运算符,前面的减去后面的 25 | friend ostream & operator<<(ostream &out, Date &date); //cout << date 26 | }; 27 | 28 | #endif -------------------------------------------------------------------------------- /Bank/bank5/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | # 基于编辑器的 HTTP 客户端请求 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /Bank/bank5/.idea/discord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /Bank/bank5/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Bank/bank5/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Bank/bank5/Account.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "Account.h" 6 | #include 7 | #include "map" 8 | 9 | double Account::total = 0; 10 | multimap Account::recordMap; 11 | // 类的静态成员变量请记得初始化。 12 | 13 | Account::Account(const Date& date, std::string id) : id(id), balance(0){ 14 | } 15 | 16 | Account::~Account() = default; 17 | 18 | void Account::record(Date date, double amount, const std::string& desc) { 19 | amount = floor(amount * 100 + 0.5) / 100; //保留小数点后两位 20 | balance += amount; 21 | total += amount; 22 | cout << date << "\t#" << id << "\t" << amount << "\t" << balance << "\t" << desc << endl; 23 | recordMap.insert(make_pair(date, AccountRecord(date,this,amount,balance,desc))); 24 | } 25 | 26 | std::string Account::getId() const{ 27 | return this->id; 28 | } 29 | 30 | double Account::getBalance() const{ 31 | return this->balance; 32 | } 33 | 34 | double Account::getTotal() { 35 | return total; 36 | } 37 | 38 | void Account::show() const { 39 | cout << id << "\tBalance: " << balance; 40 | } 41 | 42 | void Account::query(Date &day1, Date &day2) { 43 | for(auto & it : recordMap){ 44 | if(day1 < it.first && it.first getId() << "\t" << it.second.amount << "\t" 46 | << it.second.balance << "\t" << it.second.desc << endl; 47 | } 48 | } 49 | 50 | AccountRecord::AccountRecord(const Date& date, const Account *account, double amount, double balance, std::string desc) 51 | :date(date), account(account), amount(amount), balance(balance), desc(desc){} 52 | -------------------------------------------------------------------------------- /Bank/bank5/Account.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | #ifndef BANK3_ACCOUNT_H 5 | #define BANK3_ACCOUNT_H 6 | 7 | #include "string" 8 | #include "date.h" 9 | #include "map" 10 | using namespace std; 11 | 12 | class AccountRecord; 13 | class Account; 14 | 15 | class Account { 16 | protected: 17 | string id; 18 | double balance; 19 | static double total; 20 | static multimap recordMap; 21 | public: 22 | Account(const Date& date, std::string id); 23 | virtual ~Account(); 24 | void record(Date date, double amount, const string& desc); // 记录balance变化 25 | //const error(string msg); 26 | string getId() const; 27 | double getBalance() const; 28 | virtual void show() const; 29 | virtual void deposit(Date date, double amount, string desc) = 0; 30 | virtual void withdraw(Date date, double amount, string desc) = 0; 31 | virtual void settle(Date date) = 0; 32 | static double getTotal(); 33 | static void query (Date &day1, Date &day2); 34 | }; 35 | 36 | class AccountRecord { // 账目记录 37 | public: 38 | Date date; //日期 39 | const Account *account; //账户 40 | double amount; //金额 41 | double balance; //余额 42 | string desc; //描述 43 | AccountRecord(const Date& date, const Account *account, double amount, double balance, string desc); 44 | 45 | }; 46 | 47 | #endif //BANK3_ACCOUNT_H 48 | -------------------------------------------------------------------------------- /Bank/bank5/Accumulator.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "Accumulator.h" 6 | #include 7 | using namespace std; 8 | 9 | Accumulator::Accumulator(Date date, double value): lastDate(date), value(value), sum(0){} 10 | 11 | const double Accumulator::getSum(Date date) { 12 | double a = sum + value * (date - this->lastDate); 13 | //cout << date - this->lastDate << endl ; 14 | //cout << endl << a << endl; 15 | return a; 16 | } 17 | 18 | void Accumulator::change(Date date, double value) { 19 | sum = getSum(date); 20 | lastDate = date; 21 | this->value = value; 22 | } 23 | 24 | void Accumulator::reset(Date date, double value) { 25 | lastDate = date; 26 | this->value = value; 27 | sum = 0; 28 | } 29 | 30 | Accumulator::~Accumulator() = default; 31 | -------------------------------------------------------------------------------- /Bank/bank5/Accumulator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_ACCUMULATOR_H 6 | #define BANK3_ACCUMULATOR_H 7 | #include "date.h" 8 | 9 | class Accumulator { 10 | private: 11 | Date lastDate; //上次变更值的日子 12 | double value; //余额或者欠款 13 | double sum; //余额或欠款累加 14 | public: 15 | Accumulator(Date date, double value); 16 | ~Accumulator(); 17 | const double getSum(Date date); 18 | void change(Date date, double value); 19 | void reset(Date date, double value); 20 | }; 21 | 22 | 23 | #endif //BANK3_ACCUMULATOR_H 24 | -------------------------------------------------------------------------------- /Bank/bank5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | project(bank5) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(bank5 7 | date.cpp date.h 8 | Account.h Account.cpp 9 | SavingsAccount.cpp SavingsAccount.h 10 | Accumulator.cpp Accumulator.h 11 | CreditAccount.cpp CreditAccount.h 12 | step_5.cpp) 13 | -------------------------------------------------------------------------------- /Bank/bank5/CreditAccount.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "CreditAccount.h" 6 | #include "iostream" 7 | using namespace std; 8 | 9 | CreditAccount::CreditAccount(Date date, std::string id, double credit, double rate, double fee): 10 | Account(date, id), acc(date, 0), credit(credit), rate(rate), fee(fee) { 11 | cout << date << "\t#" << id << " created" << endl; 12 | } 13 | 14 | double CreditAccount::getRate() const{ 15 | return this->rate; 16 | } 17 | 18 | double CreditAccount::getCredit() const{ 19 | return this->credit; 20 | } 21 | 22 | double CreditAccount::getFee() const { 23 | return this->fee; 24 | } 25 | 26 | double CreditAccount::getAvailableCredit() const { 27 | if(balance > 0) return credit; 28 | else return credit + balance; 29 | } 30 | 31 | void CreditAccount::deposit(Date date, double amount, std::string desc) { 32 | record(date, amount, desc); 33 | acc.change(date, getDebt()); 34 | } 35 | 36 | void CreditAccount::withdraw(Date date, double amount, std::string desc) { 37 | if(amount + getBalance() > credit){ 38 | //todo 39 | } 40 | else { 41 | record(date, -amount, desc); 42 | acc.change(date, getDebt()); 43 | } 44 | } 45 | 46 | void CreditAccount::settle(Date date) { 47 | double interest = acc.getSum(date) * rate; 48 | //cout << interest << endl; 49 | if(interest != 0){ 50 | record(date, interest, "interest"); 51 | } 52 | if(date.getMonth() == 1){ 53 | record(date, -fee, "annual fee"); 54 | } 55 | acc.reset(date, getDebt()); 56 | } 57 | 58 | double CreditAccount::getDebt() const { 59 | //cout << balance << endl; 60 | if(balance < 0) return balance; 61 | else return 0; 62 | } 63 | 64 | void CreditAccount::show() const { 65 | Account::show(); 66 | cout << "\t" << "Available credit: " << getAvailableCredit(); 67 | } 68 | 69 | CreditAccount::~CreditAccount() = default;; -------------------------------------------------------------------------------- /Bank/bank5/CreditAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_CREDITACCOUNT_H 6 | #define BANK3_CREDITACCOUNT_H 7 | #include "string" 8 | #include "Account.h" 9 | #include "Accumulator.h" 10 | 11 | class CreditAccount : public Account{ 12 | private: 13 | Accumulator acc; 14 | double credit; 15 | double rate; 16 | double fee; 17 | public: 18 | CreditAccount(Date date, std::string id, double credit, double rate, double fee); 19 | ~CreditAccount(); 20 | double getDebt() const; 21 | double getCredit() const; 22 | double getRate() const; 23 | double getFee() const; 24 | double getAvailableCredit() const; 25 | void deposit(Date date, double amount, std::string desc) override; 26 | void withdraw(Date date, double amount, std::string desc) override; 27 | void settle(Date date) override; 28 | void show() const override; 29 | }; 30 | 31 | 32 | #endif //BANK3_CREDITACCOUNT_H 33 | -------------------------------------------------------------------------------- /Bank/bank5/SavingsAccount.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "SavingsAccount.h" 6 | #include "Accumulator.h" 7 | #include "iostream" 8 | using namespace std; 9 | 10 | SavingsAccount::SavingsAccount(Date date, std::string id, double rate) : Account(date, id), acc(date, 0), rate(rate) { 11 | cout << date << "\t#" << id << " created" << endl; 12 | } 13 | 14 | void SavingsAccount::deposit(Date date, double amount, std::string desc) { 15 | record(date, amount, desc); 16 | acc.change(date, getBalance()); 17 | } 18 | 19 | void SavingsAccount::withdraw(Date date, double amount, std::string desc) { 20 | if(amount <= getBalance()) { 21 | record(date, -amount, desc); 22 | acc.change(date, getBalance()); 23 | } 24 | } 25 | 26 | double SavingsAccount::getRate() const{ 27 | return this->rate; 28 | } 29 | 30 | void SavingsAccount::settle(Date date) { 31 | if(date.getMonth() != 1) return; 32 | double a = acc.getSum(date); 33 | int days = (date - Date(date.getYear() - 1, 1, 1)) + 1; 34 | double interest = a * rate / days; 35 | //cout << days << endl; 36 | //cout << a << endl; 37 | // cout << interest << endl; 38 | record(date, interest, "interest"); 39 | acc.change(date, interest); 40 | acc.reset(date, getBalance()); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /Bank/bank5/SavingsAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_SAVINGSACCOUNT_H 6 | #define BANK3_SAVINGSACCOUNT_H 7 | 8 | #include 9 | #include "Account.h" 10 | #include "Accumulator.h" 11 | 12 | class SavingsAccount :public Account{ 13 | private: 14 | Accumulator acc; 15 | double rate; 16 | public: 17 | SavingsAccount(Date date, std::string id, double rate); 18 | double getRate() const; 19 | void deposit(Date date, double amount, std::string desc) override; 20 | void withdraw(Date date, double amount, std::string desc) override; 21 | void settle(Date date) override; 22 | }; 23 | 24 | 25 | #endif //BANK3_SAVINGSACCOUNT_H 26 | -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/.cmake/api/v1/query/cache-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/.cmake/api/v1/query/cache-v2 -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/.cmake/api/v1/query/codemodel-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/.cmake/api/v1/query/toolchains-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-a3056065330bf3a62973.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations" : 3 | [ 4 | { 5 | "directories" : 6 | [ 7 | { 8 | "build" : ".", 9 | "jsonFile" : "directory-.-Debug-f5ebdc15457944623624.json", 10 | "minimumCMakeVersion" : 11 | { 12 | "string" : "3.21" 13 | }, 14 | "projectIndex" : 0, 15 | "source" : ".", 16 | "targetIndexes" : 17 | [ 18 | 0 19 | ] 20 | } 21 | ], 22 | "name" : "Debug", 23 | "projects" : 24 | [ 25 | { 26 | "directoryIndexes" : 27 | [ 28 | 0 29 | ], 30 | "name" : "bank5", 31 | "targetIndexes" : 32 | [ 33 | 0 34 | ] 35 | } 36 | ], 37 | "targets" : 38 | [ 39 | { 40 | "directoryIndex" : 0, 41 | "id" : "bank5::@6890427a1f51a3e7e1df", 42 | "jsonFile" : "target-bank5-Debug-00c479d5685656b3a2bd.json", 43 | "name" : "bank5", 44 | "projectIndex" : 0 45 | } 46 | ] 47 | } 48 | ], 49 | "kind" : "codemodel", 50 | "paths" : 51 | { 52 | "build" : "/Users/cakeal/Desktop/class/bank5/cmake-build-debug", 53 | "source" : "/Users/cakeal/Desktop/class/bank5" 54 | }, 55 | "version" : 56 | { 57 | "major" : 2, 58 | "minor" : 3 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json: -------------------------------------------------------------------------------- 1 | { 2 | "backtraceGraph" : 3 | { 4 | "commands" : [], 5 | "files" : [], 6 | "nodes" : [] 7 | }, 8 | "installers" : [], 9 | "paths" : 10 | { 11 | "build" : ".", 12 | "source" : "." 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/.ninja_deps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/.ninja_deps -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/3.21.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Darwin-21.6.0") 2 | set(CMAKE_HOST_SYSTEM_NAME "Darwin") 3 | set(CMAKE_HOST_SYSTEM_VERSION "21.6.0") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Darwin-21.6.0") 9 | set(CMAKE_SYSTEM_NAME "Darwin") 10 | set(CMAKE_SYSTEM_VERSION "21.6.0") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/CMakeError.log: -------------------------------------------------------------------------------- 1 | Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. 2 | Compiler: /Library/Developer/CommandLineTools/usr/bin/cc 3 | Build flags: 4 | Id flags: 5 | 6 | The output was: 7 | 1 8 | ld: library not found for -lSystem 9 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 10 | 11 | 12 | Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. 13 | Compiler: /Library/Developer/CommandLineTools/usr/bin/c++ 14 | Build flags: 15 | Id flags: 16 | 17 | The output was: 18 | 1 19 | ld: library not found for -lc++ 20 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 21 | 22 | 23 | -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /Users/cakeal/Desktop/class/bank5/cmake-build-debug/CMakeFiles/rebuild_cache.dir 2 | /Users/cakeal/Desktop/class/bank5/cmake-build-debug/CMakeFiles/edit_cache.dir 3 | /Users/cakeal/Desktop/class/bank5/cmake-build-debug/CMakeFiles/bank5.dir 4 | -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/Account.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/Account.cpp.o -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/Accumulator.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/Accumulator.cpp.o -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/CreditAccount.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/CreditAccount.cpp.o -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/SavingsAccount.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/SavingsAccount.cpp.o -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/date.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/date.cpp.o -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/step_5.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/CMakeFiles/bank5.dir/step_5.cpp.o -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/clion-environment.txt: -------------------------------------------------------------------------------- 1 | ToolSet: 1.0 (local)Options: 2 | 3 | Options:-DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/clion-log.txt: -------------------------------------------------------------------------------- 1 | /Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -G Ninja /Users/cakeal/Desktop/class/bank5 2 | -- Configuring done 3 | -- Generating done 4 | -- Build files have been written to: /Users/cakeal/Desktop/class/bank5/cmake-build-debug 5 | -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/Testing/Temporary/LastTest.log: -------------------------------------------------------------------------------- 1 | Start testing: Sep 23 18:47 CST 2 | ---------------------------------------------------------- 3 | End testing: Sep 23 18:47 CST 4 | -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/bank3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/bank3 -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/bank4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/bank4 -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/bank5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank5/cmake-build-debug/bank5 -------------------------------------------------------------------------------- /Bank/bank5/cmake-build-debug/cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /Users/cakeal/Desktop/class/bank5 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr/local") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "Debug") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Is this installation the result of a crosscompile? 31 | if(NOT DEFINED CMAKE_CROSSCOMPILING) 32 | set(CMAKE_CROSSCOMPILING "FALSE") 33 | endif() 34 | 35 | # Set default install directory permissions. 36 | if(NOT DEFINED CMAKE_OBJDUMP) 37 | set(CMAKE_OBJDUMP "/Library/Developer/CommandLineTools/usr/bin/objdump") 38 | endif() 39 | 40 | if(CMAKE_INSTALL_COMPONENT) 41 | set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") 42 | else() 43 | set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") 44 | endif() 45 | 46 | string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT 47 | "${CMAKE_INSTALL_MANIFEST_FILES}") 48 | file(WRITE "/Users/cakeal/Desktop/class/bank5/cmake-build-debug/${CMAKE_INSTALL_MANIFEST}" 49 | "${CMAKE_INSTALL_MANIFEST_CONTENT}") 50 | -------------------------------------------------------------------------------- /Bank/bank5/date.h: -------------------------------------------------------------------------------- 1 | #ifndef __Date__ 2 | #define __Date__ 3 | 4 | #include "iostream" 5 | using namespace std; 6 | class Date; 7 | 8 | class Date 9 | { 10 | private: 11 | int year, month, day; 12 | int totalDays; // 从1900年1月1日开始 13 | public: 14 | Date() = default; 15 | Date(int year, int month, int day); 16 | ~Date(); 17 | int getYear() const; 18 | int getMonth() const; 19 | int getDay() const; 20 | bool isLeapYear() const; 21 | int getTotalDays() const; 22 | int getMaxDay() const; 23 | int distance() const; //获得从1900年1月1日距今多少天 24 | void show() const; 25 | int operator - (const Date &d) const; //重载运算符,前面的减去后面的 26 | bool operator < (const Date &d) const; 27 | friend ostream & operator<<(ostream &out, Date &date); //cout << date 28 | static Date read(); 29 | }; 30 | 31 | #endif -------------------------------------------------------------------------------- /Bank/bank6/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | # 基于编辑器的 HTTP 客户端请求 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /Bank/bank6/.idea/discord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /Bank/bank6/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Bank/bank6/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Bank/bank6/Account.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "Account.h" 6 | #include 7 | #include "map" 8 | 9 | double Account::total = 0; 10 | multimap Account::recordMap; 11 | // 类的静态成员变量请记得初始化。 12 | 13 | Account::Account(const Date& date, std::string id) : id(id), balance(0){ 14 | } 15 | 16 | Account::~Account() = default; 17 | 18 | void Account::record(Date date, double amount, const std::string& desc) { 19 | amount = floor(amount * 100 + 0.5) / 100; //保留小数点后两位 20 | balance += amount; 21 | total += amount; 22 | cout << date << "\t#" << id << "\t" << amount << "\t" << balance << "\t" << desc << endl; 23 | recordMap.insert(make_pair(date, AccountRecord(date,this,amount,balance,desc))); 24 | } 25 | 26 | std::string Account::getId() const{ 27 | return this->id; 28 | } 29 | 30 | double Account::getBalance() const{ 31 | return this->balance; 32 | } 33 | 34 | double Account::getTotal() { 35 | return total; 36 | } 37 | 38 | void Account::show() const { 39 | cout << id << "\tBalance: " << balance; 40 | } 41 | 42 | void Account::query(Date &day1, Date &day2) { 43 | for(auto & it : recordMap){ 44 | if(day1 < it.first && it.first getId() << "\t" << it.second.amount << "\t" 48 | << it.second.balance << "\t" << it.second.desc << endl; 49 | } 50 | } 51 | 52 | AccountRecord::AccountRecord(const Date& date, const Account *account, double amount, double balance, std::string desc) 53 | :date(date), account(account), amount(amount), balance(balance), desc(desc){} 54 | -------------------------------------------------------------------------------- /Bank/bank6/Account.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | #ifndef BANK3_ACCOUNT_H 5 | #define BANK3_ACCOUNT_H 6 | 7 | #include "string" 8 | #include "date.h" 9 | #include "map" 10 | using namespace std; 11 | 12 | class AccountRecord; 13 | class Account; 14 | 15 | class Account { 16 | protected: 17 | string id; 18 | double balance; 19 | static double total; 20 | static multimap recordMap; 21 | public: 22 | Account(const Date& date, std::string id); 23 | virtual ~Account(); 24 | void record(Date date, double amount, const string& desc); // 记录balance变化 25 | //const error(string msg); 26 | string getId() const; 27 | double getBalance() const; 28 | virtual void show() const; 29 | virtual void deposit(Date date, double amount, string desc) = 0; 30 | virtual void withdraw(Date date, double amount, string desc) = 0; 31 | virtual void settle(Date date) = 0; 32 | static double getTotal(); 33 | static void query (Date &day1, Date &day2); 34 | }; 35 | 36 | class AccountRecord { // 账目记录 37 | public: 38 | Date date; //日期 39 | const Account *account; //账户 40 | double amount; //金额 41 | double balance; //余额 42 | string desc; //描述 43 | AccountRecord(const Date& date, const Account *account, double amount, double balance, string desc); 44 | 45 | }; 46 | 47 | #endif //BANK3_ACCOUNT_H 48 | -------------------------------------------------------------------------------- /Bank/bank6/Accumulator.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "Accumulator.h" 6 | #include 7 | using namespace std; 8 | 9 | Accumulator::Accumulator(Date date, double value): lastDate(date), value(value), sum(0){} 10 | 11 | const double Accumulator::getSum(Date date) { 12 | double a = sum + value * (date - this->lastDate); 13 | //cout << date - this->lastDate << endl ; 14 | //cout << endl << a << endl; 15 | return a; 16 | } 17 | 18 | void Accumulator::change(Date date, double value) { 19 | sum = getSum(date); 20 | lastDate = date; 21 | this->value = value; 22 | } 23 | 24 | void Accumulator::reset(Date date, double value) { 25 | lastDate = date; 26 | this->value = value; 27 | sum = 0; 28 | } 29 | 30 | Accumulator::~Accumulator() = default; 31 | -------------------------------------------------------------------------------- /Bank/bank6/Accumulator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_ACCUMULATOR_H 6 | #define BANK3_ACCUMULATOR_H 7 | #include "date.h" 8 | 9 | class Accumulator { 10 | private: 11 | Date lastDate; //上次变更值的日子 12 | double value; //余额或者欠款 13 | double sum; //余额或欠款累加 14 | public: 15 | Accumulator(Date date, double value); 16 | ~Accumulator(); 17 | const double getSum(Date date); 18 | void change(Date date, double value); 19 | void reset(Date date, double value); 20 | }; 21 | 22 | 23 | #endif //BANK3_ACCUMULATOR_H 24 | -------------------------------------------------------------------------------- /Bank/bank6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | project(bank6) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(bank6 7 | date.cpp date.h 8 | Account.h Account.cpp 9 | SavingsAccount.cpp SavingsAccount.h 10 | Accumulator.cpp Accumulator.h 11 | CreditAccount.cpp CreditAccount.h 12 | step_6.cpp) 13 | -------------------------------------------------------------------------------- /Bank/bank6/CreditAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_CREDITACCOUNT_H 6 | #define BANK3_CREDITACCOUNT_H 7 | #include "string" 8 | #include "Account.h" 9 | #include "Accumulator.h" 10 | 11 | class CreditAccount : public Account{ 12 | private: 13 | Accumulator acc; 14 | double credit; 15 | double rate; 16 | double fee; 17 | public: 18 | CreditAccount(Date date, std::string id, double credit, double rate, double fee); 19 | ~CreditAccount() override; 20 | double getDebt() const; 21 | double getCredit() const; 22 | double getRate() const; 23 | double getFee() const; 24 | double getAvailableCredit() const; 25 | void deposit(Date date, double amount, std::string desc) override; 26 | void withdraw(Date date, double amount, std::string desc) override; 27 | void settle(Date date) override; 28 | void show() const override; 29 | }; 30 | 31 | 32 | #endif //BANK3_CREDITACCOUNT_H 33 | -------------------------------------------------------------------------------- /Bank/bank6/SavingsAccount.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "SavingsAccount.h" 6 | #include "Accumulator.h" 7 | #include "iostream" 8 | using namespace std; 9 | 10 | SavingsAccount::SavingsAccount(Date date, std::string id, double rate) : Account(date, id), acc(date, 0), rate(rate) { 11 | cout << date << "\t#" << id << " created" << endl; 12 | } 13 | 14 | void SavingsAccount::deposit(Date date, double amount, std::string desc) { 15 | record(date, amount, desc); 16 | acc.change(date, getBalance()); 17 | } 18 | 19 | void SavingsAccount::withdraw(Date date, double amount, std::string desc) { 20 | if(amount <= getBalance()) { 21 | record(date, -amount, desc); 22 | acc.change(date, getBalance()); 23 | } 24 | } 25 | 26 | double SavingsAccount::getRate() const{ 27 | return this->rate; 28 | } 29 | 30 | void SavingsAccount::settle(Date date) { 31 | if(date.getMonth() != 1) return; 32 | double a = acc.getSum(date); 33 | int days = (date - Date(date.getYear() - 1, 1, 1)) + 1; 34 | double interest = a * rate / days; 35 | //cout << days << endl; 36 | //cout << a << endl; 37 | // cout << interest << endl; 38 | record(date, interest, "interest"); 39 | acc.change(date, interest); 40 | acc.reset(date, getBalance()); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /Bank/bank6/SavingsAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_SAVINGSACCOUNT_H 6 | #define BANK3_SAVINGSACCOUNT_H 7 | 8 | #include 9 | #include "Account.h" 10 | #include "Accumulator.h" 11 | 12 | class SavingsAccount :public Account{ 13 | private: 14 | Accumulator acc; 15 | double rate; 16 | public: 17 | SavingsAccount(Date date, std::string id, double rate); 18 | double getRate() const; 19 | void deposit(Date date, double amount, std::string desc) override; 20 | void withdraw(Date date, double amount, std::string desc) override; 21 | void settle(Date date) override; 22 | }; 23 | 24 | 25 | #endif //BANK3_SAVINGSACCOUNT_H 26 | -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/.cmake/api/v1/query/cache-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/.cmake/api/v1/query/cache-v2 -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/.cmake/api/v1/query/codemodel-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/.cmake/api/v1/query/toolchains-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-7662594af196df4321ba.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations" : 3 | [ 4 | { 5 | "directories" : 6 | [ 7 | { 8 | "build" : ".", 9 | "jsonFile" : "directory-.-Debug-f5ebdc15457944623624.json", 10 | "minimumCMakeVersion" : 11 | { 12 | "string" : "3.21" 13 | }, 14 | "projectIndex" : 0, 15 | "source" : ".", 16 | "targetIndexes" : 17 | [ 18 | 0 19 | ] 20 | } 21 | ], 22 | "name" : "Debug", 23 | "projects" : 24 | [ 25 | { 26 | "directoryIndexes" : 27 | [ 28 | 0 29 | ], 30 | "name" : "bank6", 31 | "targetIndexes" : 32 | [ 33 | 0 34 | ] 35 | } 36 | ], 37 | "targets" : 38 | [ 39 | { 40 | "directoryIndex" : 0, 41 | "id" : "bank6::@6890427a1f51a3e7e1df", 42 | "jsonFile" : "target-bank6-Debug-b21e929b387aa6f8aa53.json", 43 | "name" : "bank6", 44 | "projectIndex" : 0 45 | } 46 | ] 47 | } 48 | ], 49 | "kind" : "codemodel", 50 | "paths" : 51 | { 52 | "build" : "/Users/cakeal/Desktop/程设2/bank6/cmake-build-debug", 53 | "source" : "/Users/cakeal/Desktop/程设2/bank6" 54 | }, 55 | "version" : 56 | { 57 | "major" : 2, 58 | "minor" : 3 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json: -------------------------------------------------------------------------------- 1 | { 2 | "backtraceGraph" : 3 | { 4 | "commands" : [], 5 | "files" : [], 6 | "nodes" : [] 7 | }, 8 | "installers" : [], 9 | "paths" : 10 | { 11 | "build" : ".", 12 | "source" : "." 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/.ninja_deps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/.ninja_deps -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/CMakeFiles/3.21.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/3.21.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Darwin-21.6.0") 2 | set(CMAKE_HOST_SYSTEM_NAME "Darwin") 3 | set(CMAKE_HOST_SYSTEM_VERSION "21.6.0") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Darwin-21.6.0") 9 | set(CMAKE_SYSTEM_NAME "Darwin") 10 | set(CMAKE_SYSTEM_VERSION "21.6.0") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.o -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.o -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/CMakeError.log: -------------------------------------------------------------------------------- 1 | Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. 2 | Compiler: /Library/Developer/CommandLineTools/usr/bin/cc 3 | Build flags: 4 | Id flags: 5 | 6 | The output was: 7 | 1 8 | ld: library not found for -lSystem 9 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 10 | 11 | 12 | Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. 13 | Compiler: /Library/Developer/CommandLineTools/usr/bin/c++ 14 | Build flags: 15 | Id flags: 16 | 17 | The output was: 18 | 1 19 | ld: library not found for -lc++ 20 | clang: error: linker command failed with exit code 1 (use -v to see invocation) 21 | 22 | 23 | -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /Users/cakeal/Desktop/程设2/bank6/cmake-build-debug/CMakeFiles/rebuild_cache.dir 2 | /Users/cakeal/Desktop/程设2/bank6/cmake-build-debug/CMakeFiles/edit_cache.dir 3 | /Users/cakeal/Desktop/程设2/bank6/cmake-build-debug/CMakeFiles/bank6.dir 4 | -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/Account.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/Account.cpp.o -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/Accumulator.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/Accumulator.cpp.o -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/CreditAccount.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/CreditAccount.cpp.o -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/SavingsAccount.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/SavingsAccount.cpp.o -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/date.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/date.cpp.o -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/step_6.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/CMakeFiles/bank6.dir/step_6.cpp.o -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/clion-environment.txt: -------------------------------------------------------------------------------- 1 | ToolSet: 1.0 (local)Options: 2 | 3 | Options:-DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/clion-log.txt: -------------------------------------------------------------------------------- 1 | /Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -G Ninja /Users/cakeal/Desktop/程设2/bank6 2 | -- The C compiler identification is AppleClang 14.0.0.14000029 3 | -- The CXX compiler identification is AppleClang 14.0.0.14000029 4 | -- Detecting C compiler ABI info 5 | -- Detecting C compiler ABI info - done 6 | -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped 7 | -- Detecting C compile features 8 | -- Detecting C compile features - done 9 | -- Detecting CXX compiler ABI info 10 | -- Detecting CXX compiler ABI info - done 11 | -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped 12 | -- Detecting CXX compile features 13 | -- Detecting CXX compile features - done 14 | -- Configuring done 15 | -- Generating done 16 | -- Build files have been written to: /Users/cakeal/Desktop/程设2/bank6/cmake-build-debug 17 | -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/Testing/Temporary/LastTest.log: -------------------------------------------------------------------------------- 1 | Start testing: Oct 08 20:25 CST 2 | ---------------------------------------------------------- 3 | End testing: Oct 08 20:25 CST 4 | -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/bank3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/bank3 -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/bank4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/bank4 -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/bank5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/bank5 -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/bank6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/bank6/cmake-build-debug/bank6 -------------------------------------------------------------------------------- /Bank/bank6/cmake-build-debug/cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /Users/cakeal/Desktop/程设2/bank6 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr/local") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "Debug") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Is this installation the result of a crosscompile? 31 | if(NOT DEFINED CMAKE_CROSSCOMPILING) 32 | set(CMAKE_CROSSCOMPILING "FALSE") 33 | endif() 34 | 35 | # Set default install directory permissions. 36 | if(NOT DEFINED CMAKE_OBJDUMP) 37 | set(CMAKE_OBJDUMP "/Library/Developer/CommandLineTools/usr/bin/objdump") 38 | endif() 39 | 40 | if(CMAKE_INSTALL_COMPONENT) 41 | set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") 42 | else() 43 | set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") 44 | endif() 45 | 46 | string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT 47 | "${CMAKE_INSTALL_MANIFEST_FILES}") 48 | file(WRITE "/Users/cakeal/Desktop/程设2/bank6/cmake-build-debug/${CMAKE_INSTALL_MANIFEST}" 49 | "${CMAKE_INSTALL_MANIFEST_CONTENT}") 50 | -------------------------------------------------------------------------------- /Bank/bank6/commands3333.txt: -------------------------------------------------------------------------------- 1 | a s S3755217 0.015 2 | a s 02342342 0.015 3 | a c C5392394 10000 0.0005 50 4 | c 5 5 | d 0 5000 salary 6 | c 15 7 | w 2 2000 buy a cell 8 | c 25 9 | d 1 10000 sell stock 0323 10 | n 11 | d 2 2016 repay the credit 12 | c 5 13 | d 0 5500 salary 14 | n 15 | c 15 16 | w 2 1500 buy a television -------------------------------------------------------------------------------- /Bank/bank6/date.h: -------------------------------------------------------------------------------- 1 | #ifndef __Date__ 2 | #define __Date__ 3 | 4 | #include "iostream" 5 | using namespace std; 6 | class Date; 7 | 8 | class Date 9 | { 10 | private: 11 | int year, month, day; 12 | int totalDays; // 从1900年1月1日开始 13 | public: 14 | Date() = default; 15 | Date(int year, int month, int day); 16 | ~Date(); 17 | int getYear() const; 18 | int getMonth() const; 19 | int getDay() const; 20 | bool isLeapYear() const; 21 | int getTotalDays() const; 22 | int getMaxDay() const; 23 | int distance() const; //获得从1900年1月1日距今多少天 24 | void show() const; 25 | int operator - (const Date &d) const; //重载运算符,前面的减去后面的 26 | bool operator < (const Date &d) const; 27 | friend ostream & operator<<(ostream &out, const Date &date); //cout << date 28 | static Date read(); 29 | }; 30 | 31 | #endif -------------------------------------------------------------------------------- /Bank/bank7/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | # 基于编辑器的 HTTP 客户端请求 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /Bank/bank7/.idea/discord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /Bank/bank7/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | -------------------------------------------------------------------------------- /Bank/bank7/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Bank/bank7/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Bank/bank7/Account.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "Account.h" 6 | #include 7 | #include "map" 8 | 9 | double Account::total = 0; 10 | multimap Account::recordMap; 11 | // 类的静态成员变量请记得初始化。 12 | 13 | Account::Account(const Date& date, std::string id) : id(id), balance(0){ 14 | } 15 | 16 | Account::~Account() = default; 17 | 18 | void Account::record(Date date, double amount, const std::string& desc) { 19 | amount = floor(amount * 100 + 0.5) / 100; //保留小数点后两位 20 | balance += amount; 21 | total += amount; 22 | cout << date << "\t#" << id << "\t" << amount << "\t" << balance << "\t" << desc << endl; 23 | recordMap.insert(make_pair(date, AccountRecord(date,this,amount,balance,desc))); 24 | } 25 | 26 | std::string Account::getId() const{ 27 | return this->id; 28 | } 29 | 30 | double Account::getBalance() const{ 31 | return this->balance; 32 | } 33 | 34 | double Account::getTotal() { 35 | return total; 36 | } 37 | 38 | void Account::show() const { 39 | cout << id << "\tBalance: " << balance; 40 | } 41 | 42 | void Account::query(Date &day1, Date &day2) { 43 | for(auto & it : recordMap){ 44 | if(day1 < it.first && it.first getId() << "\t" << it.second.amount << "\t" 48 | << it.second.balance << "\t" << it.second.desc << endl; 49 | } 50 | } 51 | 52 | AccountRecord::AccountRecord(const Date& date, const Account *account, double amount, double balance, std::string desc) 53 | :date(date), account(account), amount(amount), balance(balance), desc(desc){} 54 | -------------------------------------------------------------------------------- /Bank/bank7/Accumulator.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "Accumulator.h" 6 | #include 7 | using namespace std; 8 | 9 | Accumulator::Accumulator(Date date, double value): lastDate(date), value(value), sum(0){} 10 | 11 | const double Accumulator::getSum(Date date) { 12 | double a = sum + value * (date - this->lastDate); 13 | //cout << date - this->lastDate << endl ; 14 | //cout << endl << a << endl; 15 | return a; 16 | } 17 | 18 | void Accumulator::change(Date date, double value) { 19 | sum = getSum(date); 20 | lastDate = date; 21 | this->value = value; 22 | } 23 | 24 | void Accumulator::reset(Date date, double value) { 25 | lastDate = date; 26 | this->value = value; 27 | sum = 0; 28 | } 29 | 30 | Accumulator::~Accumulator() = default; 31 | -------------------------------------------------------------------------------- /Bank/bank7/Accumulator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_ACCUMULATOR_H 6 | #define BANK3_ACCUMULATOR_H 7 | #include "date.h" 8 | 9 | class Accumulator { 10 | private: 11 | Date lastDate; //上次变更值的日子 12 | double value; //余额或者欠款 13 | double sum; //余额或欠款累加 14 | public: 15 | Accumulator(Date date, double value); 16 | ~Accumulator(); 17 | const double getSum(Date date); 18 | void change(Date date, double value); 19 | void reset(Date date, double value); 20 | }; 21 | 22 | 23 | #endif //BANK3_ACCUMULATOR_H 24 | -------------------------------------------------------------------------------- /Bank/bank7/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | project(bank7) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(bank7 7 | date.cpp date.h 8 | Account.h Account.cpp 9 | SavingsAccount.cpp SavingsAccount.h 10 | Accumulator.cpp Accumulator.h 11 | CreditAccount.cpp CreditAccount.h 12 | step_7.cpp) 13 | -------------------------------------------------------------------------------- /Bank/bank7/CreditAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_CREDITACCOUNT_H 6 | #define BANK3_CREDITACCOUNT_H 7 | #include "string" 8 | #include "Account.h" 9 | #include "Accumulator.h" 10 | 11 | class CreditAccount : public Account{ 12 | private: 13 | Accumulator acc; 14 | double credit; 15 | double rate; 16 | double fee; 17 | public: 18 | CreditAccount(Date date, std::string id, double credit, double rate, double fee); 19 | ~CreditAccount() override; 20 | double getDebt() const; 21 | double getCredit() const; 22 | double getRate() const; 23 | double getFee() const; 24 | double getAvailableCredit() const; 25 | void deposit(Date date, double amount, std::string desc) override; 26 | void withdraw(Date date, double amount, std::string desc) override; 27 | void settle(Date date) override; 28 | void show() const override; 29 | }; 30 | 31 | 32 | #endif //BANK3_CREDITACCOUNT_H 33 | -------------------------------------------------------------------------------- /Bank/bank7/SavingsAccount.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "SavingsAccount.h" 6 | #include "Accumulator.h" 7 | #include "iostream" 8 | using namespace std; 9 | 10 | SavingsAccount::SavingsAccount(Date date, std::string id, double rate) : Account(date, id), acc(date, 0), rate(rate) { 11 | cout << date << "\t#" << id << " created" << endl; 12 | } 13 | 14 | void SavingsAccount::deposit(Date date, double amount, std::string desc) { 15 | record(date, amount, desc); 16 | acc.change(date, getBalance()); 17 | } 18 | 19 | void SavingsAccount::withdraw(Date date, double amount, std::string desc) { 20 | if(amount <= getBalance()) { 21 | record(date, -amount, desc); 22 | acc.change(date, getBalance()); 23 | } 24 | else throw AccountException(this); 25 | } 26 | 27 | double SavingsAccount::getRate() const{ 28 | return this->rate; 29 | } 30 | 31 | void SavingsAccount::settle(Date date) { 32 | if(date.getMonth() != 1) return; 33 | double a = acc.getSum(date); 34 | int days = (date - Date(date.getYear() - 1, 1, 1)) + 1; 35 | double interest = a * rate / days; 36 | //cout << days << endl; 37 | //cout << a << endl; 38 | // cout << interest << endl; 39 | record(date, interest, "interest"); 40 | acc.change(date, interest); 41 | acc.reset(date, getBalance()); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Bank/bank7/SavingsAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_SAVINGSACCOUNT_H 6 | #define BANK3_SAVINGSACCOUNT_H 7 | 8 | #include 9 | #include "Account.h" 10 | #include "Accumulator.h" 11 | 12 | class SavingsAccount :public Account{ 13 | private: 14 | Accumulator acc; 15 | double rate; 16 | public: 17 | SavingsAccount(Date date, std::string id, double rate); 18 | double getRate() const; 19 | void deposit(Date date, double amount, std::string desc) override; 20 | void withdraw(Date date, double amount, std::string desc) override; 21 | void settle(Date date) override; 22 | }; 23 | 24 | 25 | #endif //BANK3_SAVINGSACCOUNT_H 26 | -------------------------------------------------------------------------------- /Bank/bank7/commands.txt: -------------------------------------------------------------------------------- 1 | a s S3755217 0.015 2 | a s 02342342 0.015 3 | a c C5392394 10000 0.0005 50 4 | c 5 5 | d 0 5000 salary 6 | c 15 7 | w 2 2000 buy a cell 8 | c 25 9 | d 1 10000 sell stock 0323 10 | n 11 | d 2 2016 repay the credit 12 | c 5 13 | d 0 5500 salary 14 | n 15 | c 15 16 | w 2 1500 buy a television333 0 50 -------------------------------------------------------------------------------- /Bank/bank7/date.h: -------------------------------------------------------------------------------- 1 | #ifndef __Date__ 2 | #define __Date__ 3 | 4 | #include "iostream" 5 | using namespace std; 6 | class Date; 7 | 8 | class Date 9 | { 10 | private: 11 | int year, month, day; 12 | int totalDays; // 从1900年1月1日开始 13 | public: 14 | Date() = default; 15 | Date(int year, int month, int day); 16 | ~Date(); 17 | int getYear() const; 18 | int getMonth() const; 19 | int getDay() const; 20 | bool isLeapYear() const; 21 | int getTotalDays() const; 22 | int getMaxDay() const; 23 | int distance() const; //获得从1900年1月1日距今多少天 24 | void show() const; 25 | int operator - (const Date &d) const; //重载运算符,前面的减去后面的 26 | bool operator < (const Date &d) const; 27 | friend ostream & operator<<(ostream &out, const Date &date); //cout << date 28 | static Date read(); 29 | }; 30 | 31 | class DateException : public exception{ 32 | public: 33 | const char *what() const noexcept override{ 34 | return "Not a right Date. Please input again."; 35 | } 36 | }; 37 | 38 | 39 | #endif -------------------------------------------------------------------------------- /Bank/qtbank/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | # 基于编辑器的 HTTP 客户端请求 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /Bank/qtbank/.idea/discord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /Bank/qtbank/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Bank/qtbank/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Bank/qtbank/Accumulator.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "Accumulator.h" 6 | #include 7 | using namespace std; 8 | 9 | Accumulator::Accumulator(Date date, double value): lastDate(date), value(value), sum(0){} 10 | 11 | const double Accumulator::getSum(Date date) { 12 | double a = sum + value * (date - this->lastDate); 13 | //cout << date - this->lastDate << endl ; 14 | //cout << endl << a << endl; 15 | return a; 16 | } 17 | 18 | void Accumulator::change(Date date, double value) { 19 | sum = getSum(date); 20 | lastDate = date; 21 | this->value = value; 22 | } 23 | 24 | void Accumulator::reset(Date date, double value) { 25 | lastDate = date; 26 | this->value = value; 27 | sum = 0; 28 | } 29 | 30 | Accumulator::~Accumulator() = default; 31 | -------------------------------------------------------------------------------- /Bank/qtbank/Accumulator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_ACCUMULATOR_H 6 | #define BANK3_ACCUMULATOR_H 7 | #include "date.h" 8 | 9 | class Accumulator { 10 | private: 11 | Date lastDate; //上次变更值的日子 12 | double value; //余额或者欠款 13 | double sum; //余额或欠款累加 14 | public: 15 | Accumulator(Date date, double value); 16 | ~Accumulator(); 17 | const double getSum(Date date); 18 | void change(Date date, double value); 19 | void reset(Date date, double value); 20 | }; 21 | 22 | 23 | #endif //BANK3_ACCUMULATOR_H 24 | -------------------------------------------------------------------------------- /Bank/qtbank/CreditAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_CREDITACCOUNT_H 6 | #define BANK3_CREDITACCOUNT_H 7 | #include "string" 8 | #include "Account.h" 9 | #include "Accumulator.h" 10 | 11 | class CreditAccount : public Account{ 12 | private: 13 | Accumulator acc; 14 | double credit; 15 | double rate; 16 | double fee; 17 | public: 18 | CreditAccount(Date date, std::string Log_on_User, std::string id, double credit, double rate, double fee); 19 | ~CreditAccount() override; 20 | double getDebt() override; 21 | double getCredit() const; 22 | double getRate() const; 23 | double getFee() const; 24 | double getAvailableCredit() const; 25 | void deposit(Date date, double amount, std::string desc) override; 26 | void withdraw(Date date, double amount, std::string desc) override; 27 | void settle(Date date) override; 28 | int s_or_c() override{ 29 | return 1; 30 | } 31 | std::string show() const override; 32 | }; 33 | 34 | 35 | #endif //BANK3_CREDITACCOUNT_H 36 | -------------------------------------------------------------------------------- /Bank/qtbank/SavingsAccount.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #include "SavingsAccount.h" 6 | #include "Accumulator.h" 7 | #include "iostream" 8 | using namespace std; 9 | 10 | SavingsAccount::SavingsAccount(Date date, std::string Log_on_User, std::string id, double rate) : Account(date, Log_on_User, id), acc(date, 0), rate(rate) { 11 | cout << date << "\t" << Log_on_User << "\t#" << id << " created" << endl; 12 | } 13 | 14 | void SavingsAccount::deposit(Date date, double amount, std::string desc) { 15 | record(date, amount, desc); 16 | acc.change(date, getBalance()); 17 | } 18 | 19 | void SavingsAccount::withdraw(Date date, double amount, std::string desc) { 20 | if(amount <= getBalance()) { 21 | record(date, -amount, desc); 22 | acc.change(date, getBalance()); 23 | } 24 | else throw AccountException(this); 25 | } 26 | 27 | double SavingsAccount::getRate() const{ 28 | return this->rate; 29 | } 30 | 31 | void SavingsAccount::settle(Date date) { 32 | if(date.getMonth() != 1) return; 33 | double a = acc.getSum(date); 34 | int days = (date - Date(date.getYear() - 1, 1, 1)) + 1; 35 | double interest = a * rate / days; 36 | //cout << days << endl; 37 | //cout << a << endl; 38 | // cout << interest << endl; 39 | record(date, interest, "interest"); 40 | acc.change(date, interest); 41 | acc.reset(date, getBalance()); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Bank/qtbank/SavingsAccount.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2022/9/19. 3 | // 4 | 5 | #ifndef BANK3_SAVINGSACCOUNT_H 6 | #define BANK3_SAVINGSACCOUNT_H 7 | 8 | #include 9 | #include "Account.h" 10 | #include "Accumulator.h" 11 | 12 | class SavingsAccount :public Account{ 13 | private: 14 | Accumulator acc; 15 | double rate; 16 | public: 17 | SavingsAccount(Date date, std::string Log_on_User, std::string id, double rate); 18 | double getRate() const; 19 | void deposit(Date date, double amount, std::string desc) override; 20 | void withdraw(Date date, double amount, std::string desc) override; 21 | void settle(Date date) override; 22 | double getDebt() override{ 23 | return 0; 24 | } 25 | int s_or_c() override{ 26 | return 0; 27 | } 28 | }; 29 | 30 | 31 | #endif //BANK3_SAVINGSACCOUNT_H 32 | -------------------------------------------------------------------------------- /Bank/qtbank/bankusers.cpp: -------------------------------------------------------------------------------- 1 | #include "bankusers.h" 2 | 3 | BankUsers::BankUsers(string ID, string password): ID(ID), password(password) 4 | { 5 | 6 | } 7 | 8 | string BankUsers::getID() const{ 9 | return this->ID; 10 | } 11 | 12 | string BankUsers::getPassword() const{ 13 | return this->password; 14 | } 15 | -------------------------------------------------------------------------------- /Bank/qtbank/bankusers.h: -------------------------------------------------------------------------------- 1 | #ifndef BANKUSERS_H 2 | #define BANKUSERS_H 3 | 4 | #include "string" 5 | using namespace std; 6 | 7 | class BankUsers 8 | { 9 | private: 10 | string ID; 11 | string password; 12 | public: 13 | BankUsers(string ID, string password); 14 | ~BankUsers() = default; 15 | //bool FindRepeatedUser(string ID); //找到重复的ID,如果找到则提示“重复的用户名” 16 | string getID() const; 17 | string getPassword() const; 18 | }; 19 | 20 | #endif // BANKUSERS_H 21 | -------------------------------------------------------------------------------- /Bank/qtbank/date.h: -------------------------------------------------------------------------------- 1 | #ifndef __Date__ 2 | #define __Date__ 3 | 4 | #include "iostream" 5 | using namespace std; 6 | class Date; 7 | 8 | class Date 9 | { 10 | private: 11 | int year, month, day; 12 | int totalDays; // 从1900年1月1日开始 13 | public: 14 | Date() = default; 15 | Date(int year, int month, int day); 16 | ~Date(); 17 | int getYear() const; 18 | int getMonth() const; 19 | int getDay() const; 20 | bool isLeapYear() const; 21 | int getTotalDays() const; 22 | int getMaxDay() const; 23 | int distance() const; //获得从1900年1月1日距今多少天 24 | void show() const; 25 | int operator - (const Date &d) const; //重载运算符,前面的减去后面的 26 | bool operator < (const Date &d) const; 27 | friend ostream & operator<<(ostream &out, const Date &date); //cout << date 28 | static Date read(); 29 | }; 30 | 31 | class DateException : public exception{ 32 | public: 33 | const char *what() const noexcept override{ 34 | return "Not a right Date. Please input again."; 35 | } 36 | }; 37 | 38 | 39 | #endif -------------------------------------------------------------------------------- /Bank/qtbank/insidewindow.h: -------------------------------------------------------------------------------- 1 | #ifndef INSIDEWINDOW_H 2 | #define INSIDEWINDOW_H 3 | 4 | #include 5 | #include "mainwindow.h" 6 | 7 | namespace Ui { 8 | class InsideWindow; 9 | } 10 | 11 | class InsideWindow : public MainWindow 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit InsideWindow(QWidget *parent = nullptr); 17 | ~InsideWindow(); 18 | 19 | private slots: 20 | void recvInsideWindow(); 21 | 22 | void on_pushButton_vhhu_clicked(); 23 | 24 | void on_pushButton_cyqm_clicked(); 25 | 26 | void on_pushButton_quqm_clicked(); 27 | 28 | void on_pushButton_gdbmriqi_clicked(); 29 | 30 | void on_pushButton_jbruxxgeyt_clicked(); 31 | 32 | void on_pushButton_iaxyxbxi_clicked(); 33 | 34 | void on_pushButton_iaxyvhmu_clicked(); 35 | 36 | private: 37 | Ui::InsideWindow *ui; 38 | static InsideWindow *iw; 39 | static void backMain(char cmd, bool is_now_reading_a_file); 40 | static void jisrBro2(); 41 | }; 42 | 43 | #endif // INSIDEWINDOW_H 44 | -------------------------------------------------------------------------------- /Bank/qtbank/main.cpp: -------------------------------------------------------------------------------- 1 | //main.cpp 2 | 3 | #include "Account.h" 4 | #include "date.h" 5 | #include "SavingsAccount.h" 6 | #include "CreditAccount.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "stdexcept" 12 | #include "mainwindow.h" 13 | #include 14 | #include "insidewindow.h" 15 | using namespace std; 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | QApplication a(argc, argv); 20 | MainWindow w; 21 | w.show(); 22 | 23 | return a.exec(); 24 | } 25 | -------------------------------------------------------------------------------- /Bank/qtbank/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include "vector" 6 | #include "bankusers.h" 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class MainWindow; } 10 | QT_END_NAMESPACE 11 | 12 | class MainWindow : public QMainWindow 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | static string Log_on_User; 18 | MainWindow(QWidget *parent = nullptr); 19 | ~MainWindow(); 20 | 21 | private slots: 22 | 23 | 24 | void on_registerID_clicked(); 25 | 26 | void on_log_onID_clicked(); 27 | 28 | signals: 29 | void showInsideWindow(); 30 | 31 | private: 32 | Ui::MainWindow *ui; 33 | protected: 34 | vector bankUsers; 35 | }; 36 | #endif // MAINWINDOW_H 37 | -------------------------------------------------------------------------------- /Bank/qtbank/md5.h: -------------------------------------------------------------------------------- 1 | #ifndef MD5_H 2 | #define MD5_H 3 | 4 | #include 5 | #include 6 | 7 | /* Type define */ 8 | typedef unsigned char byte; 9 | typedef unsigned int uint32; 10 | 11 | using std::string; 12 | using std::ifstream; 13 | 14 | /* MD5 declaration. */ 15 | class MD5 16 | { 17 | public: 18 | MD5(); 19 | MD5( const void *input, size_t length ); 20 | MD5( const string &str ); 21 | MD5( ifstream &in ); 22 | void update( const void *input, size_t length ); 23 | void update( const string &str ); 24 | void update( ifstream &in ); 25 | const byte* digest(); 26 | string toString(); 27 | void reset(); 28 | private: 29 | void update( const byte *input, size_t length ); 30 | void final(); 31 | void transform( const byte block[64] ); 32 | void encode( const uint32 *input, byte *output, size_t length ); 33 | void decode( const byte *input, uint32 *output, size_t length ); 34 | string bytesToHexString( const byte *input, size_t length ); 35 | 36 | /* class uncopyable */ 37 | MD5( const MD5& ); 38 | MD5& operator=( const MD5& ); 39 | 40 | private: 41 | uint32 _state[4]; /* state (ABCD) */ 42 | uint32 _count[2]; /* number of bits, modulo 2^64 (low-order word first) */ 43 | byte _buffer[64]; /* input buffer */ 44 | byte _digest[16]; /* message digest */ 45 | bool _finished; /* calculate finished ? */ 46 | 47 | static const byte PADDING[64]; /* padding for calculate */ 48 | static const char HEX[16]; 49 | static const size_t BUFFER_SIZE = 1024; 50 | }; 51 | 52 | #endif/*MD5_H*/ 53 | -------------------------------------------------------------------------------- /Bank/qtbank/qtbank.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++11 6 | 7 | # You can make your code fail to compile if it uses deprecated APIs. 8 | # In order to do so, uncomment the following line. 9 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 10 | 11 | SOURCES += \ 12 | Account.cpp \ 13 | Accumulator.cpp \ 14 | CreditAccount.cpp \ 15 | SavingsAccount.cpp \ 16 | bankusers.cpp \ 17 | date.cpp \ 18 | insidewindow.cpp \ 19 | mainwindow.cpp \ 20 | main.cpp \ 21 | md5.cpp 22 | 23 | HEADERS += \ 24 | Account.h \ 25 | Accumulator.h \ 26 | CreditAccount.h \ 27 | SavingsAccount.h \ 28 | bankusers.h \ 29 | date.h \ 30 | insidewindow.h \ 31 | mainwindow.h \ 32 | md5.h 33 | 34 | FORMS += \ 35 | insidewindow.ui \ 36 | mainwindow.ui 37 | 38 | # Default rules for deployment. 39 | qnx: target.path = /tmp/$${TARGET}/bin 40 | else: unix:!android: target.path = /opt/$${TARGET}/bin 41 | !isEmpty(target.path): INSTALLS += target 42 | 43 | DISTFILES += \ 44 | 45 | CONFIG += console 46 | -------------------------------------------------------------------------------- /Bank/程序设计实践II银行实验报告.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/Bank/程序设计实践II银行实验报告.docx -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.23) 2 | project(Cpp_Programming) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | #递归遍历所有的cpp文件 7 | file (GLOB_RECURSE files *.cpp) 8 | #将所有的cpp文件单独生成可执行文件 9 | foreach (file ${files}) 10 | string(REGEX REPLACE ".+/(.+)\\..*" "\\1" exe ${file}) 11 | add_executable (${exe} ${file}) 12 | message (\ \ \ \ --\ src/${exe}.cpp\ will\ be\ compiled\ to\ bin/${exe}) 13 | endforeach () 14 | 15 | 16 | #F:\programs\c_pro\Cpp_Programming\exercise5 17 | -------------------------------------------------------------------------------- /HarryPotterSearch/HarryPotterSearch/HarryPotterSearch.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++11 6 | 7 | # You can make your code fail to compile if it uses deprecated APIs. 8 | # In order to do so, uncomment the following line. 9 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 10 | 11 | SOURCES += \ 12 | main.cpp \ 13 | mainwindow.cpp 14 | 15 | HEADERS += \ 16 | mainwindow.h 17 | 18 | FORMS += \ 19 | mainwindow.ui 20 | 21 | # Default rules for deployment. 22 | qnx: target.path = /tmp/$${TARGET}/bin 23 | else: unix:!android: target.path = /opt/$${TARGET}/bin 24 | !isEmpty(target.path): INSTALLS += target 25 | -------------------------------------------------------------------------------- /HarryPotterSearch/HarryPotterSearch/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | MainWindow w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /HarryPotterSearch/HarryPotterSearch/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include "string" 6 | using std::string; 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class MainWindow; } 10 | QT_END_NAMESPACE 11 | 12 | class MainWindow : public QMainWindow 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | MainWindow(QWidget *parent = nullptr); 18 | ~MainWindow(); 19 | 20 | private slots: 21 | void on_pushButton_clicked(); 22 | 23 | void on_pushButton_2_clicked(); 24 | 25 | void on_textBrowser_anchorClicked(const QUrl &arg1); 26 | 27 | private: 28 | Ui::MainWindow *ui; 29 | }; 30 | 31 | class SearchInfo { 32 | private: 33 | int bookNum; //书名的序号 34 | int page; //页数 35 | int chapter; //章节 36 | string line; //当前行的内容 37 | public: 38 | SearchInfo(int bookNum, int page, int chapter, string line); 39 | ~SearchInfo(); 40 | string getLine(); 41 | }; 42 | 43 | #endif // MAINWINDOW_H 44 | -------------------------------------------------------------------------------- /HarryPotterSearch/哈利波特检索实验报告.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/HarryPotterSearch/哈利波特检索实验报告.docx -------------------------------------------------------------------------------- /exercise1/1-1/1-1_who_catched_the_most_scholarship.rap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/exercise1/1-1/1-1_who_catched_the_most_scholarship.rap -------------------------------------------------------------------------------- /exercise1/1-1/1. 流程图绘制2:要求绘制解决问题的算法(谁拿了最多奖学金).docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/exercise1/1-1/1. 流程图绘制2:要求绘制解决问题的算法(谁拿了最多奖学金).docx -------------------------------------------------------------------------------- /exercise1/1-2/1-2_search_the_number.rap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/exercise1/1-2/1-2_search_the_number.rap -------------------------------------------------------------------------------- /exercise1/1-2/2. 流程图绘制1:要求绘制解决问题的算法.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/exercise1/1-2/2. 流程图绘制1:要求绘制解决问题的算法.docx -------------------------------------------------------------------------------- /exercise1/vr1_1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | char str[16]; 6 | cin >> str; 7 | short ans = 0; 8 | for (int i = 0; i < 16; i++){ 9 | ans <<= 1; 10 | ans += str[i] - 48; 11 | } 12 | cout << ans << endl; 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /exercise1/vr1_2.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/4/20. 3 | // 4 | #include 5 | 6 | using namespace std; 7 | 8 | bool j(int n) { 9 | for (int i = 2; i * i <= n; i++) { 10 | if (n % i == 0) return false; 11 | } 12 | return true; 13 | } 14 | 15 | int main() { 16 | int n; 17 | cin >> n; 18 | if(n == 1) { 19 | cout << "N" << endl; 20 | return 0; 21 | } 22 | if (j(n)) { 23 | cout << "Y" << endl; 24 | } else { 25 | cout << "N" << endl; 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /exercise1/vr1_3.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/4/20. 3 | // 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | struct LinkList{ 10 | int data; 11 | struct LinkList* next; 12 | }; 13 | 14 | int main(){ 15 | struct LinkList Node{}; 16 | int m, n, remained; 17 | int count = 0; 18 | struct LinkList* head, * tail, * cur, * next; 19 | head = (struct LinkList*) malloc(sizeof(struct LinkList)); 20 | head->next = NULL; 21 | cin >> m >> n; 22 | remained = m; 23 | if (m == 0 || n == 0){ 24 | free(head); 25 | exit(-1); 26 | }else { 27 | tail = head; 28 | for(int i = 0; i < m; i++){ 29 | cur = (struct LinkList*) malloc(sizeof(struct LinkList)); 30 | cur->data = i + 1; 31 | tail->next = cur; 32 | cur->next = head->next; 33 | tail = cur; 34 | } 35 | cur = head->next; 36 | next = tail; 37 | int i = 1; 38 | while (remained != 1){ 39 | if (i == n){ 40 | next->next = next->next->next; 41 | free(cur); 42 | cur = next->next; 43 | remained--; 44 | i = 1; 45 | } 46 | else{ 47 | next = next->next; 48 | cur = cur->next; 49 | i++; 50 | } 51 | } 52 | cout << cur->data; 53 | free(cur); 54 | } 55 | 56 | return 0; 57 | } -------------------------------------------------------------------------------- /exercise2/vr2_1.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/4/20. 3 | // 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | char s[5000]; 9 | char subs[5000]; 10 | 11 | int main(){ 12 | scanf("%s %s", s, subs); 13 | int count = 0; 14 | char *ch; 15 | ch = s; 16 | while(*ch != 0){ 17 | if(*ch == *subs){ 18 | char *mch = ch; 19 | char *chs = subs; 20 | while(*chs != 0){ 21 | if(*mch != *chs){ 22 | count--; 23 | break; 24 | } 25 | chs++;mch++; 26 | } 27 | count++; 28 | } 29 | ch++; 30 | } 31 | cout << count << endl; 32 | return 0; 33 | } -------------------------------------------------------------------------------- /exercise2/vr2_2.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/4/20. 3 | // 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | struct Location{ 9 | int x; 10 | int y; 11 | int z; 12 | unsigned int travelTime; 13 | }locations[100010]; 14 | int N; 15 | int main(){ 16 | cin >> N; 17 | for(int i = 0; i < N; i++){ 18 | cin >> locations[i].x >> locations[i].y >> locations[i].z; 19 | } 20 | unsigned int minTravelTime = 0xFFFFFFFF; 21 | for(int i = 0; i < N; i++){ 22 | for(int j = 0; j < N; j++){ 23 | locations[i].travelTime += abs(locations[i].x - locations[j].x) + 24 | abs(locations[i].y - locations[j].y) + 25 | abs(locations[i].z - locations[j].z); 26 | } 27 | if(minTravelTime > locations[i].travelTime) { 28 | minTravelTime = locations[i].travelTime; 29 | } 30 | } 31 | cout << minTravelTime << endl; 32 | return 0; 33 | } -------------------------------------------------------------------------------- /exercise2/vr2_3.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/4/20. 3 | // 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | int A[10]; 9 | 10 | int cmp(int a, int b){ 11 | return a > b; 12 | } 13 | 14 | int main(){ 15 | unsigned int count = 0; 16 | for(int i = 0; i < 10; i++){ 17 | cin >> *(A+i); 18 | if(*(A+i) == 0) count++; 19 | } 20 | sort(A, A+10, cmp); 21 | for(int i = 0; i < 10; i++){ 22 | cout << *(A+i) << " "; 23 | } 24 | cout << endl << 10 - count << endl; 25 | return 0; 26 | } -------------------------------------------------------------------------------- /exercise2/vr2_4.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/4/20. 3 | // 4 | #include 5 | //#include 6 | using namespace std; 7 | 8 | int a[10]; 9 | 10 | void move(int *arry, int n, int m){ 11 | int temp[100]; 12 | for(int i = 0; i < m; ++i){ 13 | temp[i] = *(arry+(n-m)+i); 14 | } 15 | for(int i = n; i >= m; i--){ 16 | *(arry+i) = *(arry+i-m); 17 | } 18 | for(int i = 0; i < m; ++i){ 19 | *(arry+i) = temp[i]; 20 | } 21 | } 22 | 23 | int main(){ 24 | int n = 10, m = 3; 25 | for(int i = 0; i < n; i++){ 26 | cin >> *(a+i); 27 | } 28 | move(a, n, m); 29 | for(int i = 0; i < n; i++){ 30 | cout << *(a+i) << " "; 31 | } 32 | cout << endl; 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /exercise2/vr2_5.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/4/20. 3 | // 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int T, MaxMem; 10 | int handle = 0; //句柄handle(句柄即内存块编号,分配的第一个内存块编号为1,以此类推) 11 | int simMem[10010]; 12 | int sizeMem[10010]; 13 | int nowSizeOfMem = 0; 14 | 15 | int main() { 16 | cin >> T >> MaxMem; 17 | string cmd; 18 | for (int i = 0; i < T; i++) { 19 | cin >> cmd; 20 | if (cmd == "new") { 21 | int size; 22 | cin >> size; 23 | nowSizeOfMem += size; //计算new之后的总内存大小 24 | if(nowSizeOfMem <= MaxMem){ //是否超过MaxMem 25 | handle++; 26 | simMem[handle] = nowSizeOfMem; 27 | sizeMem[handle] = nowSizeOfMem; 28 | cout << handle << endl; 29 | } else { 30 | nowSizeOfMem -= size; //如果超过了,退回刚才步骤 31 | cout << "NULL" << endl; 32 | } 33 | } else if (cmd == "del") { 34 | int delHandle; 35 | cin >> delHandle; 36 | // 如果 simMem[delHandel](模拟的句柄编号的位置)是-1(被删除)或者是0(还没到Handel位置),那么是非法操作 37 | if(simMem[delHandle] != -1 && simMem[delHandle] != 0) { 38 | simMem[delHandle] = -1; //-1表示该Handel被删除 39 | } else { 40 | cout << "ILLEGAL_OPERATION" << endl; 41 | } 42 | } else if (cmd == "def") { 43 | for (int j = 0; j < sizeof(simMem)/sizeof(simMem[0]); j++){ 44 | if (simMem[j] == -1){ 45 | nowSizeOfMem -= sizeMem[j]; 46 | } 47 | } 48 | } 49 | } 50 | 51 | return 0; 52 | } -------------------------------------------------------------------------------- /exercise3/vr3_1.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/4/20. 3 | // 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | class Course{ 9 | private: 10 | string courseName; //课程名 11 | int prerequisites; //先修课 12 | int ID; // 课程ID 13 | public: 14 | Course(const string& courseName, int prerequisites, int ID); 15 | void ShowCourseInfo(); 16 | string FindPrerequisites(int pre) const; 17 | }; 18 | 19 | vector courses; 20 | 21 | Course::Course(const string& courseName, int prerequisites, int ID) { 22 | this->courseName = courseName; 23 | this->prerequisites = prerequisites; 24 | this->ID = ID; 25 | } 26 | 27 | void Course::ShowCourseInfo() { 28 | if(prerequisites == -1){ 29 | cout << "Course " << ID << "-" << courseName << " has prerequisites: none" << endl; 30 | return; 31 | } 32 | cout << "Course " << ID << "-" << courseName << " has prerequisites: " << FindPrerequisites(prerequisites) << endl; 33 | } 34 | 35 | string Course::FindPrerequisites(int pre) const { 36 | if(prerequisites == -1) return ""; 37 | return courses[pre].courseName + " " + courses[pre].FindPrerequisites(courses[pre].prerequisites); 38 | } 39 | 40 | int main(){ 41 | char cmd; 42 | string courseName; 43 | int ID = 0; 44 | int prerequisites; 45 | while(true){ 46 | cin >> cmd; 47 | switch (cmd) { 48 | case 'c': 49 | cin >> courseName >> prerequisites; 50 | //courses.push_back(Course(courseName, prerequisites, ++ID)); 51 | courses.emplace_back(courseName, prerequisites, ID++); 52 | break; 53 | case 's': 54 | for (auto i : courses) { 55 | i.ShowCourseInfo(); 56 | } 57 | break; 58 | 59 | default: 60 | return 0; 61 | } 62 | } 63 | return 0; 64 | } -------------------------------------------------------------------------------- /exercise3/vr3_4.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/4/21. 3 | // 4 | #include 5 | #include 6 | //#include 7 | using namespace std; 8 | 9 | class MyStack{ 10 | private: 11 | int m_array[10]{}; 12 | int m_size{}; 13 | public: 14 | MyStack() = default; 15 | bool push(int num); 16 | bool pop(); 17 | void print(); 18 | }; 19 | 20 | bool MyStack::push(int num) { 21 | if(m_size == 10) return false; 22 | m_size++; 23 | m_array[m_size-1] = num; 24 | return true; 25 | } 26 | 27 | bool MyStack::pop() { 28 | if(m_size == 0) return false; 29 | m_size--; 30 | return true; 31 | } 32 | 33 | void MyStack::print() { 34 | cout << "( "; 35 | for(int i = 0; i < m_size; i++){ 36 | cout << m_array[i] << " "; 37 | } 38 | cout << ")" << endl; 39 | } 40 | 41 | int main(){ 42 | MyStack myStack = *new MyStack(); 43 | char cmd; 44 | int num; 45 | while(cin >> cmd){ 46 | switch (cmd) { 47 | case 'i': 48 | cin >> num; 49 | myStack.push(num); 50 | break; 51 | case 'o': 52 | if(!myStack.pop()){ 53 | cout << "Can not pop empty stack"<< endl; 54 | return 0; 55 | } 56 | break; 57 | case 's': 58 | myStack.print(); 59 | return 0; 60 | default: 61 | return 0; 62 | } 63 | } 64 | return 0; 65 | } -------------------------------------------------------------------------------- /exercise4/vr4-1/error.multiplication.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | const int maxn = 5000; 4 | const int maxn2 = maxn * 2; 5 | 6 | // 读入数字字符串,解析并存放到数组中 7 | int read_str(char *s, int *a) 8 | { 9 | int n = strlen(s); 10 | for (int i = 0; i < n; ++i) 11 | { 12 | a[i] = s[n - i - 1] - '0'; 13 | } 14 | return n; 15 | } 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | char s[maxn]; 20 | int a[maxn2], b[maxn2], c[maxn2]; 21 | int n1, n2; 22 | std::cin >> s; 23 | n1 = read_str(s, a); 24 | std::cin >> s; 25 | n2 = read_str(s, b); 26 | 27 | // 卷积操作 28 | for (int i = 0; i < n1 + n2; ++i) c[i] = 0; 29 | for (int i = 0; i < n1; ++i) 30 | for (int j = 0; j < n2; ++j) 31 | { 32 | c[i + j - 1] += a[i] * b[j]; 33 | } 34 | 35 | // 进位 36 | for (int i = 0, m = 0; i < n1 + n2; ++i) 37 | { 38 | c[i] += m; 39 | m = c[i] / 10; 40 | c[i] %= 10; 41 | } 42 | 43 | int n = n1 + n2 - 1; 44 | for (; c[n] == 0; --n); 45 | for (; n >= 0; --n) 46 | { 47 | std::cout << c[n]; 48 | } 49 | std::cout << std::endl; 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /exercise4/vr4-1/right_multiplication.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include //头文件加上这句,否则编译因为strlen问题不通过 3 | 4 | const int maxn = 5000; 5 | const int maxn2 = maxn * 2; 6 | 7 | // 读入数字字符串,解析并存放到数组中 8 | int read_str(char *s, int *a) 9 | { 10 | int n = int(strlen(s)); //进行强制类型转换,size_t -> int 11 | for (int i = 0; i < n; ++i) 12 | { 13 | a[i] = s[n - i - 1] - '0'; 14 | } 15 | return n; 16 | } 17 | 18 | int main(int argc, char *argv[]) 19 | { 20 | char s[maxn]; 21 | int a[maxn2], b[maxn2], c[maxn2]; 22 | int n1, n2; 23 | std::cin >> s; 24 | n1 = read_str(s, a); 25 | std::cin >> s; 26 | n2 = read_str(s, b); 27 | 28 | // 卷积操作 29 | for (int i = 0; i < n1 + n2; ++i) c[i] = 0; 30 | for (int i = 0; i < n1; ++i) 31 | for (int j = 0; j < n2; ++j) 32 | { 33 | c[i + j] += a[i] * b[j]; 34 | // 这里错了,原来是c[i+j-1] -1导致一开始i+j得0的时候存入了c[-1]位置导致末尾结果丢失 35 | } 36 | 37 | // 进位 38 | for (int i = 0, m = 0; i < n1 + n2; ++i) 39 | { 40 | c[i] += m; 41 | m = c[i] / 10; 42 | c[i] %= 10; 43 | } 44 | 45 | int n = n1 + n2 - 1; 46 | for (; c[n] == 0; --n); 47 | for (; n >= 0; --n) 48 | { 49 | std::cout << c[n]; 50 | } 51 | std::cout << std::endl; 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /exercise4/vr4-3/error.bubble_sort.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 冒泡排序 3 | */ 4 | #include 5 | #include 6 | 7 | const int maxn = 5000; 8 | int a[maxn]; 9 | 10 | // 交换函数,利用异或操作的可逆性 11 | void swap(int a, int b) 12 | { 13 | a ^= b; 14 | b ^= a; 15 | a ^= b; 16 | } 17 | 18 | int main(int argc, char *argv[]) 19 | { 20 | int n; 21 | std::cin >> n; 22 | if (n <= 0 || n > maxn) 23 | { 24 | std::cout << "Invalid input array length:\n" 25 | " must be in the range of 1 to " 26 | << maxn << std::endl; 27 | } 28 | 29 | for (int i = 0; i < n; ++i) 30 | { 31 | std::cin >> a[i]; 32 | } 33 | 34 | // 冒泡排序 35 | for (bool flag = true; flag; ) 36 | { 37 | flag = false; 38 | // 权值大的元素上浮 39 | for (int i = 0; i < n - 1; ++i) 40 | { 41 | if (a[i] > a[i + 1]) 42 | { 43 | swap(a[i], a[i + 1]); 44 | flag = true; 45 | } 46 | } 47 | // 权值小的元素下沉 48 | for (int i = n - 1; i > 0; --i) 49 | { 50 | if (a[i - 1] > a[i]) 51 | { 52 | swap(a[i - 1], a[i]); 53 | flag = true; 54 | } 55 | } 56 | } 57 | 58 | for (int i = 0; i < n; ++i) 59 | { 60 | std::cout << a[i] << (i < n - 1 ? ' ' : '\n'); 61 | } 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /exercise4/vr4-3/right_bubble_sort.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 冒泡排序 3 | */ 4 | //错误位置,第12行,值传递导致交换失败,改为引用传递 5 | #include 6 | #include 7 | 8 | const int maxn = 5000; 9 | int a[maxn]; 10 | 11 | // 交换函数,利用异或操作的可逆性 12 | void swap(int &a, int &b) 13 | { 14 | a ^= b; 15 | b ^= a; 16 | a ^= b; 17 | } 18 | 19 | int main(int argc, char *argv[]) 20 | { 21 | int n; 22 | std::cin >> n; 23 | if (n <= 0 || n > maxn) 24 | { 25 | std::cout << "Invalid input array length:\n" 26 | " must be in the range of 1 to " 27 | << maxn << std::endl; 28 | } 29 | 30 | for (int i = 0; i < n; ++i) 31 | { 32 | std::cin >> a[i]; 33 | } 34 | 35 | // 冒泡排序 36 | for (bool flag = true; flag; ) 37 | { 38 | flag = false; 39 | // 权值大的元素上浮 40 | for (int i = 0; i < n - 1; ++i) 41 | { 42 | if (a[i] > a[i + 1]) 43 | { 44 | swap(a[i], a[i + 1]); 45 | flag = true; 46 | } 47 | } 48 | // 权值小的元素下沉 49 | for (int i = n - 1; i > 0; --i) 50 | { 51 | if (a[i - 1] > a[i]) 52 | { 53 | swap(a[i - 1], a[i]); 54 | flag = true; 55 | } 56 | } 57 | } 58 | 59 | for (int i = 0; i < n; ++i) 60 | { 61 | std::cout << a[i] << (i < n - 1 ? ' ' : '\n'); 62 | } 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /exercise5/take_a_coin.cpp: -------------------------------------------------------------------------------- 1 | // 将n枚硬币摆成环状,A和B轮流拿,A先拿。每个人拿的时候只可以选择拿走一个或者拿走相邻的两个,谁拿完最后的硬币胜利。 2 | // 给定n <= 1000,并且假设双方都采取最优策略,输出最后的获胜者 3 | 4 | // Created by 25910 on 2023/4/20. 5 | 6 | // 看硬币排成1行 n=1,2 A赢 n=3 B赢, n=4 A赢,n=5 A赢 7 | #include 8 | using namespace std; 9 | const int maxn=1e3+5; 10 | int n; 11 | bool a_win[1005]; 12 | void init(int n){ 13 | a_win[1]=a_win[2]= true; 14 | a_win[3]= false; 15 | for(int i=4;i<=n;i++){ 16 | a_win[i]= (a_win[i - 1] || a_win[i - 2]); 17 | } 18 | 19 | } 20 | int main() { 21 | 22 | cin>>n; 23 | init(n); 24 | if(a_win[n-1]||a_win[n-2])cout<<'B'; 25 | else cout<<'A'; 26 | return 0; 27 | } -------------------------------------------------------------------------------- /exercise5/vr5_1.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/4/23. 3 | // 4 | #include "iostream" 5 | using namespace std; 6 | int main(){ 7 | int n; 8 | cin >> n; 9 | //cout << n; 10 | if(n >= 3){ 11 | cout << "B" << endl; 12 | } else { 13 | cout << "A" << endl; 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /exercise5/vr5_2.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/4/23. 3 | // 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | char map[40][40]; 9 | int dir[4][2]= {{1,0},{0,1},{0,-1},{-1,0}}; //走的方向 10 | int sum=1; 11 | int row,col; 12 | struct node 13 | { 14 | int x,y; 15 | } start; //start为起点 16 | queue a; 17 | void bfs() 18 | { 19 | node tmp1,tmp2; 20 | a.push(start); 21 | while(!a.empty()) 22 | { 23 | tmp1=a.front(); 24 | a.pop(); 25 | for(int i=0; i<4; i++) //4个方向搜索 满足条件的插入队尾 26 | { 27 | tmp2.x=tmp1.x+dir[i][0]; 28 | tmp2.y=tmp1.y+dir[i][1]; 29 | if(tmp2.x>=0&&tmp2.x=0&&tmp2.y>col>>row; 41 | for(int i=0; i>map[i][j]; 46 | if (map[i][j]=='@') 47 | { 48 | start.x=i; 49 | start.y=j; 50 | } 51 | } 52 | } 53 | bfs(); 54 | cout<> t; 12 | for (int i = 0; i < t; i++) { 13 | int n,m; 14 | cin >> n >> m; 15 | if(m>=n){ 16 | cout << 100 << endl; 17 | } 18 | for (int j = 1; j <= n; ++j) { // 从1开始 19 | cin >> arr[j]; 20 | //cout << arr[j] << " "; 21 | } 22 | //cout << endl; 23 | arr[n+1] = 101; 24 | int max = -1; 25 | for (int j = 1; j <= n-m+1 ; ++j) { 26 | int apple = arr[j+m] - arr[j-1] - 1; 27 | if (apple > max) max = apple; 28 | } 29 | if(max == -1) continue; 30 | cout << max << endl; 31 | } 32 | } -------------------------------------------------------------------------------- /exercise5/vr5_4.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/5/10. 3 | // 4 | #include 5 | using namespace std; 6 | int arr[8][8]; 7 | int vis[8][8]; 8 | bool check() 9 | { 10 | for (int i = 1; i < 5; i++) 11 | for (int j = 1; j < 7; j++) 12 | vis[i + 1][j] = (arr[i][j] + vis[i][j - 1] + vis[i][j] + vis[i][j + 1] + vis[i - 1][j]) % 2; 13 | 14 | for (int i = 1; i < 7; i++) 15 | { 16 | if ((vis[5][i - 1] + vis[5][i] + vis[5][i + 1] + vis[4][i]) % 2 != arr[5][i]) 17 | return false; 18 | } 19 | return true; 20 | } 21 | 22 | void sol() 23 | { 24 | for (int i = 1; i < 7; i++) 25 | vis[1][i] = 0; 26 | while (!check()) 27 | { 28 | vis[1][1]++; 29 | int tag = 1; 30 | while (vis[1][tag] > 1) 31 | { 32 | vis[1][tag] = 0; 33 | tag++; 34 | vis[1][tag]++; 35 | } 36 | } 37 | } 38 | 39 | int main() 40 | { 41 | int round; 42 | cin >> round; 43 | for (int k = 0; k< round; k++) 44 | { 45 | cout<<"PUZZLE #"<> arr[i][j]; 59 | } 60 | } 61 | sol(); 62 | for (int i = 1; i < 6; i++) 63 | { 64 | for (int j = 1; j < 7; j++) 65 | { 66 | cout << vis[i][j] << " "; 67 | } 68 | cout << endl; 69 | } 70 | } 71 | return 0; 72 | } -------------------------------------------------------------------------------- /exercise5/vr5_5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #define db double 7 | #define CLR(x) memset(x,0,sizeof(x)) 8 | using namespace std; 9 | const db eps=1e-5; 10 | db a[5]; 11 | int vis[5]; 12 | int dfs(int step) 13 | { 14 | if(step==1){ 15 | if(fabs(a[0]-24) 5 | 6 | using namespace std; 7 | 8 | void Qsort(int arr[], int low, int high){ 9 | if (high <= low) return; 10 | int i = low; 11 | int j = high; 12 | int key = arr[low]; 13 | while (true) 14 | { 15 | /*从左向右找比key大的值*/ 16 | while (arr[i] <= key) 17 | { 18 | i++; 19 | if (i == high){ 20 | break; 21 | } 22 | } 23 | /*从右向左找比key小的值*/ 24 | while (arr[j] >= key) 25 | { 26 | j--; 27 | if (j == low){ 28 | break; 29 | } 30 | } 31 | if (i >= j) break; 32 | /*交换i,j对应的值*/ 33 | int temp = arr[i]; 34 | arr[i] = arr[j]; 35 | arr[j] = temp; 36 | } 37 | /*中枢值与j对应值交换*/ 38 | arr[low] = arr[j]; 39 | arr[j] = key; 40 | Qsort(arr, low, j - 1); 41 | Qsort(arr, j + 1, high); 42 | } 43 | 44 | int a[500]; 45 | 46 | int main() 47 | { 48 | //int a[] = {57, 68, 59, 52, 72, 28, 96, 33, 24}; 49 | int n; 50 | cin >> n; 51 | for (int i = 0; i < n; ++i) { 52 | cin >> a[i]; 53 | cout << a[i] << " "; 54 | } 55 | cout << endl << "after sorting:" << endl; 56 | Qsort(a, 0, n - 1);/*这里原文第三个参数要减1否则内存越界*/ 57 | 58 | for(int i = 0; i < n; i++) 59 | { 60 | cout << a[i] << " "; 61 | } 62 | 63 | return 0; 64 | } -------------------------------------------------------------------------------- /exercise5/vr5_8.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cakeal on 2023/5/10. 3 | // 4 | 5 | #include 6 | #include "algorithm" 7 | using namespace std; 8 | int main() 9 | { 10 | // int DTH, HZH, PYH, TH; 11 | // int A, B, C, D; 12 | // for (DTH = 1; DTH <= 4; DTH++) 13 | // for (HZH = 1; HZH <= 4; HZH++) 14 | // for (PYH = 1; PYH <= 4; PYH++) 15 | // for (TH = 1; TH <= 4; TH++) 16 | // { 17 | // A = (DTH == 1) + (HZH == 4) + (PYH == 3); 18 | // B = (HZH == 1) + (DTH == 4) + (PYH == 2) + (TH == 3); 19 | // C = (HZH == 4) + (DTH == 3); 20 | // D = (PYH == 1) + (TH == 4) + (HZH == 2) + (DTH == 3); 21 | // if ((A * B * C * D == 1)&&(DTH*HZH*PYH*TH==24)) 22 | // { 23 | // cout << "洞庭湖排名第" << DTH << endl; 24 | // cout << "洪泽湖排名第" << HZH << endl; 25 | // cout << "鄱阳湖排名第" << PYH << endl; 26 | // cout << "太湖排名第" << TH << endl; 27 | // break; 28 | // } 29 | // } 30 | cout << "Hongze Lake\n" 31 | "\n" 32 | "Tai Lake\n" 33 | "\n" 34 | "Dongting Lake\n" 35 | "\n" 36 | "Boyang Lake" << endl; 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /planebattle/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /planebattle/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /planebattle/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /planebattle/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /planebattle/Bullet.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/14. 3 | // 4 | 5 | #ifndef PLANEBATTLE_BULLET_H 6 | #define PLANEBATTLE_BULLET_H 7 | 8 | 9 | class Bullet { 10 | public: 11 | Bullet(int bulletType, int x, int y); 12 | void printBullet() const; 13 | void clearBullet() const; 14 | static void moveUpBullet(); 15 | static void meetEnemy(Bullet &bullet); 16 | static void moveDownBullet(); 17 | 18 | int bulletType; // 3为我方子弹,4为敌方子弹 19 | int x; 20 | int y; 21 | }; 22 | 23 | 24 | #endif //PLANEBATTLE_BULLET_H 25 | -------------------------------------------------------------------------------- /planebattle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.23) 2 | project(planebattle) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | 6 | set(CMAKE_EXE_LINKER_FLAGS "-static") 7 | 8 | add_executable(planebattle main.cpp 9 | MyPlane.cpp MyPlane.h 10 | ConsoleOperator.cpp ConsoleOperator.h 11 | EnemyPlane.cpp EnemyPlane.h 12 | TheMap.cpp TheMap.h 13 | Bullet.cpp Bullet.h) 14 | -------------------------------------------------------------------------------- /planebattle/ConsoleOperator.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/11. 3 | // 4 | 5 | #include "ConsoleOperator.h" 6 | #include "windows.h" 7 | 8 | void ConsoleOperator::gotoXY(int x, int y){ // 光标移动到x,y位置 9 | COORD pos = {(short)y, (short)x}; 10 | HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); //获取标准输出句柄 11 | SetConsoleCursorPosition(hOut, pos); 12 | } 13 | 14 | void ConsoleOperator::HideCursor(){ 15 | CONSOLE_CURSOR_INFO cursor_info = {1, 0}; //第二个值为0表示隐藏光标 16 | SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); 17 | } 18 | 19 | // 设置窗口控制台大小(需要使用旧版控制台) 20 | void ConsoleOperator::SetConsoleWindowSize( short width, short height ) 21 | { 22 | HANDLE hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); 23 | SMALL_RECT wrt = { 0, 0, static_cast(width-1), static_cast(height-1) }; 24 | SetConsoleWindowInfo( hStdOutput, TRUE, &wrt ); // 设置窗体尺寸 25 | COORD coord = { width, height }; 26 | SetConsoleScreenBufferSize( hStdOutput, coord ); // 设置缓冲尺寸 27 | } -------------------------------------------------------------------------------- /planebattle/ConsoleOperator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/11. 3 | // 4 | 5 | #ifndef PLANEBATTLE_CONSOLEOPERATOR_H 6 | #define PLANEBATTLE_CONSOLEOPERATOR_H 7 | 8 | 9 | class ConsoleOperator { 10 | public: 11 | static void gotoXY(int x, int y); 12 | static void HideCursor(); 13 | static void SetConsoleWindowSize( short width, short height ); 14 | }; 15 | 16 | 17 | #endif //PLANEBATTLE_CONSOLEOPERATOR_H 18 | -------------------------------------------------------------------------------- /planebattle/EnemyPlane.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/11. 3 | // 4 | 5 | #ifndef PLANEBATTLE_ENEMYPLANE_H 6 | #define PLANEBATTLE_ENEMYPLANE_H 7 | #include 8 | #include "Bullet.h" 9 | 10 | class EnemyPlane { 11 | public: 12 | EnemyPlane(); 13 | void printEnemy() const; 14 | void clearEnemy() const; 15 | static void spawnAnEnemy(); // 生成一个敌机 16 | static void moveEnemy(); //每半秒,飞机向下移动一格 17 | static void spawnABullet(); 18 | 19 | static int max_enemy; 20 | static int id; 21 | int x, y; //当前敌机坐标 22 | int the_id; 23 | static std::vector enemys; 24 | static std::vector enemysBullet; 25 | }; 26 | 27 | 28 | #endif //PLANEBATTLE_ENEMYPLANE_H 29 | -------------------------------------------------------------------------------- /planebattle/MyPlane.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/11. 3 | // 4 | 5 | #ifndef PLANEBATTLE_MYPLANE_H 6 | #define PLANEBATTLE_MYPLANE_H 7 | #include 8 | #include "Bullet.h" 9 | 10 | class MyPlane { 11 | public: 12 | MyPlane(); 13 | static unsigned int getPoints(); //获得分数 14 | static void printPlane(int x, int y); //打印飞机 15 | static void movePlane(int& x, int& y); //进行检测按键,同时移动飞机 16 | static void clearPlane(int x, int y); //清除上一帧的飞机 17 | static void spawnABullet(int x, int y); 18 | 19 | static std::vector myPlaneBullet; 20 | static unsigned int points; //我方分数 21 | }; 22 | 23 | 24 | #endif //PLANEBATTLE_MYPLANE_H 25 | -------------------------------------------------------------------------------- /planebattle/TheMap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/11. 3 | // 4 | 5 | #include "TheMap.h" 6 | #include "ConsoleOperator.h" 7 | #include "MyPlane.h" 8 | #include "iostream" 9 | 10 | 11 | void TheMap::printPoints() { 12 | ConsoleOperator::gotoXY(39,5); 13 | std::cout << "Now the points is: " << MyPlane::getPoints() - 1; 14 | } 15 | -------------------------------------------------------------------------------- /planebattle/TheMap.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/11. 3 | // 4 | 5 | #ifndef PLANEBATTLE_THEMAP_H 6 | #define PLANEBATTLE_THEMAP_H 7 | 8 | 9 | class TheMap { 10 | public: 11 | // map中标记1为我方,2为敌机,3为我方子弹,4为敌方子弹 12 | static int map[40][60]; //战场地图,高度为35(2~36),宽度为55(3~58),括号内为对应使用的二维数组的值 13 | static int bulletMap[40][60]; //子弹地图 14 | static void printPoints(); 15 | }; 16 | 17 | 18 | #endif //PLANEBATTLE_THEMAP_H 19 | -------------------------------------------------------------------------------- /planebattle/img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/planebattle/img.png -------------------------------------------------------------------------------- /planebattle/readme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/planebattle/readme.png -------------------------------------------------------------------------------- /planebattle/飞机大战的游戏设计.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/planebattle/飞机大战的游戏设计.docx -------------------------------------------------------------------------------- /qt_plane/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /qt_plane/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /qt_plane/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /qt_plane/Bullet.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/14. 3 | // 4 | 5 | #ifndef PLANEBATTLE_BULLET_H 6 | #define PLANEBATTLE_BULLET_H 7 | #include 8 | #include "gameui.h" 9 | 10 | class Bullet { 11 | public: 12 | Bullet(int bulletType, int x, int y, Ui::GameUI *ui, QWidget *widget, GameUI *gameui); 13 | void printBullet() const; 14 | void clearBullet() const; 15 | static void moveUpBullet(); 16 | static void meetEnemy(Bullet &bullet); 17 | static void moveDownBullet(); 18 | 19 | int bulletType; // 3为我方子弹,4为敌方子弹 20 | int x; 21 | int y; 22 | QLabel *bulletLabel; 23 | }; 24 | 25 | 26 | #endif //PLANEBATTLE_BULLET_H 27 | -------------------------------------------------------------------------------- /qt_plane/Enemy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/qt_plane/Enemy.png -------------------------------------------------------------------------------- /qt_plane/EnemyPlane.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/11. 3 | // 4 | 5 | #ifndef PLANEBATTLE_ENEMYPLANE_H 6 | #define PLANEBATTLE_ENEMYPLANE_H 7 | #include 8 | #include "Bullet.h" 9 | 10 | class EnemyPlane { 11 | public: 12 | EnemyPlane(); 13 | void printEnemy() const; 14 | void clearEnemy() const; 15 | static void spawnAnEnemy(); // 生成一个敌机 16 | static void moveEnemy(); //每半秒,飞机向下移动一格 17 | static void spawnABullet(Ui::GameUI *ui, QWidget *widget, GameUI *gameui); 18 | 19 | static int max_enemy; 20 | static int id; 21 | int x, y; //当前敌机坐标 22 | int the_id; 23 | static std::vector enemys; 24 | static std::vector enemysBullet; 25 | }; 26 | 27 | 28 | #endif //PLANEBATTLE_ENEMYPLANE_H 29 | -------------------------------------------------------------------------------- /qt_plane/MyPlane.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/11. 3 | // 4 | 5 | #ifndef PLANEBATTLE_MYPLANE_H 6 | #define PLANEBATTLE_MYPLANE_H 7 | #include 8 | #include "Bullet.h" 9 | #include 10 | 11 | class MyPlane { 12 | public: 13 | MyPlane(); 14 | static unsigned int getPoints(); //获得分数 15 | static void printPlane(int x, int y, QLabel *myPlaneLabel); //打印飞机 16 | static void movePlane(int& x, int& y, Ui::GameUI *ui, char key, QWidget *widget, GameUI *gameui); //进行检测按键,同时移动飞机 17 | static void clearPlane(int x, int y); //清除上一帧的飞机 18 | static void spawnABullet(int x, int y, Ui::GameUI *ui, QWidget *widget, GameUI *gameui); 19 | 20 | static std::vector myPlaneBullet; 21 | static unsigned int points; //我方分数 22 | }; 23 | 24 | 25 | #endif //PLANEBATTLE_MYPLANE_H 26 | -------------------------------------------------------------------------------- /qt_plane/Myplane.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/qt_plane/Myplane.png -------------------------------------------------------------------------------- /qt_plane/TheMap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/11. 3 | // 4 | 5 | #include "TheMap.h" 6 | //#include "ConsoleOperator.h" 7 | #include "MyPlane.h" 8 | #include "iostream" 9 | 10 | 11 | void TheMap::printPoints() { 12 | // ConsoleOperator::gotoXY(39,5); 13 | // std::cout << "Now the points is: " << MyPlane::getPoints() - 1; 14 | } 15 | -------------------------------------------------------------------------------- /qt_plane/TheMap.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by CakeAL on 2023/5/11. 3 | // 4 | 5 | #ifndef PLANEBATTLE_THEMAP_H 6 | #define PLANEBATTLE_THEMAP_H 7 | 8 | 9 | class TheMap { 10 | public: 11 | // map中标记1为我方,2为敌机,3为我方子弹,4为敌方子弹 12 | static int map[40][60]; //战场地图,高度为35(2~36),宽度为55(3~58),括号内为对应使用的二维数组的值 13 | static int bulletMap[40][60]; //子弹地图 14 | static void printPoints(); 15 | }; 16 | 17 | 18 | #endif //PLANEBATTLE_THEMAP_H 19 | -------------------------------------------------------------------------------- /qt_plane/bullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/qt_plane/bullet.png -------------------------------------------------------------------------------- /qt_plane/cmake-build-debug/.cmake/api/v1/query/cache-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/qt_plane/cmake-build-debug/.cmake/api/v1/query/cache-v2 -------------------------------------------------------------------------------- /qt_plane/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/qt_plane/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 -------------------------------------------------------------------------------- /qt_plane/cmake-build-debug/.cmake/api/v1/query/codemodel-v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/qt_plane/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 -------------------------------------------------------------------------------- /qt_plane/cmake-build-debug/.cmake/api/v1/query/toolchains-v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/qt_plane/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 -------------------------------------------------------------------------------- /qt_plane/cmake-build-debug/CMakeFiles/3.25.2/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/qt_plane/cmake-build-debug/CMakeFiles/3.25.2/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /qt_plane/cmake-build-debug/CMakeFiles/3.25.2/CMakeRCCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_RC_COMPILER "C:/Program Files/JetBrains/CLion 2022.2.4/bin/mingw/bin/windres.exe") 2 | set(CMAKE_RC_COMPILER_ARG1 "") 3 | set(CMAKE_RC_COMPILER_LOADED 1) 4 | set(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc;RC) 5 | set(CMAKE_RC_OUTPUT_EXTENSION .obj) 6 | set(CMAKE_RC_COMPILER_ENV_VAR "RC") 7 | -------------------------------------------------------------------------------- /qt_plane/cmake-build-debug/CMakeFiles/3.25.2/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Windows-10.0.22621") 2 | set(CMAKE_HOST_SYSTEM_NAME "Windows") 3 | set(CMAKE_HOST_SYSTEM_VERSION "10.0.22621") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "AMD64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Windows-10.0.22621") 9 | set(CMAKE_SYSTEM_NAME "Windows") 10 | set(CMAKE_SYSTEM_VERSION "10.0.22621") 11 | set(CMAKE_SYSTEM_PROCESSOR "AMD64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /qt_plane/cmake-build-debug/CMakeFiles/3.25.2/CompilerIdCXX/a.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/qt_plane/cmake-build-debug/CMakeFiles/3.25.2/CompilerIdCXX/a.exe -------------------------------------------------------------------------------- /qt_plane/cmake-build-debug/CMakeFiles/clion-Debug-log.txt: -------------------------------------------------------------------------------- 1 | "C:\Program Files\JetBrains\CLion 2022.2.4\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2022.2.4/bin/ninja/win/x64/ninja.exe" -G Ninja -S C:\Users\CakeAL\Desktop\qt_plane -B C:\Users\CakeAL\Desktop\qt_plane\cmake-build-debug 2 | -- The CXX compiler identification is GNU 11.2.0 3 | -- Detecting CXX compiler ABI info 4 | -- Detecting CXX compiler ABI info - done 5 | -- Check for working CXX compiler: C:/Program Files/JetBrains/CLion 2022.2.4/bin/mingw/bin/g++.exe - skipped 6 | -- Detecting CXX compile features 7 | -- Detecting CXX compile features - done 8 | CMake Error at CMakeLists.txt:12 (find_package): 9 | Could not find a package configuration file provided by "QT" with any of 10 | the following names: 11 | 12 | Qt6Config.cmake 13 | qt6-config.cmake 14 | Qt5Config.cmake 15 | qt5-config.cmake 16 | 17 | Add the installation prefix of "QT" to CMAKE_PREFIX_PATH or set "QT_DIR" to 18 | a directory containing one of the above files. If "QT" provides a separate 19 | development package or SDK, be sure it has been installed. 20 | 21 | 22 | -- Configuring incomplete, errors occurred! 23 | See also "C:/Users/CakeAL/Desktop/qt_plane/cmake-build-debug/CMakeFiles/CMakeOutput.log". 24 | -------------------------------------------------------------------------------- /qt_plane/cmake-build-debug/CMakeFiles/clion-environment.txt: -------------------------------------------------------------------------------- 1 | ToolSet: w64 9.0 (local)@C:\Program Files\JetBrains\CLion 2022.2.4\bin\mingw 2 | Options: 3 | 4 | Options:-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2022.2.4/bin/ninja/win/x64/ninja.exe -------------------------------------------------------------------------------- /qt_plane/cmake-build-debug/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /qt_plane/gameui.h: -------------------------------------------------------------------------------- 1 | #ifndef GAMEUI_H 2 | #define GAMEUI_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class GameUI; 8 | } 9 | 10 | class GameUI : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit GameUI(QWidget *parent = nullptr); 16 | ~GameUI(); 17 | QWidget *par_widget; 18 | 19 | private: 20 | Ui::GameUI *ui; 21 | void keyPressEvent(QKeyEvent *event) override; 22 | void keyReleaseEvent(QKeyEvent *event) override; 23 | private slots: 24 | void recvGameUI(); 25 | void mainloop();; 26 | }; 27 | 28 | #endif // GAMEUI_H 29 | -------------------------------------------------------------------------------- /qt_plane/gameui.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | GameUI 4 | 5 | 6 | 7 | 0 8 | 0 9 | 760 10 | 984 11 | 12 | 13 | 14 | 飞机大战 15 | 16 | 17 | 18 | 19 | 360 20 | 830 21 | 50 22 | 50 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 610 33 | 650 34 | 69 35 | 19 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /qt_plane/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | MainWindow w; 9 | w.setStyleSheet("background-color: #fbecde"); 10 | w.show(); 11 | return a.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /qt_plane/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "./ui_mainwindow.h" 3 | #include "gameui.h" 4 | 5 | MainWindow::MainWindow(QWidget *parent) 6 | : QMainWindow(parent) 7 | , ui(new Ui::MainWindow) 8 | { 9 | ui->setupUi(this); 10 | } 11 | 12 | MainWindow::~MainWindow() 13 | { 14 | delete ui; 15 | } 16 | 17 | 18 | void MainWindow::on_start_clicked() 19 | { 20 | static GameUI w1; 21 | w1.setStyleSheet("background-color: #fbecde"); 22 | QObject::connect(this,SIGNAL(showGameUI()),&w1,SLOT(recvGameUI())); 23 | //qDebug() << QString::fromStdString( Log_on_User ); 24 | this->hide(); //隐藏本页面 25 | emit showGameUI(); //激活信号 26 | } 27 | -------------------------------------------------------------------------------- /qt_plane/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class MainWindow; } 8 | QT_END_NAMESPACE 9 | 10 | class MainWindow : public QMainWindow 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | MainWindow(QWidget *parent = nullptr); 16 | ~MainWindow(); 17 | 18 | private slots: 19 | void on_start_clicked(); 20 | signals: 21 | void showGameUI(); 22 | 23 | private: 24 | Ui::MainWindow *ui; 25 | }; 26 | #endif // MAINWINDOW_H 27 | -------------------------------------------------------------------------------- /qt_plane/qt做的plane.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CakeAL/ustb-cpp-programming/c19629576583881963a6b1441200f97e7b47c7e6/qt_plane/qt做的plane.docx --------------------------------------------------------------------------------