Compare commits
16 Commits
9e780a4f1b
...
v24.1219
| Author | SHA1 | Date | |
|---|---|---|---|
| 6719f1e7b2 | |||
| a21a66a542 | |||
| a3d1677a4c | |||
| 4ba14576e7 | |||
| fdaf7334c8 | |||
| 1de9754569 | |||
| 2852b5f178 | |||
| 01d80d8ad2 | |||
| c99f6f67b2 | |||
| 8aa6947e2b | |||
| 26fcbfbd91 | |||
| e4d146365b | |||
| 4d9579e13d | |||
| 5a4df5e6f3 | |||
| d1ec1423dd | |||
| c2923336e6 |
@@ -7,5 +7,6 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="lib" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
BIN
lib/mysql-connector-java-8.0.11.jar
Executable file
BIN
lib/mysql-connector-java-8.0.11.jar
Executable file
Binary file not shown.
1
resources/chapter7/config/helper_3.c
Normal file
1
resources/chapter7/config/helper_3.c
Normal file
@@ -0,0 +1 @@
|
||||
#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\n
|
||||
1
resources/chapter7/config/interface_4.c
Normal file
1
resources/chapter7/config/interface_4.c
Normal file
@@ -0,0 +1 @@
|
||||
#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\n
|
||||
1
resources/chapter7/config/service_5.c
Normal file
1
resources/chapter7/config/service_5.c
Normal file
@@ -0,0 +1 @@
|
||||
#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\n
|
||||
1
resources/chapter7/config/test_2/docs_3/data_2.java
Normal file
1
resources/chapter7/config/test_2/docs_3/data_2.java
Normal file
@@ -0,0 +1 @@
|
||||
public class GeneratedClass {\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\n}\n
|
||||
1
resources/chapter7/config/test_2/docs_3/product_3.java
Normal file
1
resources/chapter7/config/test_2/docs_3/product_3.java
Normal file
@@ -0,0 +1 @@
|
||||
public class GeneratedClass {\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\n}\n
|
||||
1
resources/chapter7/config/test_2/docs_3/user_1.java
Normal file
1
resources/chapter7/config/test_2/docs_3/user_1.java
Normal file
@@ -0,0 +1 @@
|
||||
public class GeneratedClass {\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\n}\n
|
||||
1
resources/chapter7/config/utils_1.java
Normal file
1
resources/chapter7/config/utils_1.java
Normal file
@@ -0,0 +1 @@
|
||||
public class GeneratedClass {\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\n}\n
|
||||
1
resources/chapter7/create.sh
Normal file
1
resources/chapter7/create.sh
Normal file
@@ -0,0 +1 @@
|
||||
Hello World! This is a random content. Always write clean and maintainable code. Documentation is very important for any project. Always write clean and maintainable code. Software development is both an art and science. The C programming language is powerful and efficient. Testing is an essential part of development. This file was automatically generated. Always write clean and maintainable code. Hello World! This is a random content. Remember to add proper comments in your code. Documentation is very important for any project. Hello World! This is a random content. The C programming language is powerful and efficient. Software development is both an art and science. Documentation is very important for any project. Always write clean and maintainable code. Documentation is very important for any project. Testing is an essential part of development. Documentation is very important for any project. Documentation is very important for any project. Java is a popular programming language. This is a sample text for testing purposes. The C programming language is powerful and efficient. The C programming language is powerful and efficient. Testing is an essential part of development. Hello World! This is a random content. This is a sample text for testing purposes. Testing is an essential part of development. The C programming language is powerful and efficient. Testing is an essential part of development. Testing is an essential part of development. Hello World! This is a random content. Always write clean and maintainable code. This is a sample text for testing purposes. Software development is both an art and science. Hello World! This is a random content. Testing is an essential part of development. Java is a popular programming language. Remember to add proper comments in your code. Testing is an essential part of development. Always write clean and maintainable code. Software development is both an art and science. This file was automatically generated. Testing is an essential part of development. Always write clean and maintainable code. Remember to add proper comments in your code. Java is a popular programming language. Java is a popular programming language. Documentation is very important for any project. Always write clean and maintainable code. Testing is an essential part of development. This is a sample text for testing purposes. The C programming language is powerful and efficient. This file was automatically generated. Hello World! This is a random content. Java is a popular programming language. Always write clean and maintainable code. This file was automatically generated. The C programming language is powerful and efficient. Testing is an essential part of development. This is a sample text for testing purposes. Hello World! This is a random content. Testing is an essential part of development. Always write clean and maintainable code. Java is a popular programming language. This is a sample text for testing purposes. Hello World! This is a random content. Documentation is very important for any project. Documentation is very important for any project. This is a sample text for testing purposes. The C programming language is powerful and efficient. This is a sample text for testing purposes. Always write clean and maintainable code. The C programming language is powerful and efficient. Always write clean and maintainable code. This is a sample text for testing purposes. This is a sample text for testing purposes. Software development is both an art and science. Hello World! This is a random content. Remember to add proper comments in your code. Software development is both an art and science. Documentation is very important for any project. Testing is an essential part of development. This is a sample text for testing purposes. Testing is an essential part of development. Documentation is very important for any project. Java is a popular programming language. This file was automatically generated. Documentation is very important for any project. This file was automatically generated. Documentation is very important for any project. The C programming language is powerful and efficient. This is a sample text for testing purposes. This is a sample text for testing purposes. Documentation is very important for any project. Documentation is very important for any project. This is a sample text for testing purposes. Remember to add proper comments in your code. Documentation is very important for any project. Software development is both an art and science. This file was automatically generated.
|
||||
1
resources/chapter7/fill.sh
Normal file
1
resources/chapter7/fill.sh
Normal file
@@ -0,0 +1 @@
|
||||
The C programming language is powerful and efficient. This is a sample text for testing purposes. This is a sample text for testing purposes. Software development is both an art and science. This is a sample text for testing purposes. Hello World! This is a random content. Documentation is very important for any project. The C programming language is powerful and efficient. The C programming language is powerful and efficient. Software development is both an art and science. Hello World! This is a random content. This file was automatically generated. This is a sample text for testing purposes. Always write clean and maintainable code. Software development is both an art and science. This is a sample text for testing purposes. Documentation is very important for any project. Java is a popular programming language. Software development is both an art and science. Software development is both an art and science. Java is a popular programming language. Always write clean and maintainable code. Hello World! This is a random content. Testing is an essential part of development. The C programming language is powerful and efficient. This file was automatically generated. Java is a popular programming language. This file was automatically generated. Testing is an essential part of development. Hello World! This is a random content. Hello World! This is a random content. Remember to add proper comments in your code. Testing is an essential part of development. The C programming language is powerful and efficient. Documentation is very important for any project. Documentation is very important for any project. The C programming language is powerful and efficient. This is a sample text for testing purposes. Documentation is very important for any project. Remember to add proper comments in your code. Java is a popular programming language. The C programming language is powerful and efficient. Always write clean and maintainable code. This is a sample text for testing purposes. This file was automatically generated. Documentation is very important for any project. Remember to add proper comments in your code. Remember to add proper comments in your code. Remember to add proper comments in your code. Documentation is very important for any project. Remember to add proper comments in your code. Remember to add proper comments in your code. Always write clean and maintainable code. Java is a popular programming language. This file was automatically generated. This is a sample text for testing purposes. Software development is both an art and science. Hello World! This is a random content. Java is a popular programming language. Remember to add proper comments in your code. Documentation is very important for any project. Documentation is very important for any project. Always write clean and maintainable code. This is a sample text for testing purposes. Documentation is very important for any project. Documentation is very important for any project. Remember to add proper comments in your code. Testing is an essential part of development. The C programming language is powerful and efficient.
|
||||
@@ -0,0 +1 @@
|
||||
Remember to add proper comments in your code. Documentation is very important for any project. Hello World! This is a random content. Java is a popular programming language. Always write clean and maintainable code. Java is a popular programming language. This file was automatically generated. Software development is both an art and science. Always write clean and maintainable code. Remember to add proper comments in your code. The C programming language is powerful and efficient. Hello World! This is a random content. Documentation is very important for any project. This is a sample text for testing purposes. The C programming language is powerful and efficient. Java is a popular programming language. The C programming language is powerful and efficient. Software development is both an art and science. Software development is both an art and science. Remember to add proper comments in your code. Remember to add proper comments in your code. Testing is an essential part of development. Documentation is very important for any project. Java is a popular programming language. This file was automatically generated. This is a sample text for testing purposes. Always write clean and maintainable code. Testing is an essential part of development. This is a sample text for testing purposes. This file was automatically generated. This file was automatically generated. Always write clean and maintainable code. Software development is both an art and science. Always write clean and maintainable code. Hello World! This is a random content. The C programming language is powerful and efficient. Testing is an essential part of development. The C programming language is powerful and efficient. Hello World! This is a random content. Remember to add proper comments in your code. Java is a popular programming language. Hello World! This is a random content. Testing is an essential part of development. Java is a popular programming language. Software development is both an art and science. Always write clean and maintainable code. Hello World! This is a random content. Always write clean and maintainable code. Software development is both an art and science. Always write clean and maintainable code. Always write clean and maintainable code. This is a sample text for testing purposes. Documentation is very important for any project. Documentation is very important for any project. Remember to add proper comments in your code. Always write clean and maintainable code. Always write clean and maintainable code. This is a sample text for testing purposes. Always write clean and maintainable code. This file was automatically generated. Always write clean and maintainable code. Always write clean and maintainable code. Documentation is very important for any project. Testing is an essential part of development. Hello World! This is a random content. This file was automatically generated. Java is a popular programming language. Always write clean and maintainable code. Documentation is very important for any project. Java is a popular programming language. The C programming language is powerful and efficient. Hello World! This is a random content. Software development is both an art and science. Java is a popular programming language. Java is a popular programming language. This is a sample text for testing purposes. Software development is both an art and science. The C programming language is powerful and efficient. The C programming language is powerful and efficient. Testing is an essential part of development. Hello World! This is a random content. This is a sample text for testing purposes. Testing is an essential part of development. Documentation is very important for any project. Hello World! This is a random content. Documentation is very important for any project. Always write clean and maintainable code. Hello World! This is a random content. The C programming language is powerful and efficient. This is a sample text for testing purposes. This is a sample text for testing purposes. Always write clean and maintainable code. Always write clean and maintainable code. Java is a popular programming language. Testing is an essential part of development. The C programming language is powerful and efficient. This is a sample text for testing purposes. The C programming language is powerful and efficient. Hello World! This is a random content. This is a sample text for testing purposes. Documentation is very important for any project. Software development is both an art and science. The C programming language is powerful and efficient. This file was automatically generated. Java is a popular programming language. Documentation is very important for any project. Remember to add proper comments in your code. This is a sample text for testing purposes. Testing is an essential part of development. Testing is an essential part of development.
|
||||
1
resources/chapter7/models/config_2/config_3/user_2.java
Normal file
1
resources/chapter7/models/config_2/config_3/user_2.java
Normal file
@@ -0,0 +1 @@
|
||||
public class GeneratedClass {\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\n}\n
|
||||
@@ -0,0 +1 @@
|
||||
public class GeneratedClass {\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\n}\n
|
||||
@@ -0,0 +1 @@
|
||||
#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\n
|
||||
1
resources/chapter7/models/source_2/services_3/data_4.c
Normal file
1
resources/chapter7/models/source_2/services_3/data_4.c
Normal file
@@ -0,0 +1 @@
|
||||
#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\n
|
||||
@@ -0,0 +1 @@
|
||||
This file was automatically generated. This file was automatically generated. Remember to add proper comments in your code. Software development is both an art and science. The C programming language is powerful and efficient. Testing is an essential part of development. Java is a popular programming language. Hello World! This is a random content. Software development is both an art and science. Software development is both an art and science. Remember to add proper comments in your code. Testing is an essential part of development. This is a sample text for testing purposes. Documentation is very important for any project. Documentation is very important for any project. Testing is an essential part of development. Java is a popular programming language. This file was automatically generated. Software development is both an art and science. Always write clean and maintainable code. Always write clean and maintainable code. The C programming language is powerful and efficient. Hello World! This is a random content. Documentation is very important for any project. Documentation is very important for any project. This file was automatically generated. This file was automatically generated. Java is a popular programming language. Always write clean and maintainable code. Testing is an essential part of development. The C programming language is powerful and efficient. Java is a popular programming language. Always write clean and maintainable code. Testing is an essential part of development. Documentation is very important for any project. Software development is both an art and science. This is a sample text for testing purposes. This file was automatically generated. The C programming language is powerful and efficient. Remember to add proper comments in your code. The C programming language is powerful and efficient. Java is a popular programming language. Remember to add proper comments in your code.
|
||||
1
resources/chapter7/models/source_2/services_3/user_2.c
Normal file
1
resources/chapter7/models/source_2/services_3/user_2.c
Normal file
@@ -0,0 +1 @@
|
||||
#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\n
|
||||
1
resources/chapter7/resources_2/resources_3/config_2.c
Normal file
1
resources/chapter7/resources_2/resources_3/config_2.c
Normal file
@@ -0,0 +1 @@
|
||||
#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\n
|
||||
@@ -0,0 +1 @@
|
||||
This file was automatically generated. This is a sample text for testing purposes. Remember to add proper comments in your code. This is a sample text for testing purposes. Always write clean and maintainable code. This is a sample text for testing purposes. Software development is both an art and science. This file was automatically generated. Testing is an essential part of development. Java is a popular programming language. This file was automatically generated. Remember to add proper comments in your code. The C programming language is powerful and efficient. Java is a popular programming language. Always write clean and maintainable code. This file was automatically generated. Documentation is very important for any project. The C programming language is powerful and efficient. Testing is an essential part of development. Always write clean and maintainable code. The C programming language is powerful and efficient. Always write clean and maintainable code. This is a sample text for testing purposes. Always write clean and maintainable code. Java is a popular programming language. Remember to add proper comments in your code. Remember to add proper comments in your code. Software development is both an art and science. This file was automatically generated. Documentation is very important for any project. The C programming language is powerful and efficient. Hello World! This is a random content. Software development is both an art and science. Documentation is very important for any project. Always write clean and maintainable code. Remember to add proper comments in your code. Hello World! This is a random content. Hello World! This is a random content. Testing is an essential part of development. Java is a popular programming language. Remember to add proper comments in your code. The C programming language is powerful and efficient. Testing is an essential part of development. This is a sample text for testing purposes. Testing is an essential part of development. Hello World! This is a random content. Documentation is very important for any project. Documentation is very important for any project. The C programming language is powerful and efficient. The C programming language is powerful and efficient. This file was automatically generated. Hello World! This is a random content. Documentation is very important for any project. Software development is both an art and science. Remember to add proper comments in your code. Software development is both an art and science. This is a sample text for testing purposes. Remember to add proper comments in your code. Always write clean and maintainable code. Software development is both an art and science. Java is a popular programming language. Remember to add proper comments in your code. Remember to add proper comments in your code. This file was automatically generated. Java is a popular programming language. This is a sample text for testing purposes. Testing is an essential part of development. This file was automatically generated. Hello World! This is a random content. Remember to add proper comments in your code. Hello World! This is a random content. Hello World! This is a random content. This file was automatically generated. This is a sample text for testing purposes. Always write clean and maintainable code. This file was automatically generated. This file was automatically generated. Hello World! This is a random content. Testing is an essential part of development. Software development is both an art and science. Always write clean and maintainable code. Remember to add proper comments in your code. Hello World! This is a random content. Hello World! This is a random content. Software development is both an art and science. Hello World! This is a random content. Testing is an essential part of development. This is a sample text for testing purposes. Software development is both an art and science. Software development is both an art and science. Remember to add proper comments in your code. Hello World! This is a random content. Always write clean and maintainable code. Testing is an essential part of development. Java is a popular programming language. The C programming language is powerful and efficient. Documentation is very important for any project. Hello World! This is a random content. This file was automatically generated. Software development is both an art and science. Always write clean and maintainable code. The C programming language is powerful and efficient. The C programming language is powerful and efficient. Testing is an essential part of development. Hello World! This is a random content. Java is a popular programming language. Software development is both an art and science. Testing is an essential part of development. Remember to add proper comments in your code. The C programming language is powerful and efficient. Java is a popular programming language. Testing is an essential part of development.
|
||||
@@ -0,0 +1 @@
|
||||
This file was automatically generated. Remember to add proper comments in your code. Hello World! This is a random content. Remember to add proper comments in your code. Remember to add proper comments in your code. This is a sample text for testing purposes. Hello World! This is a random content. Testing is an essential part of development. Always write clean and maintainable code. Testing is an essential part of development. Java is a popular programming language. This is a sample text for testing purposes. This file was automatically generated. The C programming language is powerful and efficient. Software development is both an art and science. This is a sample text for testing purposes. This is a sample text for testing purposes. Always write clean and maintainable code. Testing is an essential part of development. This is a sample text for testing purposes. Always write clean and maintainable code. The C programming language is powerful and efficient. Remember to add proper comments in your code. Java is a popular programming language. Hello World! This is a random content. This file was automatically generated. Always write clean and maintainable code. Always write clean and maintainable code. Documentation is very important for any project. This file was automatically generated. The C programming language is powerful and efficient. Software development is both an art and science. Testing is an essential part of development. Always write clean and maintainable code. Hello World! This is a random content. The C programming language is powerful and efficient. Always write clean and maintainable code. Software development is both an art and science. Remember to add proper comments in your code. Remember to add proper comments in your code. Hello World! This is a random content. Testing is an essential part of development. Documentation is very important for any project. Testing is an essential part of development. Always write clean and maintainable code. This is a sample text for testing purposes. This is a sample text for testing purposes. Software development is both an art and science. Documentation is very important for any project. Software development is both an art and science. Java is a popular programming language. Always write clean and maintainable code. The C programming language is powerful and efficient. This is a sample text for testing purposes.
|
||||
1
resources/chapter7/resources_2/resources_3/user_3.c
Normal file
1
resources/chapter7/resources_2/resources_3/user_3.c
Normal file
@@ -0,0 +1 @@
|
||||
#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\n
|
||||
1
resources/chapter7/service_2.c
Normal file
1
resources/chapter7/service_2.c
Normal file
@@ -0,0 +1 @@
|
||||
#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\nvoid processData(int[] data) {\n for(int i = 0; i < data.length; i++) {\n data[i] = transform(data[i]);\n }\n}\n\npublic interface DataProcessor {\n void process(Data data);\n Result getResult();\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\nprivate static void logger(String message) {\n System.out.println("[LOG] " + message);\n}\n\npublic class Example {\n private String value;\n\n public Example(String value) {\n this.value = value;\n }\n\n public String getValue() {\n return value;\n }\n}\n\n
|
||||
46
src/chapter10/Example01.java
Normal file
46
src/chapter10/Example01.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package chapter10;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.sql.DriverManager;
|
||||
|
||||
public class Example01 {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
// 1. 加载驱动
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
|
||||
// 2. 准备连接参数
|
||||
String url = "jdbc:mysql://localhost:3306/school?characterEncoding=utf-8&useSSL=false&serverTimezone=UTC";
|
||||
String username = "root";
|
||||
String password = "root";
|
||||
|
||||
// 使用try-with-resources自动关闭资源
|
||||
try (
|
||||
// 创建连接
|
||||
Connection connection = DriverManager.getConnection(url, username, password);
|
||||
// 创建语句对象
|
||||
Statement statement = connection.createStatement();
|
||||
// 执行查询获取结果集
|
||||
ResultSet resultSet = statement.executeQuery("select * from student")
|
||||
) {
|
||||
// 处理结果集
|
||||
while (resultSet.next()) {
|
||||
int id = resultSet.getInt("id");
|
||||
String name = resultSet.getString("name");
|
||||
int age = resultSet.getInt("age");
|
||||
String gender = resultSet.getString("gender");
|
||||
String className = resultSet.getString("class");
|
||||
|
||||
System.out.println("id=" + id + ", name=" + name + ", age=" + age +
|
||||
", gender=" + gender + ", className=" + className);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
37
src/chapter10/Example02.java
Normal file
37
src/chapter10/Example02.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package chapter10;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Statement;
|
||||
import java.sql.DriverManager;
|
||||
|
||||
public class Example02 {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
// 1. 加载驱动
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
|
||||
// 2. 准备连接参数
|
||||
String url = "jdbc:mysql://localhost:3306/school?characterEncoding=utf-8&useSSL=false&serverTimezone=UTC";
|
||||
String username = "root";
|
||||
String password = "root";
|
||||
|
||||
// 使用try-with-resources自动关闭资源
|
||||
try (
|
||||
Connection connection = DriverManager.getConnection(url, username, password);
|
||||
Statement statement = connection.createStatement()
|
||||
) {
|
||||
// 准备INSERT语句
|
||||
String sql = "INSERT INTO student (name, age, gender, class, score) " +
|
||||
"VALUES ('小张', 19, 'M', '计算机1班', 88.5)";
|
||||
|
||||
// 执行INSERT语句
|
||||
int rows = statement.executeUpdate(sql);
|
||||
|
||||
// 输出受影响的行数
|
||||
System.out.println("成功插入 " + rows + " 条数据");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
73
src/chapter6/Example08.java
Normal file
73
src/chapter6/Example08.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package chapter6;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
class Student implements Comparable<Student> {
|
||||
String id;
|
||||
String name;
|
||||
int height;
|
||||
|
||||
public Student(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return id + ":" + name;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof Student)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Student other = (Student) obj;
|
||||
return this.id.equals(other.id);
|
||||
}
|
||||
|
||||
public int compareTo(Student other) {
|
||||
if (this.height > other.height) {
|
||||
return 1; // 返回正数:表示"我"比"你"大
|
||||
} else if (this.height < other.height) {
|
||||
return -1; // 返回负数:表示"我"比"你"小
|
||||
} else {
|
||||
return 0; // 返回0:表示"我"和"你"一样大
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Example08 {
|
||||
public static void main(String[] args) {
|
||||
HashSet<Student> students = new HashSet<>();
|
||||
|
||||
Student s1 = new Student("1", "张三");
|
||||
Student s2 = new Student("2", "李四");
|
||||
Student s3 = new Student("2", "李四");
|
||||
Student s4 = new Student("3", "王五");
|
||||
|
||||
students.add(s3);
|
||||
students.add(s4);
|
||||
students.add(s1);
|
||||
students.add(s2);
|
||||
|
||||
Iterator<Student> iterator = students.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Student student = iterator.next();
|
||||
System.out.println(student);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
21
src/chapter6/Example12.java
Normal file
21
src/chapter6/Example12.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package chapter6;
|
||||
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class Example12 {
|
||||
public static void main(String[] args) {
|
||||
Student s1 = new Student("1", "张三");
|
||||
s1.setHeight(175);
|
||||
Student s2 = new Student("2", "李四");
|
||||
s2.setHeight(170);
|
||||
Student s4 = new Student("3", "王五");
|
||||
s4.setHeight(180);
|
||||
|
||||
TreeSet<Student> students = new TreeSet<>();
|
||||
students.add(s1);
|
||||
students.add(s2);
|
||||
students.add(s4);
|
||||
|
||||
System.out.println(students);
|
||||
}
|
||||
}
|
||||
27
src/chapter6/Example14.java
Normal file
27
src/chapter6/Example14.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package chapter6;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Example14 {
|
||||
public static void main(String[] args) {
|
||||
HashMap map = new HashMap(); // 创建Map对象
|
||||
map.put("1","张三");//存储键和值
|
||||
map.put("2","李四");
|
||||
map.put("3","王五");
|
||||
map.put("3", "赵六");
|
||||
|
||||
System.out.println("1:" + map.get("1")); // 根据键获取值
|
||||
System.out.println("2: " + map.get("2"));
|
||||
System.out.println("3: " + map.get("3"));
|
||||
System.out.println("键值对数量:" + map.size());
|
||||
|
||||
// if (map.containsKey("1")) {
|
||||
// System.out.println("1号存在");
|
||||
// }
|
||||
//
|
||||
// if (map.containsValue("李四")) {
|
||||
// System.out.println("李四存在");
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
52
src/chapter6/Example15.java
Normal file
52
src/chapter6/Example15.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package chapter6;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class Example15 {
|
||||
public static void main(String[] args) {
|
||||
HashMap map = new HashMap(); // 创建Map对象
|
||||
map.put("2","李四"); //存储键和值
|
||||
map.put("3","王五");
|
||||
map.put("1","张三");
|
||||
|
||||
// 方法一
|
||||
Set keySet = map.keySet(); //获取键的集合
|
||||
Iterator it = keySet.iterator();//选代键的集合
|
||||
while (it.hasNext()) {
|
||||
Object key = it.next();
|
||||
Object value = map.get(key); //获取每个键所对应的值
|
||||
System.out.println(key + ":" + value);
|
||||
}
|
||||
|
||||
Iterator it2 = map.keySet().iterator();
|
||||
while (it2.hasNext()) {
|
||||
Object key = it2.next();
|
||||
System.out.println(key);
|
||||
}
|
||||
|
||||
Iterator it3 = map.values().iterator();
|
||||
while (it3.hasNext()) {
|
||||
Object value = it3.next();
|
||||
System.out.println(value);
|
||||
}
|
||||
|
||||
// 方法二
|
||||
Set entrySet = map.entrySet(); // 获取所有映射关系
|
||||
Iterator it4 = entrySet.iterator(); // 获取Iterator对象
|
||||
while (it4.hasNext()){
|
||||
//获取集合中键值对映射关系
|
||||
Map.Entry entry = (Map.Entry) (it4.next());
|
||||
Object key = entry.getKey();//获取Entry中的键
|
||||
Object value = entry.getValue();//获取Entry中的值
|
||||
System.out.println(key + ":" + value);
|
||||
}
|
||||
|
||||
for (Object obj : map.entrySet()) {
|
||||
System.out.println(obj);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
23
src/chapter6/Example19.java
Normal file
23
src/chapter6/Example19.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package chapter6;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class Example19 {
|
||||
public static void main(String[] args) {
|
||||
TreeMap map = new TreeMap(); // 创建Map集合
|
||||
map.put(3, "李四"); // 存储键和值
|
||||
map.put(2, "王五");
|
||||
map.put(4, "赵六");
|
||||
map.put(3, "张三");
|
||||
|
||||
Set keySet = map.keySet();
|
||||
Iterator iterator = keySet.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Object key = iterator.next();
|
||||
Object value = map.get(key);
|
||||
System.out.println(key + ":" + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/chapter6/Example21.java
Normal file
20
src/chapter6/Example21.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package chapter6;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Example21 {
|
||||
public static void main(String[] args) {
|
||||
Properties p = new Properties();
|
||||
p.setProperty("Backgroudnd", "red");
|
||||
p.setProperty("Font-size", "14px");
|
||||
p.setProperty("Language", "Chinese");
|
||||
|
||||
Enumeration names = p.propertyNames();
|
||||
while (names.hasMoreElements()) {
|
||||
String key = (String) names.nextElement();
|
||||
String value = p.getProperty(key);
|
||||
System.out.println(key + "=" + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
src/chapter6/Example22.java
Normal file
33
src/chapter6/Example22.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package chapter6;
|
||||
|
||||
// T 标识一个不确定的类型
|
||||
class Score<T> {
|
||||
private String studentName; // 学生姓名
|
||||
private String subject; // 课程名称
|
||||
private T value; // 成绩值(可以是任意类型)
|
||||
|
||||
// 构造方法
|
||||
public Score(String studentName, String subject, T value) {
|
||||
this.studentName = studentName;
|
||||
this.subject = subject;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return studentName + "的" + subject + "成绩是" + value;
|
||||
}
|
||||
}
|
||||
|
||||
public class Example22 {
|
||||
public static void main(String[] args) {
|
||||
// 创建三个成绩对象,分别存储小明的数学、英语、军事理论成绩
|
||||
Score<Integer> s1 = new Score<Integer>("小明", "数学", 100);
|
||||
Score<String> s2 = new Score<String>("小明", "英语", "A");
|
||||
Score<String> s3 = new Score<String>("小明", "军事理论", "合格");
|
||||
|
||||
// 打印三门课程的成绩
|
||||
System.out.println(s1);
|
||||
System.out.println(s2);
|
||||
System.out.println(s3);
|
||||
}
|
||||
}
|
||||
29
src/chapter6/Example23.java
Normal file
29
src/chapter6/Example23.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package chapter6;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
public class Example23 {
|
||||
public static void main(String[] args) {
|
||||
// 存放字符串的集合
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
names.add("张三"); // √ 正确
|
||||
|
||||
Iterator it1 = names.iterator();
|
||||
while (it1.hasNext()) {
|
||||
String name = (String) it1.next();
|
||||
System.out.println(name);
|
||||
}
|
||||
|
||||
ArrayList students = new ArrayList();
|
||||
names.add("张三");
|
||||
|
||||
Iterator it2 = students.iterator();
|
||||
while (it2.hasNext()) {
|
||||
String student = (String) it2.next();
|
||||
System.out.println(student);
|
||||
}
|
||||
}
|
||||
}
|
||||
36
src/chapter6/Example24.java
Normal file
36
src/chapter6/Example24.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package chapter6;
|
||||
|
||||
|
||||
|
||||
public class Example24 {
|
||||
// 泛型方法:验证订单信息
|
||||
public static <T> boolean verify(T info) {
|
||||
System.out.println("正在验证: " + info);
|
||||
|
||||
if (info instanceof String) {
|
||||
// 验证订单号
|
||||
String orderNo = (String) info;
|
||||
return orderNo.length() == 10; // 假设订单号必须是10位
|
||||
}
|
||||
else if (info instanceof Double || info instanceof Integer) {
|
||||
// 验证订单金额
|
||||
double amount = Double.parseDouble(info.toString());
|
||||
return amount > 0; // 金额必须大于0
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 验证订单号
|
||||
boolean isValidOrderNo = verify("A123456789");
|
||||
System.out.println("订单号是否合法: " + isValidOrderNo);
|
||||
|
||||
// 验证订单金额
|
||||
boolean isValidAmount = verify(99.9);
|
||||
System.out.println("订单金额是否合法: " + isValidAmount);
|
||||
|
||||
// 验证负数金额
|
||||
boolean isValidNegative = verify(-10.0);
|
||||
System.out.println("负数金额是否合法: " + isValidNegative);
|
||||
}
|
||||
}
|
||||
59
src/chapter6/Example25.java
Normal file
59
src/chapter6/Example25.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package chapter6;
|
||||
|
||||
// 定义支付接口(泛型接口)
|
||||
interface Payment<T> {
|
||||
boolean pay(T amount); // 支付方法
|
||||
T getBalance(); // 获取余额
|
||||
}
|
||||
|
||||
// 方式一:明确类型的接口实现 - 支付宝支付
|
||||
class AliPay implements Payment<Double> {
|
||||
private Double balance = 1000.0;
|
||||
|
||||
@Override
|
||||
public boolean pay(Double amount) {
|
||||
if (balance >= amount) {
|
||||
balance -= amount;
|
||||
System.out.println("支付成功:" + amount + "元");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getBalance() {
|
||||
return balance;
|
||||
}
|
||||
}
|
||||
|
||||
// 方式二:泛型类型的接口实现 - 校园卡支付
|
||||
class CampusCard<T> implements Payment<T> {
|
||||
private T balance;
|
||||
|
||||
public CampusCard(T balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(T amount) {
|
||||
System.out.println("支付积分:" + amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getBalance() {
|
||||
return balance;
|
||||
}
|
||||
}
|
||||
|
||||
public class Example25 {
|
||||
public static void main(String[] args) {
|
||||
// 测试支付宝支付
|
||||
AliPay aliPay = new AliPay();
|
||||
aliPay.pay(100.0);
|
||||
|
||||
// 测试校园卡支付
|
||||
CampusCard<Integer> campusCard = new CampusCard<>(500);
|
||||
campusCard.pay(100);
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,6 @@ public class Manager {
|
||||
System.out.print("请输入要出库的商品编号:");
|
||||
int id = sc.nextInt();
|
||||
removeGoods(id);
|
||||
System.out.println("商品出库成功,出库后仓库商品如下:");
|
||||
showWareHouse();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +63,13 @@ public class Manager {
|
||||
|
||||
// 商品出库(从goodList中删除指定位置的元素)
|
||||
static void removeGoods(int index) {
|
||||
goodsList.remove(index);
|
||||
if (index >= 0 && index < goodsList.size()) {
|
||||
goodsList.remove(index);
|
||||
System.out.println("商品出库成功,出库后仓库商品如下:");
|
||||
showWareHouse();
|
||||
} else {
|
||||
System.out.println("商品不存在!");
|
||||
}
|
||||
}
|
||||
|
||||
// 使用迭代器遍历商品
|
||||
|
||||
171
src/chapter6/demo62/Manager.java
Normal file
171
src/chapter6/demo62/Manager.java
Normal file
@@ -0,0 +1,171 @@
|
||||
package chapter6.demo62;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Manager {
|
||||
// 创建集合对象,用于存储学生数据
|
||||
static LinkedList<Student> array = new LinkedList<Student>();
|
||||
public static void main(String[] args) {
|
||||
|
||||
while(true) {
|
||||
// 这是学生管理系统的主界面
|
||||
System.out.println("--------欢迎来到学生管理系统--------");
|
||||
System.out.println("1 查看所有学生");
|
||||
System.out.println("2 添加学生");
|
||||
System.out.println("3 删除学生");
|
||||
System.out.println("4 修改学生");
|
||||
System.out.println("5 退出");
|
||||
System.out.println("请输入你的选择:");
|
||||
|
||||
Scanner sc = new Scanner(System.in);
|
||||
int choice = sc.nextInt();
|
||||
|
||||
switch (choice) {
|
||||
case 1:
|
||||
showAllStudents();
|
||||
break;
|
||||
case 2:
|
||||
addStudent();
|
||||
break;
|
||||
case 3:
|
||||
deleteStudent();
|
||||
break;
|
||||
case 4:
|
||||
updateStudent();
|
||||
break;
|
||||
default:
|
||||
System.out.println("谢谢你的使用");
|
||||
System.exit(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查看所有学生
|
||||
public static void showAllStudents() {
|
||||
// 首先来判断集合中是否有数据,如果没有数据,就给出提示,并让该方法不继续往下执行
|
||||
if (array.isEmpty()) {
|
||||
System.out.println("不好意思,目前没有学生信息可供查询,请回去重新选择你的操作");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("学号\t姓名\t年龄\t居住地");
|
||||
// 使用 foreach 循环遍历
|
||||
for (Student s : array) {
|
||||
System.out.println(s.getId() + "\t" + s.getName() + "\t" + s.getAge() + "\t" + s.getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
// 添加学生
|
||||
public static void addStudent() {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
|
||||
System.out.println("请输入学生学号:");
|
||||
String id = sc.nextLine();
|
||||
|
||||
// 判断学号有没有被人占用
|
||||
|
||||
// 定义标记
|
||||
boolean flag = false;
|
||||
// 遍历集合,得到每一个学生
|
||||
for (Student s : array) {
|
||||
if (s.getId().equals(id)) {
|
||||
flag = true; // 说明学号被占用了
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
System.out.println("你输入的学号已经被占用,请重新输入:");
|
||||
id = sc.nextLine();
|
||||
}
|
||||
|
||||
System.out.println("请输入学生姓名:");
|
||||
String name = sc.nextLine();
|
||||
System.out.println("请输入学生年龄:");
|
||||
int age = Integer.parseInt(sc.nextLine());
|
||||
System.out.println("请输入学生居住地:");
|
||||
String address = sc.nextLine();
|
||||
// 添加学生到Array
|
||||
array.add(new Student(id, name, age, address));
|
||||
// 给出提示
|
||||
System.out.println("添加学生成功");
|
||||
}
|
||||
|
||||
// 删除学生
|
||||
public static void deleteStudent() {
|
||||
// 删除学生的思路:键盘录入一个学号,到集合中去查找,看是否有学生使用的是该学号,如果有就删除该学生
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.println("请输入你要删除的学生的学号:");
|
||||
String id = sc.nextLine();
|
||||
|
||||
// 我们必须给出学号不存在的时候的提示
|
||||
// 定义一个索引
|
||||
int index = -1;
|
||||
// 遍历集合
|
||||
for (int x = 0; x < array.size(); x++) {
|
||||
// 获取到每一个学生对象
|
||||
Student s = array.get(x);
|
||||
// 拿这个学生对象的学号和键盘录入的学号进行比较
|
||||
if (s.getId().equals(id)) {
|
||||
index = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1) {
|
||||
System.out.println("不好意思,你要删除的学号对应的学生信息不存在,请回去重新你的选择");
|
||||
} else {
|
||||
array.remove(index);
|
||||
System.out.println("删除学生成功");
|
||||
}
|
||||
}
|
||||
|
||||
// 修改学生信息
|
||||
public static void updateStudent() {
|
||||
// 修改学生的思路:键盘录入一个学号,到集合中去查找,看是否有学生使用的是该学号,如果有就修改该学生
|
||||
// 创建键盘录入对象
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.println("请输入你要修改的学生的学号:");
|
||||
String id = sc.nextLine();
|
||||
// 定义一个索引
|
||||
Student student = null;
|
||||
// 遍历集合
|
||||
for (int x = 0; x < array.size(); x++) {
|
||||
// 获取每一个学生对象
|
||||
Student s = array.get(x);
|
||||
// 拿学生对象的学号和键盘录入的学号进行比较
|
||||
if (s.getId().equals(id)) {
|
||||
student = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (student == null) {
|
||||
System.out.println("不好意思,你要修改的学号对应的学生信息不存在,请回去重新你的选择");
|
||||
} else {
|
||||
System.out.println("1 姓名");
|
||||
System.out.println("2 年龄");
|
||||
System.out.println("3 居住地");
|
||||
int choice = sc.nextInt();
|
||||
switch (choice) {
|
||||
case 1:
|
||||
System.out.println("请输入学生新姓名:");
|
||||
String name = sc.nextLine();
|
||||
student.setName(name);
|
||||
break;
|
||||
case 2:
|
||||
System.out.println("请输入学生新年龄:");
|
||||
int age = sc.nextInt();
|
||||
student.setAge(age);
|
||||
break;
|
||||
case 3:
|
||||
System.out.println("请输入学生新居住地:");
|
||||
String address = sc.nextLine();
|
||||
student.setAddress(address);
|
||||
break;
|
||||
}
|
||||
System.out.println("修改学生成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
52
src/chapter6/demo62/Student.java
Normal file
52
src/chapter6/demo62/Student.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package chapter6.demo62;
|
||||
|
||||
public class Student {
|
||||
// 学号
|
||||
private String id;
|
||||
// 姓名
|
||||
private String name;
|
||||
// 年龄
|
||||
private int age;
|
||||
// 居住地
|
||||
private String address;
|
||||
|
||||
// 构造方法
|
||||
public Student(String id, String name, int age, String address) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
}
|
||||
43
src/chapter6/demo64/Card.java
Normal file
43
src/chapter6/demo64/Card.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package chapter6.demo64;
|
||||
|
||||
// Card.java - 扑克牌类
|
||||
public class Card implements Comparable<Card> {
|
||||
private final String color; // 花色
|
||||
private final String point; // 点数
|
||||
private final int index; // 编号
|
||||
|
||||
/**
|
||||
* 构造一张扑克牌
|
||||
* @param color 花色
|
||||
* @param point 点数
|
||||
* @param index 编号
|
||||
*/
|
||||
public Card(String color, String point, int index) {
|
||||
this.color = color;
|
||||
this.point = point;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return color + point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Card other) {
|
||||
// if (this.index == other.index) {
|
||||
// return 0;
|
||||
// } else if (this.index > other.index) {
|
||||
// return 1;
|
||||
// } else {
|
||||
// return -1;
|
||||
// }
|
||||
// 谁的index小,谁排在前面
|
||||
return this.index - other.index;
|
||||
}
|
||||
|
||||
// getter方法
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
45
src/chapter6/demo64/Deck.java
Normal file
45
src/chapter6/demo64/Deck.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package chapter6.demo64;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
// Deck.java - 牌组类
|
||||
public class Deck {
|
||||
private ArrayList<Card> cards = new ArrayList<>();
|
||||
private static final String[] COLORS = {"♠", "♥", "♣", "♦"};
|
||||
private static final String[] POINTS = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
|
||||
|
||||
/**
|
||||
* 初始化一副扑克牌
|
||||
*/
|
||||
public Deck() {
|
||||
int index = 0;
|
||||
// 生成52张普通牌
|
||||
for (String point : POINTS) {
|
||||
for (String color : COLORS) {
|
||||
cards.add(new Card(color, point, index++));
|
||||
}
|
||||
}
|
||||
// 添加大小王
|
||||
cards.add(new Card("", "小☺", index++));
|
||||
cards.add(new Card("", "大☻", index));
|
||||
}
|
||||
|
||||
/**
|
||||
* 洗牌
|
||||
*/
|
||||
public void shuffle() {
|
||||
Collections.shuffle(cards);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发牌
|
||||
* @return 发出的牌
|
||||
*/
|
||||
public Card dealCard() {
|
||||
if (!cards.isEmpty()) {
|
||||
return cards.removeFirst();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
170
src/chapter6/demo64/Function.java
Normal file
170
src/chapter6/demo64/Function.java
Normal file
@@ -0,0 +1,170 @@
|
||||
package chapter6.demo64;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Function {
|
||||
// 存储牌号和牌面的对应关系
|
||||
private static HashMap<Integer, String> cardMap = new HashMap<>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 1. 准备牌的基本元素
|
||||
ArrayList<String> colors = prepareColors();
|
||||
ArrayList<String> points = preparePoints();
|
||||
|
||||
// 2. 组装54张牌
|
||||
createCards(colors, points);
|
||||
|
||||
// 3. 洗牌准备
|
||||
ArrayList<Integer> cards = shuffleCards();
|
||||
|
||||
// 4. 发牌
|
||||
ArrayList<ArrayList<Integer>> dealtCards = dealCards(cards);
|
||||
ArrayList<Integer> iPlayer = dealtCards.get(0);
|
||||
ArrayList<Integer> iPlayer2 = dealtCards.get(1);
|
||||
ArrayList<Integer> iPlayer3 = dealtCards.get(2);
|
||||
ArrayList<Integer> iSecretCards = dealtCards.get(3);
|
||||
|
||||
// 5. 整理手牌
|
||||
sortCards(iPlayer, iPlayer2, iPlayer3);
|
||||
|
||||
// 6. 转换并显示牌面
|
||||
showCards(iPlayer, iPlayer2, iPlayer3, iSecretCards);
|
||||
}
|
||||
|
||||
/**
|
||||
* 准备扑克牌的4种花色
|
||||
* @return ArrayList<String> 包含4种花色符号的列表
|
||||
*/
|
||||
private static ArrayList<String> prepareColors() {
|
||||
ArrayList<String> colors = new ArrayList<>();
|
||||
colors.add("♠");
|
||||
colors.add("♥");
|
||||
colors.add("♣");
|
||||
colors.add("♦");
|
||||
return colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* 准备扑克牌的13种点数
|
||||
* @return ArrayList<String> 包含2-10,J,Q,K,A的点数列表
|
||||
*/
|
||||
private static ArrayList<String> preparePoints() {
|
||||
ArrayList<String> points = new ArrayList<>();
|
||||
for (int i = 2; i <= 10; i++) {
|
||||
points.add(i + "");
|
||||
}
|
||||
points.add("J");
|
||||
points.add("Q");
|
||||
points.add("K");
|
||||
points.add("A");
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建54张扑克牌,并建立编号和牌面的映射关系
|
||||
* @param colors 花色列表
|
||||
* @param points 点数列表
|
||||
*/
|
||||
private static void createCards(ArrayList<String> colors, ArrayList<String> points) {
|
||||
int index = 0;
|
||||
for (String number : points) {
|
||||
for (String color : colors) {
|
||||
cardMap.put(index++, color + number);
|
||||
}
|
||||
}
|
||||
cardMap.put(index++, "小☺");
|
||||
cardMap.put(index++, "大☻");
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成54张牌的编号并随机打乱顺序
|
||||
* @return ArrayList<Integer> 洗好的牌的编号列表(0-53)
|
||||
*/
|
||||
private static ArrayList<Integer> shuffleCards() {
|
||||
ArrayList<Integer> cards = new ArrayList<>();
|
||||
for (int i = 0; i <= 53; i++) {
|
||||
cards.add(i);
|
||||
}
|
||||
Collections.shuffle(cards);
|
||||
return cards;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将54张牌分发给三个玩家和底牌
|
||||
* @param cards 洗好的牌的编号列表
|
||||
* @return ArrayList<ArrayList<Integer>> 包含四个列表的集合:
|
||||
* 索引0-2分别为三个玩家的牌,索引3为底牌
|
||||
*/
|
||||
private static ArrayList<ArrayList<Integer>> dealCards(ArrayList<Integer> cards) {
|
||||
ArrayList<Integer> iPlayer = new ArrayList<>();
|
||||
ArrayList<Integer> iPlayer2 = new ArrayList<>();
|
||||
ArrayList<Integer> iPlayer3 = new ArrayList<>();
|
||||
ArrayList<Integer> iSecretCards = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < cards.size(); i++) {
|
||||
if (i >= 51) {
|
||||
iSecretCards.add(cards.get(i));
|
||||
} else {
|
||||
if (i % 3 == 0) {
|
||||
iPlayer.add(cards.get(i));
|
||||
} else if (i % 3 == 1) {
|
||||
iPlayer2.add(cards.get(i));
|
||||
} else {
|
||||
iPlayer3.add(cards.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<ArrayList<Integer>> result = new ArrayList<>();
|
||||
result.add(iPlayer);
|
||||
result.add(iPlayer2);
|
||||
result.add(iPlayer3);
|
||||
result.add(iSecretCards);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对玩家手中的牌进行排序
|
||||
* @param players 可变参数,接收多个玩家的牌列表
|
||||
*/
|
||||
private static void sortCards(ArrayList<Integer>... players) {
|
||||
for (ArrayList<Integer> player : players) {
|
||||
Collections.sort(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示所有玩家的牌和底牌
|
||||
* @param iPlayer 玩家1的牌号列表
|
||||
* @param iPlayer2 玩家2的牌号列表
|
||||
* @param iPlayer3 玩家3的牌号列表
|
||||
* @param iSecretCards 底牌列表
|
||||
*/
|
||||
private static void showCards(ArrayList<Integer> iPlayer, ArrayList<Integer> iPlayer2,
|
||||
ArrayList<Integer> iPlayer3, ArrayList<Integer> iSecretCards) {
|
||||
ArrayList<String> sPlayer = convertToCardFace(iPlayer);
|
||||
ArrayList<String> sPlayer2 = convertToCardFace(iPlayer2);
|
||||
ArrayList<String> sPlayer3 = convertToCardFace(iPlayer3);
|
||||
ArrayList<String> sSecretCards = convertToCardFace(iSecretCards);
|
||||
|
||||
System.out.println("玩家1:" + sPlayer);
|
||||
System.out.println("玩家2:" + sPlayer2);
|
||||
System.out.println("玩家3:" + sPlayer3);
|
||||
System.out.println("底牌:" + sSecretCards);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将牌号转换为具体的牌面
|
||||
* @param cards 牌号列表
|
||||
* @return ArrayList<String> 转换后的牌面列表
|
||||
*/
|
||||
private static ArrayList<String> convertToCardFace(ArrayList<Integer> cards) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
for (Integer key : cards) {
|
||||
result.add(cardMap.get(key));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
73
src/chapter6/demo64/Game.java
Normal file
73
src/chapter6/demo64/Game.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package chapter6.demo64;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
// Game.java - 游戏类
|
||||
public class Game {
|
||||
private Deck deck;
|
||||
private Player player1;
|
||||
private Player player2;
|
||||
private Player player3;
|
||||
private ArrayList<Card> bottomCards;
|
||||
|
||||
/**
|
||||
* 初始化游戏
|
||||
*/
|
||||
public Game() {
|
||||
deck = new Deck();
|
||||
player1 = new Player("玩家1");
|
||||
player2 = new Player("玩家2");
|
||||
player3 = new Player("玩家3");
|
||||
bottomCards = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始游戏
|
||||
*/
|
||||
public void start() {
|
||||
// 1. 洗牌
|
||||
deck.shuffle();
|
||||
|
||||
// 2. 发牌
|
||||
for (int i = 0; i < 54; i++) {
|
||||
Card card = deck.dealCard();
|
||||
if (i >= 51) {
|
||||
bottomCards.add(card);
|
||||
} else {
|
||||
switch (i % 3) {
|
||||
case 0:
|
||||
player1.receiveCard(card);
|
||||
break;
|
||||
case 1:
|
||||
player2.receiveCard(card);
|
||||
break;
|
||||
case 2:
|
||||
player3.receiveCard(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 显示结果
|
||||
showResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示游戏结果
|
||||
*/
|
||||
private void showResult() {
|
||||
System.out.println(player1.showHand());
|
||||
System.out.println(player2.showHand());
|
||||
System.out.println(player3.showHand());
|
||||
System.out.println("底牌:" + bottomCards);
|
||||
}
|
||||
|
||||
/**
|
||||
* 程序入口
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Game game = new Game();
|
||||
game.start();
|
||||
}
|
||||
}
|
||||
111
src/chapter6/demo64/Main.java
Normal file
111
src/chapter6/demo64/Main.java
Normal file
@@ -0,0 +1,111 @@
|
||||
package chapter6.demo64;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
/* 第一步:准备扑克牌的基本元素 */
|
||||
// 准备4种花色
|
||||
ArrayList<String> colors = new ArrayList<String>();
|
||||
colors.add("♠");
|
||||
colors.add("♥");
|
||||
colors.add("♣");
|
||||
colors.add("♦");
|
||||
|
||||
// 准备13种点数(2-10,J,Q,K,A)
|
||||
ArrayList<String> point = new ArrayList<String>();
|
||||
for (int i = 2; i <= 10; i++) {
|
||||
point.add(i + "");
|
||||
}
|
||||
point.add("J");
|
||||
point.add("Q");
|
||||
point.add("K");
|
||||
point.add("A");
|
||||
|
||||
/* 第二步:组装54张扑克牌 */
|
||||
// 用HashMap将每张牌的编号(0-53)与具体牌面对应起来
|
||||
HashMap<Integer, String> map = new HashMap<Integer, String>();
|
||||
int index = 0; // 牌的编号,从0开始
|
||||
|
||||
// 两层循环,生成52张普通牌(13点数 × 4花色)
|
||||
for (String number : point) {
|
||||
for (String color : colors) {
|
||||
// 将花色与数字组合,形成52张牌,并赋予其编号
|
||||
map.put(index++, color + number);
|
||||
}
|
||||
}
|
||||
|
||||
// 加入大小王,编号为52和53
|
||||
map.put(index++, "小☺");
|
||||
map.put(index++, "大☻");
|
||||
|
||||
/* 第三步:洗牌准备 */
|
||||
// 准备一个数字序列,代表54张牌
|
||||
ArrayList<Integer> cards = new ArrayList<Integer>();
|
||||
for (int i = 0; i <= 53; i++) {
|
||||
cards.add(i); // 此时的cards顺序为0-53
|
||||
}
|
||||
|
||||
// 使用shuffle方法打乱牌的顺序(洗牌)
|
||||
Collections.shuffle(cards);
|
||||
|
||||
/* 第四步:发牌 */
|
||||
// 创建4个集合,分别存储三个玩家的牌和底牌
|
||||
ArrayList<Integer> iPlayer = new ArrayList<Integer>(); // 玩家1的牌
|
||||
ArrayList<Integer> iPlayer2 = new ArrayList<Integer>(); // 玩家2的牌
|
||||
ArrayList<Integer> iPlayer3 = new ArrayList<Integer>(); // 玩家3的牌
|
||||
ArrayList<Integer> iSecretCards = new ArrayList<Integer>(); // 底牌
|
||||
|
||||
// 发牌规则:留3张底牌,其余轮流发给3个玩家
|
||||
for (int i = 0; i < cards.size(); i++) {
|
||||
if (i >= 51) {
|
||||
iSecretCards.add(cards.get(i));// 留取3张底牌
|
||||
} else {
|
||||
if (i % 3 == 0) {
|
||||
iPlayer.add(cards.get(i)); // 与3取余为0的牌发给玩家1
|
||||
} else if (i % 3 == 1) {
|
||||
iPlayer2.add(cards.get(i)); // 与3取余为1的牌发给玩家2
|
||||
} else {
|
||||
iPlayer3.add(cards.get(i)); // 其余的牌发给玩家3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 第五步:整理手牌 */
|
||||
// 对每个玩家手中的牌排序
|
||||
Collections.sort(iPlayer);
|
||||
Collections.sort(iPlayer2);
|
||||
Collections.sort(iPlayer3);
|
||||
|
||||
/* 第六步:转换牌面并显示 */
|
||||
// iPlayer 中的存储的是每个玩家拥有的牌的编号(0-53)
|
||||
// 将玩家手中的牌号转换为具体的牌面
|
||||
ArrayList<String> sPlayer = new ArrayList<String>();
|
||||
ArrayList<String> sPlayer2 = new ArrayList<String>();
|
||||
ArrayList<String> sPlayer3 = new ArrayList<String>();
|
||||
ArrayList<String> sSecretCards = new ArrayList<String>();
|
||||
|
||||
// 根据牌号,从map中找出对应的牌面
|
||||
for (Integer key : iPlayer) {
|
||||
sPlayer.add(map.get(key));
|
||||
}
|
||||
for (Integer key : iPlayer2) {
|
||||
sPlayer2.add(map.get(key));
|
||||
}
|
||||
for (Integer key : iPlayer3) {
|
||||
sPlayer3.add(map.get(key));
|
||||
}
|
||||
|
||||
for (Integer key : iSecretCards) {
|
||||
sSecretCards.add(map.get(key));
|
||||
}
|
||||
|
||||
// 展示每个玩家的牌
|
||||
System.out.println("玩家1:" + sPlayer);
|
||||
System.out.println("玩家2:" + sPlayer2);
|
||||
System.out.println("玩家3:" + sPlayer3);
|
||||
System.out.println("底牌:" + sSecretCards);
|
||||
}
|
||||
}
|
||||
37
src/chapter6/demo64/Player.java
Normal file
37
src/chapter6/demo64/Player.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package chapter6.demo64;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.TreeSet;
|
||||
|
||||
// Player.java - 玩家类
|
||||
public class Player {
|
||||
private String name;
|
||||
// Card类已经实现Comparable接口,可以使用TreeSet自动排序
|
||||
private TreeSet<Card> hand = new TreeSet<>();
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param name 玩家名称
|
||||
*/
|
||||
public Player(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收一张牌
|
||||
* @param card 收到的牌
|
||||
*/
|
||||
public void receiveCard(Card card) {
|
||||
hand.add(card);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示手牌
|
||||
* @return 手牌的字符串表示
|
||||
*/
|
||||
public String showHand() {
|
||||
return name + ":" + hand.toString();
|
||||
}
|
||||
}
|
||||
226
src/chapter6/demo64/README.md
Normal file
226
src/chapter6/demo64/README.md
Normal file
@@ -0,0 +1,226 @@
|
||||
|
||||
本案例要求编写一个**斗地主的洗牌发牌**程序,要求按照斗地主的规则完成洗牌发牌的过程。
|
||||
|
||||
## 任务描述
|
||||
|
||||
一副扑克总共有54张牌,牌面由花色和数字组成(包括J、Q、K、A字母)组成,花色有♠、♥、♦、♣ 四种,分别表示黑桃、红桃、方块、梅花,小☺、大☻分别表示小王和大王。
|
||||
|
||||
斗地主游戏共有3位玩家参与,首先将这54张牌的顺序打乱每人轮流摸一次牌,剩余3张留作底牌,然后在控制台打印3位玩家的牌和3张底牌。
|
||||
|
||||
## 运行结果
|
||||
|
||||

|
||||
|
||||
## 实现思路
|
||||
|
||||
### 1. 准备牌面元素
|
||||
|
||||
- 创建扑克牌的基本元素:花色和点数
|
||||
- 花色:♠(黑桃)、♥(红桃)、♣(梅花)、♦(方块)
|
||||
- 点数:2-10、J、Q、K、A
|
||||
- 使用`ArrayList`分别存储花色和点数
|
||||
|
||||
### 2. 生成完整的牌组
|
||||
|
||||
- 使用HashMap建立牌的编号和具体牌面的对应关系
|
||||
- 通过两层循环组合花色和点数,生成52张普通牌
|
||||
- 额外加入大小王,总共54张牌
|
||||
- 每张牌都有唯一的编号(0-53)
|
||||
|
||||
### 3. 洗牌准备
|
||||
|
||||
- 创建一个包含0-53数字的ArrayList,代表54张牌
|
||||
- 使用`Collections.shuffle()`方法随机打乱这些数字的顺序
|
||||
- 打乱后的顺序就是发牌的顺序
|
||||
|
||||
### 4. 发牌过程
|
||||
|
||||
- 创建4个ArrayList用于存储发牌结果:
|
||||
- 3个玩家的牌(iPlayer1、iPlayer2、iPlayer3)
|
||||
- 1个底牌(iSecretCards)
|
||||
- 发牌规则:
|
||||
- 前51张牌轮流发给3个玩家(i%3来分配)
|
||||
- 最后3张作为底牌
|
||||
|
||||
### 5. 整理手牌
|
||||
|
||||
- 使用`Collections.sort()`方法对每个玩家手中的牌进行排序
|
||||
- 排序是对牌的编号进行排序,方便后续显示
|
||||
|
||||
### 6. 转换和显示
|
||||
|
||||
- 创建新的ArrayList存储实际的牌面字符串
|
||||
- 遍历每个玩家手中的牌号
|
||||
- 通过HashMap查找对应的牌面
|
||||
- 最后打印每个玩家的牌和底牌
|
||||
|
||||
## 关键技术点
|
||||
|
||||
1. 集合的使用:
|
||||
- ArrayList:存储花色、点数和牌组
|
||||
- HashMap:建立编号和牌面的对应关系
|
||||
2. 工具类的应用:
|
||||
- Collections.shuffle():用于洗牌
|
||||
- Collections.sort():用于整理手牌
|
||||
3. 循环的应用:
|
||||
- 两层循环生成牌组
|
||||
- 取余操作(%)实现轮流发牌
|
||||
|
||||
|
||||
## 示例代码
|
||||
|
||||
```java
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
/* 第一步:准备扑克牌的基本元素 */
|
||||
// 准备4种花色
|
||||
ArrayList<String> colors = new ArrayList<String>();
|
||||
colors.add("♠");
|
||||
colors.add("♥");
|
||||
colors.add("♣");
|
||||
colors.add("♦");
|
||||
|
||||
// TODO 准备13种点数(2-10,J,Q,K,A)
|
||||
ArrayList<String> point = new ArrayList<String>();
|
||||
|
||||
|
||||
/* 第二步:组装54张扑克牌 */
|
||||
// 用HashMap将每张牌的编号(0-53)与具体牌面对应起来
|
||||
HashMap<Integer, String> map = new HashMap<Integer, String>();
|
||||
int index = 0; // 牌的编号,从0开始
|
||||
|
||||
// TODO 两层循环,生成52张普通牌(13点数 × 4花色)
|
||||
|
||||
|
||||
// 加入大小王,编号为52和53
|
||||
map.put(index++, "小☺");
|
||||
map.put(index++, "大☻");
|
||||
|
||||
/* 第三步:洗牌准备 */
|
||||
// TOOD 准备一个数字序列,代表54张牌
|
||||
ArrayList<Integer> cards = new ArrayList<Integer>();
|
||||
|
||||
|
||||
// 使用shuffle方法打乱牌的顺序(洗牌)
|
||||
Collections.shuffle(cards);
|
||||
|
||||
/* 第四步:发牌 */
|
||||
// 创建4个集合,分别存储三个玩家的牌和底牌
|
||||
ArrayList<Integer> iPlayer = new ArrayList<Integer>(); // 玩家1的牌
|
||||
ArrayList<Integer> iPlayer2 = new ArrayList<Integer>(); // 玩家2的牌
|
||||
ArrayList<Integer> iPlayer3 = new ArrayList<Integer>(); // 玩家3的牌
|
||||
ArrayList<Integer> iSecretCards = new ArrayList<Integer>(); // 底牌
|
||||
|
||||
// TODO 发牌规则:留3张底牌,其余轮流发给3个玩家
|
||||
for (int i = 0; i < cards.size(); i++) {
|
||||
|
||||
}
|
||||
|
||||
/* 第五步:整理手牌 */
|
||||
// 对每个玩家手中的牌排序
|
||||
Collections.sort(iPlayer);
|
||||
Collections.sort(iPlayer2);
|
||||
Collections.sort(iPlayer3);
|
||||
|
||||
/* 第六步:转换牌面并显示 */
|
||||
// iPlayer 中的存储的是每个玩家拥有的牌的编号(0-53)
|
||||
// 将玩家手中的牌号转换为具体的牌面
|
||||
ArrayList<String> sPlayer = new ArrayList<String>();
|
||||
ArrayList<String> sPlayer2 = new ArrayList<String>();
|
||||
ArrayList<String> sPlayer3 = new ArrayList<String>();
|
||||
ArrayList<String> sSecretCards = new ArrayList<String>();
|
||||
|
||||
// TODO 根据牌号,从map中找出对应的牌面
|
||||
for (Integer key : iPlayer) {
|
||||
sPlayer.add(map.get(key));
|
||||
}
|
||||
|
||||
|
||||
// 展示每个玩家的牌
|
||||
System.out.println("玩家1:" + sPlayer);
|
||||
System.out.println("玩家2:" + sPlayer2);
|
||||
System.out.println("玩家3:" + sPlayer3);
|
||||
System.out.println("底牌:" + sSecretCards);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 进阶任务
|
||||
|
||||
利用面向对象思想改造程序
|
||||
|
||||
### 类的设计级要求
|
||||
#### 1. Card类(扑克牌)
|
||||
|
||||
**职责**:表示一张扑克牌
|
||||
|
||||
- 属性:
|
||||
- suit(花色):字符串类型
|
||||
- rank(点数):字符串类型
|
||||
- index(编号):整型
|
||||
- 功能:
|
||||
- 构造方法:初始化一张牌
|
||||
- toString方法:返回牌面字符串
|
||||
- 实现Comparable接口:用于排序
|
||||
|
||||
#### 2. Deck类(牌组)
|
||||
|
||||
**职责**:管理一副完整的扑克牌
|
||||
|
||||
- 属性:
|
||||
- cards:Card类型的ArrayList
|
||||
- 花色和点数的常量数组
|
||||
- 功能:
|
||||
- 初始化54张牌
|
||||
- 洗牌方法
|
||||
- 发牌方法
|
||||
|
||||
#### 3. Player类(玩家)
|
||||
|
||||
**职责**:管理玩家信息和手牌
|
||||
|
||||
- 属性:
|
||||
- name:玩家名称
|
||||
- hand:存储手牌的ArrayList
|
||||
- 功能:
|
||||
- 接收牌
|
||||
- 整理手牌
|
||||
- 显示手牌
|
||||
|
||||
#### 4. Game类(游戏管理)
|
||||
|
||||
**职责**:控制游戏流程
|
||||
|
||||
- 属性:
|
||||
- deck:牌组对象
|
||||
- 三个玩家对象
|
||||
- bottomCards:底牌列表
|
||||
- 功能:
|
||||
- 初始化游戏
|
||||
- 执行游戏流程
|
||||
- 显示游戏结果
|
||||
|
||||
### 改造要点
|
||||
|
||||
#### 1. 封装性要求
|
||||
|
||||
- 所有类的属性都应该是私有的
|
||||
- 必要的属性提供getter/setter方法
|
||||
- 对外只暴露必要的方法
|
||||
|
||||
#### 2. 类之间的关系
|
||||
|
||||
- Game类包含Deck类和Player类的对象
|
||||
- Player类包含Card类的对象
|
||||
- Deck类负责Card对象的创建和管理
|
||||
|
||||
#### 3. 功能性要求
|
||||
|
||||
- 保持原有程序的所有功能
|
||||
- 洗牌和发牌的逻辑不变
|
||||
- 结果显示格式保持一致
|
||||
58
src/chapter7/Example01.java
Normal file
58
src/chapter7/Example01.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package chapter7;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Example01 {
|
||||
public static void main(String[] args) {
|
||||
/**
|
||||
* Step 1 创建普通文件
|
||||
*/
|
||||
File file1 = new File("out/chapter7/file1.txt");
|
||||
if (file1.exists()) {
|
||||
// 如果文件存在就删除
|
||||
System.out.println("文件file1.txt存在");
|
||||
file1.delete();
|
||||
System.out.println("文件file1.txt已删除");
|
||||
} else {
|
||||
// 如果文件不存在就创建
|
||||
System.out.println("文件file1.txt不存在");
|
||||
|
||||
try {
|
||||
file1.createNewFile();
|
||||
System.out.println("文件file1.txt已创建");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("\n");
|
||||
|
||||
/**
|
||||
* Step 2 创建目录
|
||||
*/
|
||||
File parent = file1.getParentFile();
|
||||
if (! parent.exists()) {
|
||||
// 如果父目录不存在就创建
|
||||
System.out.println("父目录不存在");
|
||||
parent.mkdirs();
|
||||
System.out.println("父目录已创建");
|
||||
}
|
||||
|
||||
if (file1.exists()) {
|
||||
// 如果文件存在就删除
|
||||
System.out.println("文件存在");
|
||||
file1.delete();
|
||||
System.out.println("文件已删除");
|
||||
} else {
|
||||
// 如果文件不存在就创建
|
||||
System.out.println("文件不存在");
|
||||
try {
|
||||
file1.createNewFile();
|
||||
System.out.println("文件已创建");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
16
src/chapter7/Example03.java
Normal file
16
src/chapter7/Example03.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package chapter7;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Example03 {
|
||||
public static void main(String[] args) {
|
||||
File file = new File("src/chapter7");
|
||||
if (file.isDirectory()) {
|
||||
System.out.println("是目录");
|
||||
String[] names = file.list();
|
||||
for (String name : names) {
|
||||
System.out.println(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/chapter7/Example04.java
Normal file
39
src/chapter7/Example04.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package chapter7;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
public class Example04 {
|
||||
public static void main(String[] args) {
|
||||
// 创建 File 对象
|
||||
File file = new File("src/chapter7");
|
||||
// 创建过滤器对象
|
||||
FilenameFilter filter = new FilenameFilter() {
|
||||
// 实现 accept 方法
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
File currFile = new File(dir, name);
|
||||
if (currFile.isFile() && name.endsWith(".java")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (file.exists() && file.isDirectory()) {
|
||||
String[] names = file.list(filter);
|
||||
for (String name : names) {
|
||||
System.out.println(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (file.exists() && file.isDirectory()) {
|
||||
File[] files = file.listFiles(filter);
|
||||
for (File currentFile : files) {
|
||||
System.out.println(currentFile);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
27
src/chapter7/Example05.java
Normal file
27
src/chapter7/Example05.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package chapter7;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Example05 {
|
||||
public static void main(String[] args) {
|
||||
File file = new File("src");
|
||||
showFiles(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定目录下的所有文件
|
||||
* @param dir 目录
|
||||
*/
|
||||
public static void showFiles(File dir) {
|
||||
// 获取当前目录下所有文件的数组
|
||||
File[] fileArray = dir.listFiles();
|
||||
for (File file : fileArray) {
|
||||
if (file.isDirectory()) {
|
||||
// 如果是目录就递归调用
|
||||
showFiles(file);
|
||||
}
|
||||
// 打印文件的绝对路径
|
||||
System.out.println(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
16
src/chapter7/Example06.java
Normal file
16
src/chapter7/Example06.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package chapter7;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Example06 {
|
||||
public static void main(String[] args) {
|
||||
File file = new File("resources");
|
||||
if (file.exists()) {
|
||||
if (file.delete()) {
|
||||
System.out.println("删除成功!");
|
||||
} else {
|
||||
System.out.println("删除失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/chapter7/Example07.java
Normal file
32
src/chapter7/Example07.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package chapter7;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Example07 {
|
||||
public static void main(String[] args) {
|
||||
File dir = new File("d:/hello");
|
||||
deleteFiles(dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定目录下的所有文件(包括子目录)
|
||||
* @param dir 目录
|
||||
*/
|
||||
public static void deleteFiles(File dir) {
|
||||
if (dir.exists()) {
|
||||
File[] files = dir.listFiles();
|
||||
// 删除当前目录下的所有文件
|
||||
for (File file : files) {
|
||||
// 如果是目录就递归调用
|
||||
if (file.isDirectory()) {
|
||||
deleteFiles(file);
|
||||
} else {
|
||||
// 如果是文件就删除
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
// 删除当前目录
|
||||
dir.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
19
src/chapter7/Example08.java
Normal file
19
src/chapter7/Example08.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package chapter7;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Example08 {
|
||||
public static void main(String[] args) {
|
||||
// 使用try-with-resources自动关闭资源
|
||||
try (FileWriter writer = new FileWriter("note.txt")) {
|
||||
// 写入一些文本
|
||||
writer.write("这是第一行\n"); // \n表示换行
|
||||
writer.write("这是第二行\n");
|
||||
System.out.println("文件写入成功!");
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println("写入文件出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
28
src/chapter7/Example09.java
Normal file
28
src/chapter7/Example09.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package chapter7;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Example09 {
|
||||
public static void main(String[] args) {
|
||||
FileWriter writer = null; // 在try外声明,以便finally中可以访问
|
||||
try {
|
||||
writer = new FileWriter("note.txt");
|
||||
writer.write("这是第一行\n");
|
||||
writer.write("这是第二行\n");
|
||||
System.out.println("文件写入成功!");
|
||||
} catch (IOException e) {
|
||||
System.out.println("写入文件出错:" + e.getMessage());
|
||||
} finally {
|
||||
// 在finally中确保关闭资源
|
||||
if (writer != null) { // 防止writer未初始化就抛出异常
|
||||
try {
|
||||
writer.close(); // close()方法也可能抛出IOException
|
||||
} catch (IOException e) {
|
||||
System.out.println("关闭文件出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
23
src/chapter7/Example10.java
Normal file
23
src/chapter7/Example10.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package chapter7;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Example10 {
|
||||
public static void main(String[] args) {
|
||||
// 使用try-with-resources自动关闭资源
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new FileReader("note.txt"))) {
|
||||
|
||||
String line;
|
||||
// 逐行读取文件内容
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println("读取文件出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
50
src/chapter7/FileOperationHomework.java
Normal file
50
src/chapter7/FileOperationHomework.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package chapter7;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class FileOperationHomework {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
// 1. 获取文件名
|
||||
System.out.print("请输入文件名:");
|
||||
String fileName = scanner.nextLine();
|
||||
|
||||
// 2. 获取要写入的行数
|
||||
System.out.print("请输入要写入的行数:");
|
||||
int lines = scanner.nextInt();
|
||||
scanner.nextLine(); // 消除换行符
|
||||
|
||||
// 3. 写入文件
|
||||
try (FileWriter writer = new FileWriter(fileName)) {
|
||||
// 循环获取用户输入并写入
|
||||
for (int i = 1; i <= lines; i++) {
|
||||
System.out.print("请输入第" + i + "行内容:");
|
||||
String content = scanner.nextLine();
|
||||
writer.write(content + "\n");
|
||||
}
|
||||
System.out.println("文件写入成功!");
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println("写入文件出错:" + e.getMessage());
|
||||
return; // 如果写入出错,直接返回
|
||||
}
|
||||
|
||||
// 4. 读取并显示文件内容
|
||||
System.out.println("\n文件内容如下:");
|
||||
System.out.println("--------------------");
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new FileReader(fileName))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
System.out.println("--------------------");
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println("读取文件出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user