├── 8-1 Students I
├── README.md
└── Student1
│ ├── ReadMe.txt
│ ├── Student1.cpp
│ ├── Student1.exe
│ ├── Student1.vcxproj
│ ├── Student1.vcxproj.filters
│ ├── Text.txt
│ ├── stdafx.cpp
│ ├── stdafx.h
│ └── targetver.h
├── 8-2 Students II
├── README.md
└── Student2
│ ├── ReadMe.txt
│ ├── Student2.cpp
│ ├── Student2.exe
│ ├── Student2.h
│ ├── Student2.vcxproj
│ ├── Student2.vcxproj.filters
│ ├── Student2Test.cpp
│ ├── Text.txt
│ ├── stdafx.cpp
│ ├── stdafx.h
│ └── targetver.h
├── 8-3 Adventure
├── Adventure
│ ├── Adventure.cpp
│ ├── Adventure.exe
│ ├── Adventure.vcxproj
│ ├── Adventure.vcxproj.filters
│ ├── MyCastle.txt
│ ├── ReadMe.txt
│ ├── castle.cpp
│ ├── castle.h
│ ├── stdafx.cpp
│ ├── stdafx.h
│ └── targetver.h
└── README.md
├── 8-4 Personal Diary
├── Personal Diary
│ ├── Diary.cpp
│ ├── Diary.h
│ ├── ReadMe.txt
│ ├── diary.txt
│ ├── pdadd.cpp
│ ├── pdadd.exe
│ ├── pdadd.vcxproj
│ ├── pdadd.vcxproj.filters
│ ├── pdadd_test.txt
│ ├── pdlist.cpp
│ ├── pdlist.exe
│ ├── pdlist.vcxproj
│ ├── pdlist.vcxproj.filters
│ ├── pdlist_test.txt
│ ├── pdremove.cpp
│ ├── pdremove.exe
│ ├── pdremove.vcxproj
│ ├── pdremove.vcxproj.filters
│ ├── pdremove_test.txt
│ ├── pdshow.cpp
│ ├── pdshow.exe
│ ├── pdshow.vcxproj
│ ├── pdshow.vcxproj.filters
│ ├── pdshow_test.txt
│ ├── stdafx.cpp
│ ├── stdafx.h
│ └── targetver.h
├── README.md
└── 作业四 - 说明.pdf
├── 8-5 Fraction
├── README.md
└── fraction
│ ├── FractionTest.cpp
│ ├── ReadMe.txt
│ ├── fraction.cpp
│ ├── fraction.exe
│ ├── fraction.h
│ ├── fraction.vcxproj
│ ├── fraction.vcxproj.filters
│ ├── stdafx.cpp
│ ├── stdafx.h
│ └── targetver.h
├── 8-6 Vector
├── README.md
└── vector
│ ├── ReadMe.txt
│ ├── stdafx.cpp
│ ├── stdafx.h
│ ├── targetver.h
│ ├── test.cpp
│ ├── vector.cpp
│ ├── vector.exe
│ ├── vector.h
│ ├── vector.vcxproj
│ └── vector.vcxproj.filters
├── 8-7 STL allocator + memory pool (group work)
├── Figure1.png
├── MyAllocator
│ ├── code
│ │ ├── TestMyAllocator.cpp
│ │ ├── TestWithFile.cpp
│ │ ├── generate.cpp
│ │ └── myallocator.h
│ ├── executable file
│ │ ├── TestMyAllocator
│ │ │ └── MyAllocator.exe
│ │ ├── TestWithFile
│ │ │ └── MyAllocator.exe
│ │ └── generate.exe
│ └── test file
│ │ ├── test0.txt
│ │ ├── test1.txt
│ │ ├── test10.txt
│ │ ├── test2.txt
│ │ ├── test3.txt
│ │ ├── test4.txt
│ │ ├── test5.txt
│ │ ├── test6.txt
│ │ ├── test7.txt
│ │ ├── test8.txt
│ │ └── test9.txt
├── README.md
└── STL Allocator + Mem pool + 大作业要求.pptx
└── README.md
/8-1 Students I/README.md:
--------------------------------------------------------------------------------
1 | # 8-1 Students I (10 分)
2 |
3 | Write a program that asks you 10 records of students. Each record consists of a name (w/o space), and scores for three courses (in integer, 1 to 5). Output a list as following and calculate average score (in float) of each student and each course. Output the lowest and highest score for each course.
4 |
5 | ```
6 | no name score1 score2 score3 average
7 | 1 K.Weng 5 5 5 5
8 | 2 T.Dixon 4 3 2 3
9 | 3 V.Chu 3 4 5 4
10 | 4 L.Tson 4 3 4 3.66667
11 | 5 L.Lee 3 4 3 3.33333
12 | 6 I.Young 4 2 5 3.66667
13 | 7 K.Hiro 4 2 1 2.33333
14 | 8 G.Ping 4 4 4 4
15 | 9 H.Gu 2 3 4 3
16 | 10 J.Jon 5 4 3 4
17 | average 3.8 3.4 3.6
18 | min 2 2 1
19 | max 5 5 5
20 | ```
21 |
22 | **Evaluation standard**
23 |
24 | 1. result correctness
25 | 2. c++ code quality (compact and reasonable)
26 | 3. comments quality (clean and accurate)
27 | 4. c functions like `printf` and `scanf` are not allowed
28 |
29 | **Required Files**: source code, makefile (Mac, Linux), exe (Windows)
--------------------------------------------------------------------------------
/8-1 Students I/Student1/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | 控制台应用程序:Student1 项目概述
3 | ========================================================================
4 |
5 | 应用程序向导已为您创建了此 Student1 应用程序。
6 |
7 | 本文件概要介绍组成 Student1 应用程序的每个文件的内容。
8 |
9 |
10 | Student1.vcxproj
11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
12 |
13 | Student1.vcxproj.filters
14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
15 |
16 | Student1.cpp
17 | 这是主应用程序源文件。
18 |
19 | /////////////////////////////////////////////////////////////////////////////
20 | 其他标准文件:
21 |
22 | StdAfx.h, StdAfx.cpp
23 | 这些文件用于生成名为 Student1.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
24 |
25 | /////////////////////////////////////////////////////////////////////////////
26 | 其他注释:
27 |
28 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
29 |
30 | /////////////////////////////////////////////////////////////////////////////
31 |
--------------------------------------------------------------------------------
/8-1 Students I/Student1/Student1.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-1 Students I/Student1/Student1.cpp
--------------------------------------------------------------------------------
/8-1 Students I/Student1/Student1.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-1 Students I/Student1/Student1.exe
--------------------------------------------------------------------------------
/8-1 Students I/Student1/Student1.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {B2C5FC27-00E3-4DDD-BDD0-17E5060373B3}
23 | Win32Proj
24 | Student1
25 | 8.1
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | Unicode
40 |
41 |
42 | Application
43 | true
44 | v140
45 | Unicode
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | Unicode
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | true
74 |
75 |
76 | true
77 |
78 |
79 | false
80 |
81 |
82 | false
83 |
84 |
85 |
86 | Use
87 | Level3
88 | Disabled
89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
90 | true
91 |
92 |
93 | Console
94 | true
95 |
96 |
97 |
98 |
99 | Use
100 | Level3
101 | Disabled
102 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
103 | true
104 |
105 |
106 | Console
107 | true
108 |
109 |
110 |
111 |
112 | Level3
113 | Use
114 | MaxSpeed
115 | true
116 | true
117 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
118 | true
119 |
120 |
121 | Console
122 | true
123 | true
124 | true
125 |
126 |
127 |
128 |
129 | Level3
130 | Use
131 | MaxSpeed
132 | true
133 | true
134 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
135 | true
136 |
137 |
138 | Console
139 | true
140 | true
141 | true
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 | Create
155 | Create
156 | Create
157 | Create
158 |
159 |
160 |
161 |
162 |
163 |
164 |
--------------------------------------------------------------------------------
/8-1 Students I/Student1/Student1.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 | 资源文件
21 |
22 |
23 |
24 |
25 | 头文件
26 |
27 |
28 | 头文件
29 |
30 |
31 |
32 |
33 | 源文件
34 |
35 |
36 | 源文件
37 |
38 |
39 |
--------------------------------------------------------------------------------
/8-1 Students I/Student1/Text.txt:
--------------------------------------------------------------------------------
1 | K.Weng 5 5 5
2 | T.Dixon 4 3 2
3 | V.Chu 3 4 5
4 | L.Tson 4 3 4
5 | L.Lee 3 4 3
6 | I.Young 4 2 5
7 | K.Hiro 4 2 1
8 | G.Ping 4 4 4
9 | H.Gu 2 3 4
10 | J.Jon 5 4 3
--------------------------------------------------------------------------------
/8-1 Students I/Student1/stdafx.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-1 Students I/Student1/stdafx.cpp
--------------------------------------------------------------------------------
/8-1 Students I/Student1/stdafx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-1 Students I/Student1/stdafx.h
--------------------------------------------------------------------------------
/8-1 Students I/Student1/targetver.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-1 Students I/Student1/targetver.h
--------------------------------------------------------------------------------
/8-2 Students II/README.md:
--------------------------------------------------------------------------------
1 | # 8-2 Students II (10 分)
2 |
3 | Write a CLI program that reads scores and names of students, and prints out a summary sheet (in the same format with the last homework "Students I"). The user can input as many students as possible. One student can have as many courses as possible. One course consists the name of the course and the scores the students got. Please note that a student won't choose every available course in general.
4 |
5 | **Evaluation standard**
6 |
7 | 1. c++ code quality (clean, compact and reasonable)
8 | 2. comments quality
9 |
10 | **Required Files**
11 |
12 | Please prepare a zip package including the following items:
13 |
14 | 1. the source code
15 | 2. a makefile (Mac, Linux) or exe (Windows), depending on your development environment
16 | 3. an external input file of your test data
--------------------------------------------------------------------------------
/8-2 Students II/Student2/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | 控制台应用程序:Student2 项目概述
3 | ========================================================================
4 |
5 | 应用程序向导已为您创建了此 Student2 应用程序。
6 |
7 | 本文件概要介绍组成 Student2 应用程序的每个文件的内容。
8 |
9 |
10 | Student2.vcxproj
11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
12 |
13 | Student2.vcxproj.filters
14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
15 |
16 | Student2.cpp
17 | 这是主应用程序源文件。
18 |
19 | /////////////////////////////////////////////////////////////////////////////
20 | 其他标准文件:
21 |
22 | StdAfx.h, StdAfx.cpp
23 | 这些文件用于生成名为 Student2.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
24 |
25 | /////////////////////////////////////////////////////////////////////////////
26 | 其他注释:
27 |
28 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
29 |
30 | /////////////////////////////////////////////////////////////////////////////
31 |
--------------------------------------------------------------------------------
/8-2 Students II/Student2/Student2.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-2 Students II/Student2/Student2.cpp
--------------------------------------------------------------------------------
/8-2 Students II/Student2/Student2.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-2 Students II/Student2/Student2.exe
--------------------------------------------------------------------------------
/8-2 Students II/Student2/Student2.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef STUDENT2_H
4 | #define STUDENT2_H
5 |
6 | class Student {
7 | private:
8 | string name;//student name
9 | struct Course {
10 | string name;
11 | int score;//-1 means not taken
12 | };//name and score for each course
13 | vector courses;//all course chosen
14 | int coursenum;//number of courses taken
15 | double average;//average score of all courses
16 |
17 | public:
18 | vector read();//read in the data from the file
19 | void StuAverage(vector Stu);//calculate average score of a student
20 | void CourAMM(vector Stu);//calculate average,max,min score of a course
21 | void output(vector Stu);//output the table
22 | };
23 |
24 | #endif
--------------------------------------------------------------------------------
/8-2 Students II/Student2/Student2.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {61DD8121-334B-44BF-93AF-5E6E66271133}
23 | Win32Proj
24 | Student2
25 | 8.1
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | Unicode
40 |
41 |
42 | Application
43 | true
44 | v140
45 | Unicode
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | Unicode
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | true
74 |
75 |
76 | true
77 |
78 |
79 | false
80 |
81 |
82 | false
83 |
84 |
85 |
86 | Use
87 | Level3
88 | Disabled
89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
90 | true
91 |
92 |
93 | Console
94 | true
95 |
96 |
97 |
98 |
99 | Use
100 | Level3
101 | Disabled
102 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
103 | true
104 |
105 |
106 | Console
107 | true
108 |
109 |
110 |
111 |
112 | Level3
113 | Use
114 | MaxSpeed
115 | true
116 | true
117 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
118 | true
119 |
120 |
121 | Console
122 | true
123 | true
124 | true
125 |
126 |
127 |
128 |
129 | Level3
130 | Use
131 | MaxSpeed
132 | true
133 | true
134 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
135 | true
136 |
137 |
138 | Console
139 | true
140 | true
141 | true
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 | Create
155 | Create
156 | Create
157 | Create
158 |
159 |
160 |
161 |
162 |
163 |
164 |
--------------------------------------------------------------------------------
/8-2 Students II/Student2/Student2.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 | 资源文件
21 |
22 |
23 |
24 |
25 | 头文件
26 |
27 |
28 | 头文件
29 |
30 |
31 |
32 |
33 | 源文件
34 |
35 |
36 | 源文件
37 |
38 |
39 |
--------------------------------------------------------------------------------
/8-2 Students II/Student2/Student2Test.cpp:
--------------------------------------------------------------------------------
1 | #include "Student2.h"
2 | #include "stdafx.h"
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | using namespace std;
9 |
10 |
11 | int main()
12 | {
13 | vector Stu = Stu.read();//read in the data from the file
14 | Student.StuAverage(Stu);//calculate average score of a student
15 | CourAMM(Stu);//calculate average,max,min score of a course
16 | output(Stu);//output the table
17 | int i;
18 | cin >> i;//pause
19 | return 0;
20 | }
--------------------------------------------------------------------------------
/8-2 Students II/Student2/Text.txt:
--------------------------------------------------------------------------------
1 | 7
2 | Amy Chinese 1 Math 3 English 1 Physics 5 Chemis 3 Biology 4 History 3
3 | Bob Chinese 4 Math 1 English 2 Physics 5 Chemis 3 Biology 2 History 3
4 | Charles Chinese 3 Math 5 English 5 Physics -1 Chemis 5 Biology 3 History 5
5 | Daisy Chinese 3 Math 5 English 2 Physics 4 Chemis 1 Biology 5 History 2
6 | Elize Chinese 5 Math 2 English 5 Physics 3 Chemis 3 Biology 3 History 4
7 | Peter Chinese 2 Math -1 English 3 Physics 2 Chemis 5 Biology 4 History 4
8 | Tom Chinese 1 Math 3 English 3 Physics 5 Chemis 4 Biology 2 History 5
9 | John Chinese 4 Math 3 English -1 Physics 4 Chemis 2 Biology 3 History 3
10 | Harry Chinese 3 Math 2 English 3 Physics 3 Chemis 5 Biology 5 History 1
--------------------------------------------------------------------------------
/8-2 Students II/Student2/stdafx.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-2 Students II/Student2/stdafx.cpp
--------------------------------------------------------------------------------
/8-2 Students II/Student2/stdafx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-2 Students II/Student2/stdafx.h
--------------------------------------------------------------------------------
/8-2 Students II/Student2/targetver.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-2 Students II/Student2/targetver.h
--------------------------------------------------------------------------------
/8-3 Adventure/Adventure/Adventure.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-3 Adventure/Adventure/Adventure.cpp
--------------------------------------------------------------------------------
/8-3 Adventure/Adventure/Adventure.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-3 Adventure/Adventure/Adventure.exe
--------------------------------------------------------------------------------
/8-3 Adventure/Adventure/Adventure.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {A6EDC7AA-D04A-4162-BA02-4D4CA61B4D32}
23 | Win32Proj
24 | Adventure
25 | 8.1
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | Unicode
40 |
41 |
42 | Application
43 | true
44 | v140
45 | Unicode
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | Unicode
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | true
74 |
75 |
76 | true
77 |
78 |
79 | false
80 |
81 |
82 | false
83 |
84 |
85 |
86 | Use
87 | Level3
88 | Disabled
89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
90 | true
91 |
92 |
93 | Console
94 | true
95 |
96 |
97 |
98 |
99 | Use
100 | Level3
101 | Disabled
102 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
103 | true
104 |
105 |
106 | Console
107 | true
108 |
109 |
110 |
111 |
112 | Level3
113 | Use
114 | MaxSpeed
115 | true
116 | true
117 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
118 | true
119 |
120 |
121 | Console
122 | true
123 | true
124 | true
125 |
126 |
127 |
128 |
129 | Level3
130 | Use
131 | MaxSpeed
132 | true
133 | true
134 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
135 | true
136 |
137 |
138 | Console
139 | true
140 | true
141 | true
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 | Create
158 | Create
159 | Create
160 | Create
161 |
162 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/8-3 Adventure/Adventure/Adventure.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 | 资源文件
21 |
22 |
23 |
24 |
25 | 头文件
26 |
27 |
28 | 头文件
29 |
30 |
31 | 头文件
32 |
33 |
34 |
35 |
36 | 源文件
37 |
38 |
39 | 源文件
40 |
41 |
42 | 源文件
43 |
44 |
45 |
--------------------------------------------------------------------------------
/8-3 Adventure/Adventure/MyCastle.txt:
--------------------------------------------------------------------------------
1 | room0 2 east down
2 | room1 3 east west down
3 | room2 3 east west down
4 | room3 2 west down
5 | room4 2 east down
6 | room5 2 east west
7 | room6 2 west down
8 | room7 3 east up down
9 | room8 4 east west up down
10 | room9 2 west up
11 | room10 2 up down
12 | room11 2 up down
13 | room12 2 east down
14 | room13 2 west up
15 | room14 3 east up down
16 | room15 4 east west up down
17 | room16 2 east west
18 | room17 4 east west up down
19 | room18 3 east west up
20 | room19 4 east west up down
21 | room20 1 west
22 | room21 2 east up
23 | room22 4 east west up down
24 | room23 2 west down
25 | room24 3 east up down
26 | room25 2 east west
27 | room26 3 east west up
28 | room27 2 west down
29 | room28 2 east down
30 | room29 2 west up
31 | room30 3 east up down
32 | room31 3 east west up
33 | room32 2 west down
34 | room33 1 down
35 | room34 2 up down
36 | room35 2 east up
37 | room36 3 east west down
38 | room37 4 east west up down
39 | room38 2 west down
40 | room39 2 up down
41 | room40 3 east up down
42 | room41 2 west up
43 | room42 1 east
44 | room43 2 west up
45 | room44 2 east up
46 | lobby 3 east west up
47 | room46 3 east west up
48 | room47 3 east west up
49 | room48 1 west
--------------------------------------------------------------------------------
/8-3 Adventure/Adventure/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | 控制台应用程序:Adventure 项目概述
3 | ========================================================================
4 |
5 | 应用程序向导已为您创建了此 Adventure 应用程序。
6 |
7 | 本文件概要介绍组成 Adventure 应用程序的每个文件的内容。
8 |
9 |
10 | Adventure.vcxproj
11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
12 |
13 | Adventure.vcxproj.filters
14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
15 |
16 | Adventure.cpp
17 | 这是主应用程序源文件。
18 |
19 | /////////////////////////////////////////////////////////////////////////////
20 | 其他标准文件:
21 |
22 | StdAfx.h, StdAfx.cpp
23 | 这些文件用于生成名为 Adventure.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
24 |
25 | /////////////////////////////////////////////////////////////////////////////
26 | 其他注释:
27 |
28 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
29 |
30 | /////////////////////////////////////////////////////////////////////////////
31 |
--------------------------------------------------------------------------------
/8-3 Adventure/Adventure/castle.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include "castle.h"
8 | using namespace std;
9 |
10 | void PrintInfo(Room *room)
11 | {
12 | cout << "Welcome come to the " << room->roomname << ".";
13 | if (room->ExitNum == 0)
14 | cout << "There is no exit.";//actually it is impossible
15 | else {
16 | cout << "There are " << room->ExitNum << " exits: ";
17 | string name[4];
18 | int i = 0;
19 | if (room->EastExit) name[i++] = "east";
20 | if (room->WestExit) name[i++] = "west";
21 | if (room->UpExit) name[i++] = "up";
22 | if (room->DownExit) name[i++] = "down";
23 | for (i = 0; i < room->ExitNum; i++)
24 | {
25 | cout << name[i];
26 | if (i == room->ExitNum - 2) cout << " and ";
27 | else if (i == room->ExitNum - 1) cout << "." << endl;
28 | else cout << ", ";
29 | }
30 | }
31 | cout << "Enter your command:";
32 | }
33 |
34 | Castle::Castle()
35 | {
36 |
37 | }
38 |
39 | Castle::~Castle() {
40 |
41 | while (!castle.empty()) {
42 | vector::iterator it = castle.end();
43 | castle.pop_back();
44 | delete (*it);
45 | }
46 | }
47 |
48 | void Castle::GetMap()
49 | {
50 | string name;
51 | ifstream file("MyCastle.txt", ios::in);//data of a 9*9 castle map
52 | if (!file)//test if the file is opened successfully
53 | {
54 | cout << "Error opening file." << endl;
55 | return;
56 | }
57 | for (int i = 0; i < 49; i++)
58 | {
59 | Room *room = new Room;
60 | file >> room->roomname >> room->ExitNum;
61 | room->EastExit = room->WestExit = room->UpExit = room->DownExit = false;
62 | room->Monster = room->Princess = false;//initialize
63 | string direction;
64 | for (int i = 0; i < room->ExitNum; i++)
65 | {
66 | file >> direction;
67 | if (direction == "east") room->EastExit = true;
68 | if (direction == "west") room->WestExit = true;
69 | if (direction == "up") room->UpExit = true;
70 | if (direction == "down") room->DownExit = true;
71 | }
72 | castle.push_back(room);
73 | }
74 | file.close();//close the file
75 | }
76 |
77 | void Castle::RandPosition()
78 | {
79 | //a 7*7 castle
80 | int princess = rand() % 49;
81 | int monster = rand() % 49;//0-48
82 | while (princess == monster || princess == 45 || monster == 45) {
83 | //princess and monster not in the lobby and not the same room
84 | princess = rand() % 49;
85 | monster = rand() % 49;
86 | }
87 | castle[princess]->Princess = true;
88 | castle[monster]->Monster = true;
89 | }
90 |
91 | void Castle::Run()
92 | {
93 | //a 7*7 castle
94 | //initial
95 | Room *current = castle[45];//lobby:map[3][6]
96 | int position = 45;
97 |
98 | string go, direct;
99 | while (1) {
100 | PrintInfo(current);
101 | cin >> go >> direct;
102 | //move
103 | if (direct == "east") {
104 | if (!current->EastExit) {
105 | cout << "The exit doesn't exist!" << endl;
106 | continue;
107 | }
108 | else {
109 | position++;
110 | current = castle[position];
111 | }
112 | }
113 | else if (direct == "west") {
114 | if (!current->WestExit) {
115 | cout << "The exit doesn't exist!" << endl;
116 | continue;
117 | }
118 | else {
119 | position--;
120 | current = castle[position];
121 | }
122 | }
123 | else if (direct == "up") {
124 | if (!current->UpExit) {
125 | cout << "The exit doesn't exist!" << endl;
126 | continue;
127 | }
128 | else {
129 | position -= 7;
130 | current = castle[position];
131 | }
132 | }
133 | else if (direct == "down") {
134 | if (!current->DownExit) {
135 | cout << "The exit doesn't exist!" << endl;
136 | continue;
137 | }
138 | else {
139 | position += 7;
140 | current = castle[position];
141 | }
142 | }
143 | //judge
144 | if (current->Monster) {
145 | cout << "You are eaten by the monster! Game over!" << endl;
146 | return;//dead
147 | }
148 | if (current->Princess) {
149 | if (!getPrincess)
150 | getPrincess = true;
151 | cout << "You get the princess,run out of the castle quickly!" << endl;
152 | }
153 | if (getPrincess && position == 45) {
154 | cout << "Successfully save the princess! " << "You win!" << endl;
155 | return;//win
156 | }
157 | }
158 | }
--------------------------------------------------------------------------------
/8-3 Adventure/Adventure/castle.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef CASTLE_H
3 | #define CASTLE_H
4 | #include "stdafx.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | using namespace std;
11 |
12 | struct Room {
13 | string roomname;
14 | int ExitNum;//number of exits
15 | bool EastExit, WestExit, UpExit, DownExit;//exists
16 | bool Monster = false;
17 | bool Princess = false;
18 | };
19 | void PrintInfo(Room *room);
20 |
21 | class Castle {
22 | private:
23 | vector castle;
24 | bool getPrincess = false;
25 | public:
26 | Castle();
27 | ~Castle();
28 | void GetMap();
29 | void RandPosition();
30 | void Run();
31 | };
32 | #endif // !CASTLE_H
33 |
34 |
--------------------------------------------------------------------------------
/8-3 Adventure/Adventure/stdafx.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-3 Adventure/Adventure/stdafx.cpp
--------------------------------------------------------------------------------
/8-3 Adventure/Adventure/stdafx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-3 Adventure/Adventure/stdafx.h
--------------------------------------------------------------------------------
/8-3 Adventure/Adventure/targetver.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cyjjj/OOP/e4e8121a078a7732da235e9a1efb970e54f6b7bf/8-3 Adventure/Adventure/targetver.h
--------------------------------------------------------------------------------
/8-3 Adventure/README.md:
--------------------------------------------------------------------------------
1 | # 8-3 Adventure (20 分)
2 |
3 | **Story**
4 |
5 | Adventure is a CLI game. The player has to explore in the castle with many levels and a lot of rooms. The task of the player is to find a room where the princess is prisoned and take her leave the castle. There are many types of rooms, and each type of room has different types of exits. Note that there's a monster in one of the rooms, which the exact location is not able to be aware. But once the player meets a monster, the game is over.
6 |
7 | When the game starts, the player is in the lobby of the castle. Then the program shows information about the lobby:name of the room, how many exits are there, and names of all exits (e.g.: "east", "south", "up"), like:
8 |
9 | ```
10 | Welcome to the lobby. There are 3 exits: east, west and up.
11 | Enter your command:
12 | ```
13 |
14 | The player then can input "go" followed by the name of one exit to enter the room connected to that door, like:
15 |
16 | ```
17 | go east
18 | ```
19 |
20 | The player goes into the room to the east. The program shows the information about that room, like what happened in the lobby just now. And the player may input command to choose another room.
21 |
22 | Once the player enters a room with a monster, the program shows a message and game over. Once the player enters the room of princess, the program shows a message about the princess, and the princess is going to leave with the player. The player then has to find their way out the castle. The only way to leave the castle is via the lobby.
23 |
24 | All printed messages and user input are in English to simplify the code.
25 |
26 | **Evaluation standard**
27 |
28 | 1. c++ code quality (clean, compact and reasonable)
29 | 2. comments quality
30 | 3. at least three different kinds of rooms
31 | 4. at least five rooms
32 | 5. the room with monster or princess is randomly set
33 |
34 | **Required Files**
35 |
36 | Please prepare a zip package including the following items:
37 |
38 | 1. the source code
39 | 2. a makefile (Mac, Linux) or exe (Windows), depending on your development environment
40 | 3. an external input file with your test data
--------------------------------------------------------------------------------
/8-4 Personal Diary/Personal Diary/Diary.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "Diary.h"
3 |
4 | void Diary::Reset()
5 | {
6 | text.clear();
7 | }
8 |
9 | void Diary::SetText()
10 | {
11 | string str;
12 | getline(cin, str);
13 | while (str != ".")
14 | {
15 | text.push_back(str);
16 | getline(cin, str);
17 | }
18 | }
19 |
20 | void Diary::SetDate(string d)
21 | {
22 | date = d;
23 | }
24 |
25 | void Diary::AddLine(string Line)
26 | {
27 | text.push_back(Line);
28 | }
29 |
30 | string Diary::GetText(VStringSize i)
31 | {
32 | return text[i];
33 | }
34 |
35 | string Diary::GetDate()
36 | {
37 | return date;
38 | }
39 |
40 | VStringSize Diary::Size()
41 | {
42 | return text.size();
43 | }
44 |
45 | //read diaries from file to memory
46 | void read_to_memory(string filename, vector& my_diary)
47 | {
48 | Diary diary;
49 | string str;
50 | FILE *stream;
51 | freopen_s(&stream, filename.c_str(), "r", stdin);
52 | while (getline(cin, str))
53 | {
54 | diary.SetDate(str);
55 | diary.Reset();
56 | getline(cin, str);
57 | while (str != ".")
58 | {
59 | diary.AddLine(str);
60 | getline(cin, str);
61 | }
62 | my_diary.push_back(diary);
63 | }
64 | fclose(stdin);
65 | cin.clear();
66 | }
67 |
68 | //store diaries from memory to file
69 | void write_to_file(string filename, vector& my_diary)
70 | {
71 | sort(my_diary.begin(), my_diary.end(), date_sort);
72 | FILE *stream;
73 | freopen_s(&stream, filename.c_str(), "w", stdout);
74 | for (int i = 0; i < my_diary.size(); i++)
75 | {
76 | cout << my_diary[i].GetDate() << endl;
77 | for (int j = 0; j < my_diary[i].Size(); j++)
78 | {
79 | cout << my_diary[i].GetText(j) << endl;
80 | }
81 | cout << "." << endl;
82 | }
83 | fclose(stdout);
84 | }
85 |
86 | bool date_sort(const Diary &a1, const Diary &a2)
87 | {
88 | Diary a = a1, b = a2;
89 | string date1 = a.GetDate();
90 | string date2 = b.GetDate();
91 | if(date1.compare(date2) >= 0)//date1>=date2
92 | return false;
93 | else return true;
94 | }
--------------------------------------------------------------------------------
/8-4 Personal Diary/Personal Diary/Diary.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef DIARY_H
3 | #define DIARY_H
4 |
5 | #include "stdafx.h"
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include