diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..29f2861 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..5845dbf --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/.idea/libraries/lession00.xml b/.idea/libraries/lession00.xml new file mode 100644 index 0000000..c81e1fb --- /dev/null +++ b/.idea/libraries/lession00.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0548357..78aa587 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,13 @@ +<<<<<<< HEAD +======= + + +>>>>>>> b127eb2ca79831ab03cfe24ad4732db233126931 diff --git a/.idea/modules.xml b/.idea/modules.xml index c239d47..87bc63d 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,16 @@ +<<<<<<< HEAD +======= + + + + + + +>>>>>>> b127eb2ca79831ab03cfe24ad4732db233126931 \ No newline at end of file diff --git a/.idea/swagger-settings.xml b/.idea/swagger-settings.xml new file mode 100644 index 0000000..433d6eb --- /dev/null +++ b/.idea/swagger-settings.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Calculater/.gitignore b/Calculater/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/Calculater/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/Calculater/.idea/.gitignore b/Calculater/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/Calculater/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Calculater/.idea/misc.xml b/Calculater/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/Calculater/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Calculater/.idea/modules.xml b/Calculater/.idea/modules.xml new file mode 100644 index 0000000..c239d47 --- /dev/null +++ b/Calculater/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Calculater/.idea/vcs.xml b/Calculater/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Calculater/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Calculater/Calculater.iml b/Calculater/Calculater.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Calculater/Calculater.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Calculater/src/Calculater.java b/Calculater/src/Calculater.java new file mode 100644 index 0000000..75c0461 --- /dev/null +++ b/Calculater/src/Calculater.java @@ -0,0 +1,153 @@ +import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +public class Calculater extends Application { + private Label display; + private double firstNumber = 0; + private String operator = ""; + private boolean startNewNumber = true; + + public static void main(String[] args) { + launch(args); + } + + @Override + public void start(Stage primaryStage) { + // Create display label + display = new Label("0.0"); + display.setStyle("-fx-font-size: 30px;"); + display.setMinWidth(200); // Adjust width for display + display.setAlignment(Pos.CENTER_RIGHT); // Align text to the right + + // Set up the buttons + GridPane gridPane = createButtonGrid(); + + // Create the layout + VBox layout = new VBox(10); + layout.setPadding(new Insets(10)); + layout.setAlignment(Pos.CENTER); + layout.getChildren().addAll(display, gridPane); + + // Set up the scene and stage + Scene scene = new Scene(layout, 300, 400); + primaryStage.setTitle("Calculator"); + primaryStage.setScene(scene); + primaryStage.show(); + } + + private GridPane createButtonGrid() { + GridPane grid = new GridPane(); + grid.setHgap(10); + grid.setVgap(10); + grid.setAlignment(Pos.CENTER); + + // Create buttons with a similar layout to your screenshot + String[][] buttonText = { + {"AC", "±", "%", "÷"}, + {"7", "8", "9", "×"}, + {"4", "5", "6", "-"}, + {"1", "2", "3", "+"}, + {"0", ".", "=", ""} + }; + + // Set button size + int buttonSize = 50; + + // Add buttons to the grid + int row = 0; + for (int i = 0; i < buttonText.length; i++) { + for (int j = 0; j < buttonText[i].length; j++) { + if (!buttonText[i][j].isEmpty()) { + Button button = createButton(buttonText[i][j], buttonSize); + if (buttonText[i][j].equals("0")) { + grid.add(button, j, row, 2, 1); // Make '0' span two columns + } else { + grid.add(button, j, row); + } + } + } + row++; + } + + return grid; + } + + private Button createButton(String text, int size) { + Button button = new Button(text); + button.setMinSize(size, size); + button.setStyle("-fx-font-size: 18px; -fx-background-color: white; -fx-border-color: lightgray;"); + button.setOnAction(e -> handleButtonPress(text)); + return button; + } + + private void handleButtonPress(String text) { + if (text.matches("\\d") || text.equals(".")) { + handleNumberInput(text); + } else if (text.equals("AC")) { + handleClear(); + } else if (text.equals("=")) { + handleEquals(); + } else { + handleOperator(text); + } + } + + private void handleNumberInput(String text) { + if (startNewNumber) { + display.setText(text); + startNewNumber = false; + } else { + display.setText(display.getText() + text); + } + } + + private void handleClear() { + display.setText("0"); + firstNumber = 0; + operator = ""; + startNewNumber = true; + } + + private void handleOperator(String text) { + firstNumber = Double.parseDouble(display.getText()); + operator = text; + startNewNumber = true; + } + + private void handleEquals() { + double secondNumber = Double.parseDouble(display.getText()); + double result = 0; + + switch (operator) { + case "+": + result = firstNumber + secondNumber; + break; + case "-": + result = firstNumber - secondNumber; + break; + case "×": + result = firstNumber * secondNumber; + break; + case "÷": + if (secondNumber != 0) { + result = firstNumber / secondNumber; + } else { + display.setText("Error"); + return; + } + break; + case "%": + result = firstNumber % secondNumber; + break; + } + + display.setText(String.valueOf(result)); + startNewNumber = true; + } +} \ No newline at end of file diff --git a/Calculater/src/Main.java b/Calculater/src/Main.java new file mode 100644 index 0000000..1e87232 --- /dev/null +++ b/Calculater/src/Main.java @@ -0,0 +1,17 @@ +// 按两次 Shift 打开“随处搜索”对话框并输入 `show whitespaces`, +// 然后按 Enter 键。现在,您可以在代码中看到空格字符。 +public class Main { + public static void main(String[] args) { + // 当文本光标位于高亮显示的文本处时按 Alt+Enter, + // 可查看 IntelliJ IDEA 对于如何修正该问题的建议。 + System.out.printf("Hello and welcome!"); + + // 按 Shift+F10 或点击装订区域中的绿色箭头按钮以运行脚本。 + for (int i = 1; i <= 5; i++) { + + // 按 Shift+F9 开始调试代码。我们已为您设置了一个断点, + // 但您始终可以通过按 Ctrl+F8 添加更多断点。 + System.out.println("i = " + i); + } + } +} \ No newline at end of file diff --git a/Git/.idea/.gitignore b/Git/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/Git/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Git/.idea/misc.xml b/Git/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/Git/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Git/.idea/modules.xml b/Git/.idea/modules.xml new file mode 100644 index 0000000..bff1581 --- /dev/null +++ b/Git/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Git/.idea/vcs.xml b/Git/.idea/vcs.xml new file mode 100644 index 0000000..eda9e45 --- /dev/null +++ b/Git/.idea/vcs.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Git/Calculate b/Git/Calculate new file mode 160000 index 0000000..4bd0fd7 --- /dev/null +++ b/Git/Calculate @@ -0,0 +1 @@ +Subproject commit 4bd0fd7b4ceddcd9ec62ba4c3d87077117eda55e diff --git a/Git/Computer b/Git/Computer new file mode 160000 index 0000000..119cf11 --- /dev/null +++ b/Git/Computer @@ -0,0 +1 @@ +Subproject commit 119cf11296ee84f06d011f06744d1f6c00b7f7e1 diff --git a/Git/Git.iml b/Git/Git.iml new file mode 100644 index 0000000..de4f805 --- /dev/null +++ b/Git/Git.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Git/calculater b/Git/calculater new file mode 160000 index 0000000..c2becd2 --- /dev/null +++ b/Git/calculater @@ -0,0 +1 @@ +Subproject commit c2becd26041f9a5c6c51830c15261e116fc2c6a0 diff --git a/Java1113/.gitignore b/Java1113/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/Java1113/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/Java1113/.idea/.gitignore b/Java1113/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/Java1113/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Java1113/.idea/.name b/Java1113/.idea/.name new file mode 100644 index 0000000..ee3c080 --- /dev/null +++ b/Java1113/.idea/.name @@ -0,0 +1 @@ +getLastDay1113.java \ No newline at end of file diff --git a/Java1113/.idea/misc.xml b/Java1113/.idea/misc.xml new file mode 100644 index 0000000..e208459 --- /dev/null +++ b/Java1113/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Java1113/.idea/modules.xml b/Java1113/.idea/modules.xml new file mode 100644 index 0000000..ced4bd0 --- /dev/null +++ b/Java1113/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Java1113/_00Lesson1113/_00Lesson1113.iml b/Java1113/_00Lesson1113/_00Lesson1113.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Java1113/_00Lesson1113/_00Lesson1113.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Java1113/_00Lesson1113/src/Java1113/java1113.zip b/Java1113/_00Lesson1113/src/Java1113/java1113.zip new file mode 100644 index 0000000..90ed17b Binary files /dev/null and b/Java1113/_00Lesson1113/src/Java1113/java1113.zip differ diff --git a/Java1113/_00Lesson1113/src/Java1113/lesson00/Hello1113.java b/Java1113/_00Lesson1113/src/Java1113/lesson00/Hello1113.java new file mode 100644 index 0000000..d0a07d9 --- /dev/null +++ b/Java1113/_00Lesson1113/src/Java1113/lesson00/Hello1113.java @@ -0,0 +1,9 @@ +package Java1113.lession00; + +public class Hello1113 { + public static void main(String[] args) { + System.out.println("学号:212211113"); + System.out.println("姓名:陈永锐"); + } +} + diff --git a/Java1113/_00Lesson1113/src/Main.java b/Java1113/_00Lesson1113/src/Main.java new file mode 100644 index 0000000..1e87232 --- /dev/null +++ b/Java1113/_00Lesson1113/src/Main.java @@ -0,0 +1,17 @@ +// 按两次 Shift 打开“随处搜索”对话框并输入 `show whitespaces`, +// 然后按 Enter 键。现在,您可以在代码中看到空格字符。 +public class Main { + public static void main(String[] args) { + // 当文本光标位于高亮显示的文本处时按 Alt+Enter, + // 可查看 IntelliJ IDEA 对于如何修正该问题的建议。 + System.out.printf("Hello and welcome!"); + + // 按 Shift+F10 或点击装订区域中的绿色箭头按钮以运行脚本。 + for (int i = 1; i <= 5; i++) { + + // 按 Shift+F9 开始调试代码。我们已为您设置了一个断点, + // 但您始终可以通过按 Ctrl+F8 添加更多断点。 + System.out.println("i = " + i); + } + } +} \ No newline at end of file diff --git a/Java1113/_01Lesson1113/_01Lesson1113.iml b/Java1113/_01Lesson1113/_01Lesson1113.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Java1113/_01Lesson1113/_01Lesson1113.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Java1113/_01Lesson1113/data/StudentList.txt b/Java1113/_01Lesson1113/data/StudentList.txt new file mode 100644 index 0000000..72d633f --- /dev/null +++ b/Java1113/_01Lesson1113/data/StudentList.txt @@ -0,0 +1,88 @@ +211706724 吴熹 +211904224 宋昊泽 +211914127 林浩文 +212003160 李志颍 +212106263 钟欣桦 +212106559 赵宇杰 +212106610 方懋建 +212106649 周元宣 +212202243 尹杰 +212202301 鲍金辉 +212203152 陈周烨 +212204263 李齐贤 +212206201 蔡承霖 +212206203 陈海翔 +212206204 陈佳媛 +212206212 陈子俊 +212206213 邓泽玉 +212206216 方琦 +212206218 龚心怡 +212206219 洪彬浩 +212206223 贾旺勇 +212206225 李杰 +212206226 李文军 +212206227 李文涛 +212206228 梁晓峰 +212206235 林延景 +212206236 林志煌 +212206237 刘灵峰 +212206239 彭应文 +212206243 汤宜默 +212206244 王家彬 +212206245 翁启凡 +212206247 吴宇铉 +212206248 先泽宇 +212206249 谢伟 +212206250 谢潇航 +212206257 张俊林 +212206260 赵本智 +212206262 郑亿 +212206264 朱昊 +212206266 蔡军仁 +212206268 陈朝阳 +212206269 陈达坤 +212206272 陈文熙 +212206276 陈正琦 +212206279 高晨纲 +212206280 高晨涛 +212206283 黄嘉铭 +212206285 蒋蒸 +212206288 李铭伟 +212206289 李少钧 +212206292 林秋荻 +212206295 陆生荣 +212206297 潘俊杰 +212206298 潘淑君 +212206300 宋鹏飞 +212206304 王柄盛 +212206307 王伟强 +212206308 温静远 +212206309 吴静怡 +212206310 吴翔宇 +212206313 杨鹏 +212206315 姚翔 +212206316 叶锋 +212206318 叶浙波 +212206321 詹旭航 +212206322 张杰 +212206324 张益宁 +212206326 赵思嘉 +212206327 郑鹏俊 +212206328 郑诗鹏 +212206329 朱佳辉 +212206330 祝豪政 +212206428 陆俊谕 +212207131 谢子建 +212208324 赖美娟 +212208407 陈锴德 +212211108 陈惠民 +212211113 陈永锐 +212211211 郭运盛 +212211227 梁永杰 +212211316 谢宇杰 +212211319 杨靖 +212214381 林聪 +212214417 周俊杰 +212217240 吴昊 +212217253 于建潮 +212218111 黄晓彤 diff --git a/Java1113/_01Lesson1113/src/Java1113/data/StudentList.txt b/Java1113/_01Lesson1113/src/Java1113/data/StudentList.txt new file mode 100644 index 0000000..72d633f --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/data/StudentList.txt @@ -0,0 +1,88 @@ +211706724 吴熹 +211904224 宋昊泽 +211914127 林浩文 +212003160 李志颍 +212106263 钟欣桦 +212106559 赵宇杰 +212106610 方懋建 +212106649 周元宣 +212202243 尹杰 +212202301 鲍金辉 +212203152 陈周烨 +212204263 李齐贤 +212206201 蔡承霖 +212206203 陈海翔 +212206204 陈佳媛 +212206212 陈子俊 +212206213 邓泽玉 +212206216 方琦 +212206218 龚心怡 +212206219 洪彬浩 +212206223 贾旺勇 +212206225 李杰 +212206226 李文军 +212206227 李文涛 +212206228 梁晓峰 +212206235 林延景 +212206236 林志煌 +212206237 刘灵峰 +212206239 彭应文 +212206243 汤宜默 +212206244 王家彬 +212206245 翁启凡 +212206247 吴宇铉 +212206248 先泽宇 +212206249 谢伟 +212206250 谢潇航 +212206257 张俊林 +212206260 赵本智 +212206262 郑亿 +212206264 朱昊 +212206266 蔡军仁 +212206268 陈朝阳 +212206269 陈达坤 +212206272 陈文熙 +212206276 陈正琦 +212206279 高晨纲 +212206280 高晨涛 +212206283 黄嘉铭 +212206285 蒋蒸 +212206288 李铭伟 +212206289 李少钧 +212206292 林秋荻 +212206295 陆生荣 +212206297 潘俊杰 +212206298 潘淑君 +212206300 宋鹏飞 +212206304 王柄盛 +212206307 王伟强 +212206308 温静远 +212206309 吴静怡 +212206310 吴翔宇 +212206313 杨鹏 +212206315 姚翔 +212206316 叶锋 +212206318 叶浙波 +212206321 詹旭航 +212206322 张杰 +212206324 张益宁 +212206326 赵思嘉 +212206327 郑鹏俊 +212206328 郑诗鹏 +212206329 朱佳辉 +212206330 祝豪政 +212206428 陆俊谕 +212207131 谢子建 +212208324 赖美娟 +212208407 陈锴德 +212211108 陈惠民 +212211113 陈永锐 +212211211 郭运盛 +212211227 梁永杰 +212211316 谢宇杰 +212211319 杨靖 +212214381 林聪 +212214417 周俊杰 +212217240 吴昊 +212217253 于建潮 +212218111 黄晓彤 diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/Market1113.java b/Java1113/_01Lesson1113/src/Java1113/lesson01/Market1113.java new file mode 100644 index 0000000..833bd09 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/Market1113.java @@ -0,0 +1,40 @@ +package Java1113.lesson01; +public class Market1113 { + String name; + Product1113[] products; + //构造方法,用数组的形式创建超市对象以及商品清单 + Market1113(String name, Product1113[] products) { + this.name = name; + this.products = products; + } + //情况1:按商品名称销售单个商品 + String sell(String productName) { + for (Product1113 product : products) { + if (product.getName().equals(productName)) { + return productName; + } + } + return null; // 商品不存在,返回null + } + //情况2:按商品清单销售多个商品 + String sell(Product1113[] shoppingList) { + //设置已购商品为可变性字符串 + StringBuilder ygsp = new StringBuilder(); + for (Product1113 gwqd : shoppingList) {//遍历顾客购物清单 + for (Product1113 product : products) {//遍历超市中所有商品 + if (product.equals(gwqd)) {//如果二者相匹配 + if (ygsp.length() > 0) { + ygsp.append(", ");//在商品列表中以逗号作为分隔符 + } + ygsp.append(product.getName());//添加商品名称到到已购清单中 + break; //跳出内循环,继续检测下一个顾客想要的商品 + } + } + } + return ygsp.toString();//返回商品列表 + } + String getName() { + return name; + } +} + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/Person1113.java b/Java1113/_01Lesson1113/src/Java1113/lesson01/Person1113.java new file mode 100644 index 0000000..2191f36 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/Person1113.java @@ -0,0 +1,19 @@ +package Java1113.lesson01; +public class Person1113 { + String name; + //构造方法,创建顾客对象并设置姓名 + Person1113(String name) { + this.name = name; + } + //当顾客去超市购买单个商品 + String shopping(Market1113 market, String productName) { + return market.sell(productName); + }//调用sell方法购买单个商品并返回购买结果 + //当顾客去超市购买多个商品 + public String shopping(Market1113 market, Product1113[] shoppingList) { + return market.sell(shoppingList); + }//调用sell方法购买单个商品并返回购买结果 + public String getName() { + return name; + } +} diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/Product1113.java b/Java1113/_01Lesson1113/src/Java1113/lesson01/Product1113.java new file mode 100644 index 0000000..fc592bd --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/Product1113.java @@ -0,0 +1,23 @@ +package Java1113.lesson01; +public class Product1113 { + String name; + //构造方法,创建商品对象并设置商品名 + Product1113(String name) { + this.name = name; + } + String getName() { + return name; + } + //重写equals方法,通过商品名比较两个商品是否相等 + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + Product1113 product = (Product1113) obj; + return name.equals(product.name); + } + //重写toString方法,将商品名以字符串的形式返回 + public String toString() { + return name; + } +} + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/Shopping1113.java b/Java1113/_01Lesson1113/src/Java1113/lesson01/Shopping1113.java new file mode 100644 index 0000000..ea05aac --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/Shopping1113.java @@ -0,0 +1,25 @@ +package Java1113.lesson01; +public class Shopping1113 { + public static void main(String[] args) { + //创建超市对象,指定可售商品清单 + Product1113[] marketProducts = {new Product1113("豆浆机"), new Product1113("吹风机"), new Product1113("破壁机"), new Product1113("咖啡机")};//创建超市物品清单 + Market1113 market = new Market1113("永辉", marketProducts); + //创建购物者对象,指定姓名 + Person1113 person = new Person1113("张木强"); + //创建需要购买的商品清单 + Product1113[] shoppingList = {new Product1113("豆浆机"), new Product1113("吹风机")};//创建顾客购物清单 + //再构建顾客购物清单,使即使超市不含有购物清单中的商品也可输出顾客原始购物清单 + StringBuilder gwqd = new StringBuilder(); + for (Product1113 product : shoppingList) { + if (gwqd.length() > 0) { + gwqd.append(", "); + } + gwqd.append(product.getName()); + } + //模拟顾客在超市购买商品 + String ygm = person.shopping(market, shoppingList); + //输出顾客的购买的结果 + System.out.println(person.getName() + "的购物清单:[" + gwqd + "]"); + System.out.println(person.getName() + "在" + market.getName() + "超市买到了:" + ygm); + } +} \ No newline at end of file diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/Person1113.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/Person1113.html new file mode 100644 index 0000000..6561395 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/Person1113.html @@ -0,0 +1,248 @@ + + + + + +Person1113 + + + + + + + + +
+ + +
+ + + + +
+ + + +
+
Java1113.lesson01
+

Person1113

+
+
+ +
+
    +
  • +
    +
    +
    public class Person1113
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Ҫ

      + + + + + + + + + + + + + + +
      з ʵ  
      ޶˵
      java.lang.StringgetName() 
      java.lang.Stringshopping(Java1113.lesson01.Market1113 market, + Java1113.lesson01.Product1113[] shoppingList) 
      +
        +
      • + + +

        ̳еķ java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      ϸ

      + + + +
        +
      • +

        shopping

        +
        public java.lang.String shopping(Java1113.lesson01.Market1113 market,
        +                                 Java1113.lesson01.Product1113[] shoppingList)
        +
      • +
      + + + +
        +
      • +

        getName

        +
        public java.lang.String getName()
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + +
+ + + + +
+ + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/package-frame.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/package-frame.html new file mode 100644 index 0000000..270bc82 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/package-frame.html @@ -0,0 +1,20 @@ + + + + + +Java1113.lesson01 + + + + + +

Java1113.lesson01

+
+

+ +
+ + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/package-summary.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/package-summary.html new file mode 100644 index 0000000..dc5bc03 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/package-summary.html @@ -0,0 +1,138 @@ + + + + + +Java1113.lesson01 + + + + + + + + +
+ + +
+ + + + +
+ + +
+

 Java1113.lesson01

+
+
+ +
+ +
+ + +
+ + + + +
+ + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/package-tree.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/package-tree.html new file mode 100644 index 0000000..aac42bc --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/Java1113/lesson01/package-tree.html @@ -0,0 +1,129 @@ + + + + + +Java1113.lesson01 ֲṹ + + + + + + + + +
+ + +
+ + + + +
+ + +
+

Java1113.lesson01ķֲṹ

+
+
+

ֲṹ

+ +
+ +
+ + +
+ + + + +
+ + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/allclasses-frame.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/allclasses-frame.html new file mode 100644 index 0000000..5d57a6c --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/allclasses-frame.html @@ -0,0 +1,19 @@ + + + + + + + + + + + +

+
+ +
+ + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/allclasses-noframe.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/allclasses-noframe.html new file mode 100644 index 0000000..1f2b8af --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/allclasses-noframe.html @@ -0,0 +1,19 @@ + + + + + + + + + + + +

+
+ +
+ + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/constant-values.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/constant-values.html new file mode 100644 index 0000000..a9101d2 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/constant-values.html @@ -0,0 +1,120 @@ + + + + + +ֵֶ + + + + + + + + +
+ + +
+ + + + +
+ + +
+

ֵֶ

+

Ŀ¼

+
+ +
+ + +
+ + + + +
+ + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/deprecated-list.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/deprecated-list.html new file mode 100644 index 0000000..8746102 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/deprecated-list.html @@ -0,0 +1,120 @@ + + + + + +ѹʱб + + + + + + + + +
+ + +
+ + + + +
+ + +
+

ѹʱ API

+

Ŀ¼

+
+ +
+ + +
+ + + + +
+ + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/help-doc.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/help-doc.html new file mode 100644 index 0000000..002f725 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/help-doc.html @@ -0,0 +1,217 @@ + + + + + +API + + + + + + + + +
+ + +
+ + + + +
+ + +
+

API ĵ֯ʽ

+
API (Ӧó̽ӿ) ĵӦڵеĿҳ,
+
+
+ +˰ļʹñ׼ doclet ɵ API ĵ
+ +
+ + +
+ + + + +
+ + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-1.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-1.html new file mode 100644 index 0000000..cf05bf2 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-1.html @@ -0,0 +1,125 @@ + + + + + +G - + + + + + + + + +
+ + +
+ + + + +
+ + +
G J P S  + + +

G

+
+
getName() - еķJava1113.lesson01.Person1113
+
 
+
+G J P S 
+ +
+ + +
+ + + + +
+ + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-2.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-2.html new file mode 100644 index 0000000..18b91ea --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-2.html @@ -0,0 +1,125 @@ + + + + + +J - + + + + + + + + +
+ + +
+ + + + +
+ + +
G J P S  + + +

J

+
+
Java1113.lesson01 - Java1113.lesson01
+
 
+
+G J P S 
+ +
+ + +
+ + + + +
+ + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-3.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-3.html new file mode 100644 index 0000000..cd502db --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-3.html @@ -0,0 +1,125 @@ + + + + + +P - + + + + + + + + +
+ + +
+ + + + +
+ + +
G J P S  + + +

P

+
+
Person1113 - Java1113.lesson01е
+
 
+
+G J P S 
+ +
+ + +
+ + + + +
+ + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-4.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-4.html new file mode 100644 index 0000000..9a37bfa --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-4.html @@ -0,0 +1,125 @@ + + + + + +S - + + + + + + + + +
+ + +
+ + + + +
+ + +
G J P S  + + +

S

+
+
shopping(Market1113, Product1113[]) - еķJava1113.lesson01.Person1113
+
 
+
+G J P S 
+ +
+ + +
+ + + + +
+ + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index.html new file mode 100644 index 0000000..ac2fafb --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index.html @@ -0,0 +1,72 @@ + + + + + +ɵĵ (ޱ) + + + + + + +<noscript> +<div>ѽ JavaScript</div> +</noscript> +<h2>Ԥ</h2> +<p>ʹÿܹܲ鿴ĵϢ, ʹõDzֿ֧ܵ Web ͻӵ<a href="Java1113/lesson01/package-summary.html">ǿܰ汾</a></p> + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/overview-tree.html b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/overview-tree.html new file mode 100644 index 0000000..7ac1086 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/overview-tree.html @@ -0,0 +1,133 @@ + + + + + +ֲṹ + + + + + + + + +
+ + +
+ + + + +
+ + +
+

гķֲṹ

+ֲṹ: + +
+
+

ֲṹ

+ +
+ +
+ + +
+ + + + +
+ + + + diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/package-list b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/package-list new file mode 100644 index 0000000..3236f15 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/package-list @@ -0,0 +1 @@ +Java1113.lesson01 diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/script.js b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/script.js new file mode 100644 index 0000000..b346356 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/stylesheet.css b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/stylesheet.css new file mode 100644 index 0000000..98055b2 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/Java1113/_01Lesson1113/src/Java1113/selection/SelectionWin1113.java b/Java1113/_01Lesson1113/src/Java1113/selection/SelectionWin1113.java new file mode 100644 index 0000000..7ad9169 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Java1113/selection/SelectionWin1113.java @@ -0,0 +1,54 @@ +package Java1113.selection; + +import javafx.application.Application; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Random; +public class SelectionWin1113 extends Application { + private Label selectedLabel; // 定义选中学生信息的标签 + + public void start(Stage primaryStage) { + VBox root = new VBox(10); // 创建一个垂直布局的根节点 + root.setAlignment(Pos.CENTER); // 设置根节点的对齐方式 + // 创建并设置标签 + Label label = new Label("212211113:陈永锐"); + root.getChildren().add(label); + // 创建按钮并设置事件处理 + Button btn = new Button("随机选人"); + btn.setOnAction(e -> { + String[] students = loadStudentList(); + if (students != null && students.length > 0) { + int index = new Random().nextInt(students.length); + selectedLabel.setText("恭喜 " + students[index] + " 被选中"); + } + }); + root.getChildren().add(btn); + // 创建选中学生信息的标签,并将其放置在按钮下方 + selectedLabel = new Label(); // 初始化选中学生信息的标签 + root.getChildren().add(selectedLabel); + Scene scene = new Scene(root, 300, 200); // 创建场景 + primaryStage.setTitle("随机选人"); // 设置舞台标题 + primaryStage.setScene(scene); // 设置舞台的场景 + primaryStage.show(); // 显示舞台 + } + private String[] loadStudentList() { + // 使用绝对路径 + String absolutePath = "C:/Java1113/Java1113/_01Lesson1113/src/Java1113/selection/data/StudentList.txt"; + try { + return Files.readAllLines(Paths.get(absolutePath)).toArray(new String[0]); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + public static void main(String[] args) { + launch(args); // 启动JavaFX应用程序 + } +} \ No newline at end of file diff --git a/Java1113/_01Lesson1113/src/Main.java b/Java1113/_01Lesson1113/src/Main.java new file mode 100644 index 0000000..1e87232 --- /dev/null +++ b/Java1113/_01Lesson1113/src/Main.java @@ -0,0 +1,17 @@ +// 按两次 Shift 打开“随处搜索”对话框并输入 `show whitespaces`, +// 然后按 Enter 键。现在,您可以在代码中看到空格字符。 +public class Main { + public static void main(String[] args) { + // 当文本光标位于高亮显示的文本处时按 Alt+Enter, + // 可查看 IntelliJ IDEA 对于如何修正该问题的建议。 + System.out.printf("Hello and welcome!"); + + // 按 Shift+F10 或点击装订区域中的绿色箭头按钮以运行脚本。 + for (int i = 1; i <= 5; i++) { + + // 按 Shift+F9 开始调试代码。我们已为您设置了一个断点, + // 但您始终可以通过按 Ctrl+F8 添加更多断点。 + System.out.println("i = " + i); + } + } +} \ No newline at end of file diff --git a/Java1113/_02Lesson1113/_02Lesson1113.iml b/Java1113/_02Lesson1113/_02Lesson1113.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Java1113/_02Lesson1113/_02Lesson1113.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Java1113/_02Lesson1113/src/Main.java b/Java1113/_02Lesson1113/src/Main.java new file mode 100644 index 0000000..1e87232 --- /dev/null +++ b/Java1113/_02Lesson1113/src/Main.java @@ -0,0 +1,17 @@ +// 按两次 Shift 打开“随处搜索”对话框并输入 `show whitespaces`, +// 然后按 Enter 键。现在,您可以在代码中看到空格字符。 +public class Main { + public static void main(String[] args) { + // 当文本光标位于高亮显示的文本处时按 Alt+Enter, + // 可查看 IntelliJ IDEA 对于如何修正该问题的建议。 + System.out.printf("Hello and welcome!"); + + // 按 Shift+F10 或点击装订区域中的绿色箭头按钮以运行脚本。 + for (int i = 1; i <= 5; i++) { + + // 按 Shift+F9 开始调试代码。我们已为您设置了一个断点, + // 但您始终可以通过按 Ctrl+F8 添加更多断点。 + System.out.println("i = " + i); + } + } +} \ No newline at end of file diff --git a/Java1113/_02Lesson1113/src/java1113.zip b/Java1113/_02Lesson1113/src/java1113.zip new file mode 100644 index 0000000..1775db4 Binary files /dev/null and b/Java1113/_02Lesson1113/src/java1113.zip differ diff --git a/Java1113/_02Lesson1113/src/java1113/java1113.zip b/Java1113/_02Lesson1113/src/java1113/java1113.zip new file mode 100644 index 0000000..5801e1a Binary files /dev/null and b/Java1113/_02Lesson1113/src/java1113/java1113.zip differ diff --git a/Java1113/_02Lesson1113/src/java1113/lesson02/StringSort1113.java b/Java1113/_02Lesson1113/src/java1113/lesson02/StringSort1113.java new file mode 100644 index 0000000..c64c0f4 --- /dev/null +++ b/Java1113/_02Lesson1113/src/java1113/lesson02/StringSort1113.java @@ -0,0 +1,87 @@ +package java1113.lesson02; + +import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.Border; +import javafx.scene.layout.BorderStroke; +import javafx.scene.layout.BorderStrokeStyle; +import javafx.scene.layout.BorderWidths; +import javafx.scene.layout.CornerRadii; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Paint; +import javafx.stage.Stage; +import java.util.Arrays; +import java.util.stream.Collectors; + +public class StringSort1113 extends Application { + public static void main(String[] args) { + launch(args); + } + public void start(Stage primaryStage) { + // 设置舞台的标题 + primaryStage.setTitle("排序数字字符串"); + // 调用getRoot方法创建根节点 + Parent root = getRoot(); + // 用根节点创建Scene,并增加宽度和高度 + Scene scene = new Scene(root, 500.0, 350.0); // 修改尺寸参数为double类型 + // 为Stage指定Scene + primaryStage.setScene(scene); + // 显示Stage + primaryStage.show(); + } + // 创建根节点的方法 + private Parent getRoot() { + Label lblStudent = new Label("212211113 陈永锐"); + // 边框【注意】多行代码的书写规范 + BorderStroke bs = new BorderStroke(Paint.valueOf("#8FBC8F"), // 边框的颜色 + BorderStrokeStyle.DOTTED, // 边框的样式 + new CornerRadii(10), // 边框四个角的圆角 + new BorderWidths(3)); // 边框的宽度 + lblStudent.setBorder(new Border(bs)); // 设置边框 + lblStudent.setPadding(new Insets(10)); // 设置边距 + // 水平排列的两个控件,用于输入 + HBox hText = new HBox(10); + Label lblText = new Label("输入数字串:"); + TextField tfText = new TextField(); + tfText.setPromptText("用空格分隔的数字串"); // 文本无内容时显示的提示信息 + hText.getChildren().addAll(lblText, tfText); + hText.setAlignment(Pos.CENTER_LEFT); // 两个控件的对齐方式 + Button button = new Button("排序"); + Label lblPrint = new Label(""); // 显示排序结果 + // 垂直排列的根节点 + VBox root = new VBox(20); // 节点之间的垂直间距20 + // 为根节点添加子节点 + root.getChildren().addAll(lblStudent, hText, button, lblPrint); + root.setPadding(new Insets(20.0)); // 设置根节点的边距 + root.setAlignment(Pos.TOP_CENTER); // 根节点中各节点的对齐方式 + root.setStyle("-fx-font-size: 20;"); // 用CSS样式设置容器中所有节点的字体大小 + // 添加按钮的事件处理程序 + button.setOnAction(e -> { + String input = tfText.getText(); + String sortedNumbers = sortNumbers(input); + lblPrint.setText("排序结果:"+sortedNumbers); + }); + return root; + } + // 排序数字字符串的方法 + private String sortNumbers(String input) { + return Arrays.stream(input.split("\\s+")) // 允许任意空白字符作为分隔符 + .map(Integer::parseInt) + .sorted() + .map(String::valueOf) + .collect(Collectors.joining(" ")); + } +} + + + + + + diff --git a/Java1113/_02Lesson1113/src/java1113/lesson02/Word1113.java b/Java1113/_02Lesson1113/src/java1113/lesson02/Word1113.java new file mode 100644 index 0000000..1a7567f --- /dev/null +++ b/Java1113/_02Lesson1113/src/java1113/lesson02/Word1113.java @@ -0,0 +1,80 @@ +package java1113.lesson02; + +import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.Border; +import javafx.scene.layout.BorderStroke; +import javafx.scene.layout.BorderStrokeStyle; +import javafx.scene.layout.CornerRadii; +import javafx.scene.layout.BorderWidths; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Paint; +import javafx.stage.Stage; +import java.util.Arrays; +import java.util.stream.Collectors; + +public class Word1113 extends Application { + public static void main(String[] args) { + launch(args); + } + public void start(Stage primaryStage) { + // 设置舞台的标题 + primaryStage.setTitle("提取三个字符的单词"); + // 调用getRoot方法创建根节点 + Parent root = getRoot(); + // 用根节点创建Scene,并增加宽度和高度 + Scene scene = new Scene(root, 450, 350); + // 为Stage指定Scene + primaryStage.setScene(scene); + // 显示Stage + primaryStage.show(); + } + // 创建根节点的方法 + private Parent getRoot() { + Label infoLabel = new Label("212211113 陈永锐"); + // 边框【注意】多行代码的书写规范 + BorderStroke bs = new BorderStroke(Paint.valueOf("#8FBC8F"), // 边框的颜色 + BorderStrokeStyle.DOTTED, // 边框的样式 + new CornerRadii(10), // 边框四个角的圆角 + new BorderWidths(3)); // 边框的宽度 + infoLabel.setBorder(new Border(bs)); // 设置边框 + infoLabel.setPadding(new Insets(10)); // 设置边距 + // 水平排列的两个控件,用于输入 + HBox inputBox = new HBox(10); + Label inputLabel = new Label("输入单词:"); + TextField inputField = new TextField(); + inputField.setPromptText("输入单词"); // 文本无内容时显示的提示信息 + inputBox.getChildren().addAll(inputLabel, inputField); + inputBox.setAlignment(Pos.CENTER_LEFT); // 两个控件的对齐方式 + Button extractButton = new Button("提取单词"); + Label resultLabel = new Label(); // 显示提取结果 + // 垂直排列的根节点 + VBox root = new VBox(20); // 节点之间的垂直间距20 + // 为根节点添加子节点 + root.getChildren().addAll(infoLabel, inputBox, extractButton, resultLabel); + root.setPadding(new Insets(20.0)); // 设置根节点的边距 + root.setAlignment(Pos.TOP_CENTER); // 根节点中各节点的对齐方式 + root.setStyle("-fx-font-size:20"); // 用CSS样式设置容器中所有节点的字体大小 + // 添加按钮的事件处理程序 + extractButton.setOnAction(e -> { + String input = inputField.getText(); + String extractedWords = extractWords(input); + resultLabel.setText(extractedWords); + }); + return root; + } + // 提取三个字符的单词的方法 + String extractWords(String input) { + return Arrays.stream(input.split("[ ,]+")) // 允许空格和逗号作为分隔符 + .filter(word -> word.length() == 3) + .collect(Collectors.joining(" ")); // 将过滤后的单词用空格连接 + } +} + diff --git a/Java1113/_02Lesson1113/src/java1113/lesson02/regex/CheckRegex1113.java b/Java1113/_02Lesson1113/src/java1113/lesson02/regex/CheckRegex1113.java new file mode 100644 index 0000000..8730834 --- /dev/null +++ b/Java1113/_02Lesson1113/src/java1113/lesson02/regex/CheckRegex1113.java @@ -0,0 +1,86 @@ +package java1113.lesson02.regex; + +import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Paint; +import javafx.stage.Stage; +import javafx.scene.layout.Border; +import javafx.scene.layout.BorderStroke; +import javafx.scene.layout.BorderStrokeStyle; +import javafx.scene.layout.BorderWidths; +import javafx.scene.layout.CornerRadii; +import javafx.geometry.Pos; // 导入用于对齐的Pos类 +import java.util.regex.Pattern; + +public class CheckRegex1113 extends Application { + private ListView resultList; // 将 resultList 定义为类的成员变量 + public void start(Stage primaryStage) { + VBox inputBox = getRoot(); // 获取输入区域的布局 + this.resultList = getListView(); // 初始化结果列表 + HBox mainLayout = new HBox(10); // 创建一个水平布局,用于放置输入区域和结果列表 + mainLayout.setPadding(new Insets(10)); // 设置布局的内边距 + mainLayout.setSpacing(10); // 设置布局中组件之间的间距 + mainLayout.getChildren().addAll(inputBox, resultList); // 将输入区域和结果列表添加到水平布局中 + Scene scene = new Scene(mainLayout, 775, 455); // 创建场景,并设置场景的尺寸 + primaryStage.setTitle("正则表达式验证器"); // 设置舞台的标题 + primaryStage.setScene(scene); // 将场景设置到舞台上 + primaryStage.show(); // 显示舞台 + } + private VBox getRoot() { + VBox inputBox = new VBox(10); // 创建一个垂直布局,用于放置输入相关的组件 + inputBox.setPadding(new Insets(10)); // 设置布局的内边距 + inputBox.setSpacing(5); // 设置布局中组件之间的间距 + Label studentInfo = new Label("212211113 陈永锐"); + styleLabel(studentInfo); // 为标签设置样式 + studentInfo.setAlignment(Pos.CENTER); // 设置标签在水平方向上居中 + HBox hboxForStudentInfo = new HBox(10); // 创建一个水平布局,用于放置学生信息标签 + hboxForStudentInfo.setAlignment(Pos.CENTER); // 设置水平布局在水平方向上居中 + hboxForStudentInfo.getChildren().add(studentInfo); + HBox regexHBox = new HBox(10); // 创建一个水平布局,用于放置正则表达式标签和输入框 + regexHBox.setAlignment(Pos.CENTER_LEFT); // 设置水平布局中组件的对齐方式 + Label regexLabel = new Label("正则表达式:"); + TextField regexField = new TextField(); // 创建一个文本输入框,用于输入正则表达式 + regexField.setPromptText("请输入正则表达式"); + regexField.setPrefColumnCount(20); // 设置输入框的列数 + regexHBox.getChildren().addAll(regexLabel, regexField); // 将标签和输入框添加到水平布局中 + Label inputLabel = new Label("输入要检验的一组字符串(用逗号分隔):"); + inputLabel.setAlignment(Pos.CENTER); // 设置标签在水平方向上居中 + HBox inputHBox = new HBox(10); // 创建一个水平布局,用于放置输入标签 + inputHBox.setAlignment(Pos.CENTER); + inputHBox.getChildren().add(inputLabel); // 将标签添加到水平布局中 + TextArea inputArea = new TextArea(); // 创建一个文本区域,用于输入要验证的字符串 + inputArea.setPromptText("例如: 2018-10,2018-05,2018-5"); + inputArea.setPrefColumnCount(20); // 设置文本区域的列数 + Button checkButton = new Button("验证字符串是否属于正则表达式"); // 创建一个按钮,用于触发验证操作 + checkButton.setOnAction(e -> validateRegex(regexField.getText(), inputArea.getText())); // 为按钮设置事件处理器 + HBox buttonHBox = new HBox(checkButton); // 创建一个水平布局,用于放置按钮 + buttonHBox.setAlignment(Pos.CENTER); // 设置水平布局中组件的对齐方式 + inputBox.getChildren().addAll(hboxForStudentInfo, regexHBox, inputHBox, inputArea, buttonHBox); // 将所有组件添加到垂直布局中 + return inputBox; // 返回输入区域的布局 + } + private ListView getListView() { + ListView resultList = new ListView<>(); // 创建一个ListView,用于显示验证结果 + return resultList; // 返回ListView + } + private void styleLabel(Label label) { + BorderStroke bs = new BorderStroke(Paint.valueOf("#8FBC8F"), BorderStrokeStyle.DOTTED, new CornerRadii(10), new BorderWidths(3)); // 创建一个边框样式 + label.setBorder(new Border(bs)); // 为标签设置边框 + label.setPadding(new Insets(10)); // 为标签设置内边距 + } + private void validateRegex(String regex, String input) { + resultList.getItems().clear(); // 清空之前的验证结果 + String[] inputs = input.split(","); // 将输入的字符串按逗号分隔 + for (String str : inputs) { + str = str.trim(); // 去除字符串两端的空白 + boolean matches = Pattern.matches(regex, str); // 验证字符串是否符合正则表达式 + resultList.getItems().add(str + (matches ? ":true" : ":false")); // 将验证结果添加到ListView中 + } + } + public static void main(String[] args) { + launch(args); // 启动JavaFX应用程序 + } +} \ No newline at end of file diff --git a/Java1113/_03Lesson1113/_03Lesson1113.iml b/Java1113/_03Lesson1113/_03Lesson1113.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Java1113/_03Lesson1113/_03Lesson1113.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Java1113/_03Lesson1113/src/Main.java b/Java1113/_03Lesson1113/src/Main.java new file mode 100644 index 0000000..1e87232 --- /dev/null +++ b/Java1113/_03Lesson1113/src/Main.java @@ -0,0 +1,17 @@ +// 按两次 Shift 打开“随处搜索”对话框并输入 `show whitespaces`, +// 然后按 Enter 键。现在,您可以在代码中看到空格字符。 +public class Main { + public static void main(String[] args) { + // 当文本光标位于高亮显示的文本处时按 Alt+Enter, + // 可查看 IntelliJ IDEA 对于如何修正该问题的建议。 + System.out.printf("Hello and welcome!"); + + // 按 Shift+F10 或点击装订区域中的绿色箭头按钮以运行脚本。 + for (int i = 1; i <= 5; i++) { + + // 按 Shift+F9 开始调试代码。我们已为您设置了一个断点, + // 但您始终可以通过按 Ctrl+F8 添加更多断点。 + System.out.println("i = " + i); + } + } +} \ No newline at end of file diff --git a/Java1113/_03Lesson1113/src/java1113.zip b/Java1113/_03Lesson1113/src/java1113.zip new file mode 100644 index 0000000..8e06df5 Binary files /dev/null and b/Java1113/_03Lesson1113/src/java1113.zip differ diff --git a/Java1113/_03Lesson1113/src/java1113/lesson03/EndDate1113.java b/Java1113/_03Lesson1113/src/java1113/lesson03/EndDate1113.java new file mode 100644 index 0000000..716952b --- /dev/null +++ b/Java1113/_03Lesson1113/src/java1113/lesson03/EndDate1113.java @@ -0,0 +1,88 @@ +package java1113.lesson03; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.time.DayOfWeek; +import java.time.YearMonth; +import java.util.Scanner; + +public class EndDate1113 { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + // 输入提示 + System.out.print("请按yyyy-MM-dd的格式输入开班日期: "); + String startDate = scanner.nextLine(); // 获取输入的开班日期 + String endDate = calc1113(startDate); // 调用calcXXXX方法计算结业日期 + + if (endDate != null) { + System.out.println("培训15天,结业日期: " + endDate); // 输出结业日期 + } else { + System.out.println("null"); // 如果日期不合法,输出null + } + } + public static String calc1113(String startDate) { + // 去除输入字符串的多余空格 + startDate = startDate.trim().replace(" ", ""); + // 判断输入是否为空或全是空格 + if (startDate.isEmpty()) { + return null; + } + // 校验日期格式(年份四位、月份两位、日期两位) + if (!startDate.matches("\\d{4}-\\d{2}-\\d{2}")) { + return null; + } + // 尝试解析日期,避免无效日期 + try { + // 提取输入的年月日 + String[] parts = startDate.split("-"); + int inputYear = Integer.parseInt(parts[0]); + int inputMonth = Integer.parseInt(parts[1]); + int inputDay = Integer.parseInt(parts[2]); + // 手动校验月份范围是否在1到12之间 + if (inputMonth < 1 || inputMonth > 12) { + return null; // 非法月份 + } + // 校验月份和日期 + YearMonth yearMonth = YearMonth.of(inputYear, inputMonth); + if (inputDay < 1 || inputDay > yearMonth.lengthOfMonth()) { + return null; // 如果天数超过该月份的最大天数,返回null + } + // 解析为LocalDate + LocalDate parsedDate = LocalDate.of(inputYear, inputMonth, inputDay); + // 计算结业日期(15天后) + LocalDate endLocalDate = parsedDate.plusDays(15); + // 按指定格式输出结业日期,包括"年-月-日"格式及星期几 + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy年M月d日"); + String formattedDate = endLocalDate.format(outputFormatter); + // 获取结业日期的星期几 + DayOfWeek dayOfWeek = endLocalDate.getDayOfWeek(); + String dayInChinese = getDayInChinese(dayOfWeek); + return formattedDate + " " + dayInChinese; + } catch (Exception e) { + // 处理任何潜在的异常 + return null; + } + } + // 将DayOfWeek转换为中文星期几 + public static String getDayInChinese(DayOfWeek dayOfWeek) { + switch (dayOfWeek) { + case MONDAY: + return "星期一"; + case TUESDAY: + return "星期二"; + case WEDNESDAY: + return "星期三"; + case THURSDAY: + return "星期四"; + case FRIDAY: + return "星期五"; + case SATURDAY: + return "星期六"; + case SUNDAY: + return "星期日"; + default: + return ""; + } + } +} diff --git a/Java1113/_03Lesson1113/src/java1113/lesson03/LastDay1113.java b/Java1113/_03Lesson1113/src/java1113/lesson03/LastDay1113.java new file mode 100644 index 0000000..9cbdfff --- /dev/null +++ b/Java1113/_03Lesson1113/src/java1113/lesson03/LastDay1113.java @@ -0,0 +1,49 @@ +package java1113.lesson03; + +import java.time.YearMonth; +import java.util.Scanner; +public class LastDay1113 { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + // 输入提示 + System.out.println("计算某月的最后一天"); + System.out.print("请按yyyy-MM的格式输入年月: "); + String input = scanner.nextLine().trim(); // 获取输入的年月并去除头尾空格 + String lastDay = getLastDay1113(input); // 调用getLastDayXXXX方法计算该月最后一天 + if (lastDay != null) { + System.out.println("本月最后一天是" + lastDay + "日"); + } else { + System.out.println("格式错误"); + } + } + public static String getLastDay1113(String input) { + // 去除输入字符串的多余空格 + input = input.replace(" ", ""); + // 判断输入是否为空或全是空格 + if (input.isEmpty()) { + return null; + } + // 校验输入格式(年份四位,月份一位或两位) + if (!input.matches("\\d{4}(-\\d{1,2})?")) { + return null; + } + // 尝试解析年月,避免无效日期 + try { + // 提取输入的年和月 + String[] parts = input.split("-"); + int year = Integer.parseInt(parts[0]); + int month = (parts.length > 1) ? Integer.parseInt(parts[1]) : 1; // 如果月份未指定,默认为1月 + // 校验月份范围是否在1到12之间 + if (month < 1 || month > 12) { + return null; // 非法月份 + } + // 根据年月获取该月最后一天 + YearMonth yearMonth = YearMonth.of(year, month); + int lastDay = yearMonth.lengthOfMonth(); + return String.valueOf(lastDay); // 直接返回最后一天的数字 + } catch (Exception e) { + // 处理任何潜在的异常 + return null; + } + } +} \ No newline at end of file diff --git a/Java1113/_03Lesson1113/src/java1113/newdate/MotherDays1113.java b/Java1113/_03Lesson1113/src/java1113/newdate/MotherDays1113.java new file mode 100644 index 0000000..fc06bb9 --- /dev/null +++ b/Java1113/_03Lesson1113/src/java1113/newdate/MotherDays1113.java @@ -0,0 +1,4 @@ +package java1113.newdate; + +public class MotherDays1113 { +} diff --git a/Java1113/_03Lesson1113/src/java1113/newdate/MothersDay1113Controller.java b/Java1113/_03Lesson1113/src/java1113/newdate/MothersDay1113Controller.java new file mode 100644 index 0000000..5af44d7 --- /dev/null +++ b/Java1113/_03Lesson1113/src/java1113/newdate/MothersDay1113Controller.java @@ -0,0 +1,8 @@ +package java1113.newdate; + +import javafx.scene.input.MouseEvent; + +public class MothersDay1113Controller { + public void buttonClick(MouseEvent mouseEvent) { + } +} diff --git a/Java1113/_03Lesson1113/src/java1113/newdate/MothersDay1113View.fxml b/Java1113/_03Lesson1113/src/java1113/newdate/MothersDay1113View.fxml new file mode 100644 index 0000000..2f7fe9d --- /dev/null +++ b/Java1113/_03Lesson1113/src/java1113/newdate/MothersDay1113View.fxml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + +