From 4e3c5635aaf90019751e83433353ed9de427324e Mon Sep 17 00:00:00 2001
From: LQS <2506203757@qq.com>
Date: Thu, 8 Aug 2024 08:59:27 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 38 ++++++++++
.idea/.gitignore | 8 +++
.idea/encodings.xml | 7 ++
.idea/misc.xml | 14 ++++
.idea/vcs.xml | 6 ++
pom.xml | 17 +++++
src/main/java/com/muyu/pojo/Student.java | 74 ++++++++++++++++++++
src/main/java/com/muyu/test/StudentTest.java | 41 +++++++++++
8 files changed, 205 insertions(+)
create mode 100644 .gitignore
create mode 100644 .idea/.gitignore
create mode 100644 .idea/encodings.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/vcs.xml
create mode 100644 pom.xml
create mode 100644 src/main/java/com/muyu/pojo/Student.java
create mode 100644 src/main/java/com/muyu/test/StudentTest.java
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..132404b
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..3204d80
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,17 @@
+
+
+ 4.0.0
+
+ com.icecream
+ zgl-rikao-day19-8-8
+ 1.0-SNAPSHOT
+
+
+ 8
+ 8
+ UTF-8
+
+
+
diff --git a/src/main/java/com/muyu/pojo/Student.java b/src/main/java/com/muyu/pojo/Student.java
new file mode 100644
index 0000000..b01d991
--- /dev/null
+++ b/src/main/java/com/muyu/pojo/Student.java
@@ -0,0 +1,74 @@
+package com.muyu.pojo;
+
+
+
+
+public class Student {
+ /**
+ * 编号
+ */
+ private int id;
+ /**
+ * 姓名
+ */
+ private String name;
+ /**
+ * 科目
+ */
+ private String subject;
+ /**
+ * 分数
+ */
+ private int score;
+
+ @Override
+ public String toString() {
+ return
+ "编号:" + id +
+ "姓名:" + name +
+ "科目:" + subject +
+ "分数" + score ;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getSubject() {
+ return subject;
+ }
+
+ public void setSubject(String subject) {
+ this.subject = subject;
+ }
+
+ public int getScore() {
+ return score;
+ }
+
+ public void setScore(int score) {
+ this.score = score;
+ }
+
+ public Student() {
+ }
+
+ public Student(int id, String name, String subject, int score) {
+ this.id = id;
+ this.name = name;
+ this.subject = subject;
+ this.score = score;
+ }
+}
diff --git a/src/main/java/com/muyu/test/StudentTest.java b/src/main/java/com/muyu/test/StudentTest.java
new file mode 100644
index 0000000..f05f820
--- /dev/null
+++ b/src/main/java/com/muyu/test/StudentTest.java
@@ -0,0 +1,41 @@
+package com.muyu.test;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class StudentTest {
+ public static void main(String[] args) {
+ List studentInfoStrings = new ArrayList<>();
+ //创建并添加学生信息到集合
+ studentInfoStrings.add("1,张三,语文,100");
+ studentInfoStrings.add("1,张三,数学,90");
+ studentInfoStrings.add("2,李四,语文,95");
+ studentInfoStrings.add("2,李四,数学,92");
+ studentInfoStrings.add("3,王五,语文,88");
+ studentInfoStrings.add("3,王五,数学,82");
+
+ // 打印集合
+ studentInfoStrings.forEach(System.out::println);
+
+ System.out.println("----------------------添加数据之后-----------------------");
+
+ Map averageScores = studentInfoStrings.stream()
+ .map(s -> s.split(","))
+ .collect(Collectors.groupingBy(
+ arr -> arr[1], // 假设arr[1]是名字
+ Collectors.mapping(
+ arr -> Integer.parseInt(arr[3]), // 假设arr[3]是分数
+ Collectors.averagingInt(i -> i)
+ )
+ ));
+
+ // 输出平均成绩结果
+ averageScores.forEach((name, avgScore) -> System.out.println(name + "的平均成绩是: " + avgScore));
+
+ }
+
+
+}