diff --git a/USB_homework/src/Computer.java b/USB_homework/src/Computer.java new file mode 100644 index 0000000..299d933 --- /dev/null +++ b/USB_homework/src/Computer.java @@ -0,0 +1,4 @@ +package PACKAGE_NAME; + +public class Computer { +} diff --git a/USB_homework/src/Keyboard.java b/USB_homework/src/Keyboard.java new file mode 100644 index 0000000..e802093 --- /dev/null +++ b/USB_homework/src/Keyboard.java @@ -0,0 +1,4 @@ +package PACKAGE_NAME; + +public class Keyboard { +} diff --git a/USB_homework/src/Main.java b/USB_homework/src/Main.java new file mode 100644 index 0000000..1e936b3 --- /dev/null +++ b/USB_homework/src/Main.java @@ -0,0 +1,4 @@ +package PACKAGE_NAME; + +public class Main { +} diff --git a/USB_homework/src/Mouse.java b/USB_homework/src/Mouse.java new file mode 100644 index 0000000..5da7c28 --- /dev/null +++ b/USB_homework/src/Mouse.java @@ -0,0 +1,4 @@ +package PACKAGE_NAME; + +public class Mouse { +} diff --git a/USB_homework/src/USB.java b/USB_homework/src/USB.java new file mode 100644 index 0000000..583c1fd --- /dev/null +++ b/USB_homework/src/USB.java @@ -0,0 +1,4 @@ +package PACKAGE_NAME; + +public interface USB { +} diff --git a/w5/AI使用记录.docx b/w5/AI使用记录.docx new file mode 100644 index 0000000..d0b8154 Binary files /dev/null and b/w5/AI使用记录.docx differ diff --git a/w5/USB_homework/.gitignore b/w5/USB_homework/.gitignore new file mode 100644 index 0000000..13275f1 --- /dev/null +++ b/w5/USB_homework/.gitignore @@ -0,0 +1,30 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ +.kotlin + +### 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/w5/USB_homework/.idea/.gitignore b/w5/USB_homework/.idea/.gitignore new file mode 100644 index 0000000..b6b1ecf --- /dev/null +++ b/w5/USB_homework/.idea/.gitignore @@ -0,0 +1,10 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 已忽略包含查询文件的默认文件夹 +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ diff --git a/w5/USB_homework/.idea/misc.xml b/w5/USB_homework/.idea/misc.xml new file mode 100644 index 0000000..6f29fee --- /dev/null +++ b/w5/USB_homework/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/w5/USB_homework/.idea/modules.xml b/w5/USB_homework/.idea/modules.xml new file mode 100644 index 0000000..346b867 --- /dev/null +++ b/w5/USB_homework/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/w5/USB_homework/.idea/vcs.xml b/w5/USB_homework/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/w5/USB_homework/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/w5/USB_homework/USB_homework.iml b/w5/USB_homework/USB_homework.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/w5/USB_homework/USB_homework.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/w5/USB_homework/USB实验截图.png b/w5/USB_homework/USB实验截图.png new file mode 100644 index 0000000..82ff5d6 Binary files /dev/null and b/w5/USB_homework/USB实验截图.png differ diff --git a/w5/USB_homework/src/Computer.java b/w5/USB_homework/src/Computer.java new file mode 100644 index 0000000..341abfb --- /dev/null +++ b/w5/USB_homework/src/Computer.java @@ -0,0 +1,16 @@ +public class Computer { + // 核心方法:插入 USB 设备 + public void useUSB(USB usb) { + // 1. 打开设备 + usb.open(); + + // 2. 模拟使用过程 + System.out.println("电脑正在使用这个 USB 设备..."); + + // 3. 关闭设备 + usb.close(); + + // 换行隔开,看着更清楚 + System.out.println("---------------------"); + } +} \ No newline at end of file diff --git a/w5/USB_homework/src/Keyboard.java b/w5/USB_homework/src/Keyboard.java new file mode 100644 index 0000000..e1fd0a9 --- /dev/null +++ b/w5/USB_homework/src/Keyboard.java @@ -0,0 +1,11 @@ +public class Keyboard implements USB { + @Override + public void open() { + System.out.println("键盘已连接,准备输入"); + } + + @Override + public void close() { + System.out.println("键盘已断开连接,停止输入"); + } +} \ No newline at end of file diff --git a/w5/USB_homework/src/Main.java b/w5/USB_homework/src/Main.java new file mode 100644 index 0000000..8b935c7 --- /dev/null +++ b/w5/USB_homework/src/Main.java @@ -0,0 +1,18 @@ +public class Main { + public static void main(String[] args) { + // 1. 建造一台电脑 + Computer computer = new Computer(); + + // 2. 拿出一个鼠标(USB设备) + USB mouse = new Mouse(); + + // 3. 把鼠标插进电脑 + computer.useUSB(mouse); + + // 4. 拿出一个键盘(USB设备) + USB keyboard = new Keyboard(); + + // 5. 把键盘插进电脑 + computer.useUSB(keyboard); + } +} diff --git a/w5/USB_homework/src/Mouse.java b/w5/USB_homework/src/Mouse.java new file mode 100644 index 0000000..0a05d82 --- /dev/null +++ b/w5/USB_homework/src/Mouse.java @@ -0,0 +1,11 @@ +public class Mouse implements USB { + @Override + public void open() { + System.out.println("鼠标已连接,准备工作"); + } + + @Override + public void close() { + System.out.println("鼠标已断开连接,收起工作"); + } +} \ No newline at end of file diff --git a/w5/USB_homework/src/USB.java b/w5/USB_homework/src/USB.java new file mode 100644 index 0000000..02f5fd4 --- /dev/null +++ b/w5/USB_homework/src/USB.java @@ -0,0 +1,7 @@ +public interface USB { + // 打开设备 + void open(); + + // 关闭设备 + void close(); +} \ No newline at end of file diff --git a/w5/shape_homework/.gitignore b/w5/shape_homework/.gitignore new file mode 100644 index 0000000..13275f1 --- /dev/null +++ b/w5/shape_homework/.gitignore @@ -0,0 +1,30 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ +.kotlin + +### 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/w5/shape_homework/.idea/.gitignore b/w5/shape_homework/.idea/.gitignore new file mode 100644 index 0000000..b6b1ecf --- /dev/null +++ b/w5/shape_homework/.idea/.gitignore @@ -0,0 +1,10 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 已忽略包含查询文件的默认文件夹 +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ diff --git a/w5/shape_homework/.idea/misc.xml b/w5/shape_homework/.idea/misc.xml new file mode 100644 index 0000000..6f29fee --- /dev/null +++ b/w5/shape_homework/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/w5/shape_homework/.idea/modules.xml b/w5/shape_homework/.idea/modules.xml new file mode 100644 index 0000000..40de91c --- /dev/null +++ b/w5/shape_homework/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/w5/shape_homework/.idea/vcs.xml b/w5/shape_homework/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/w5/shape_homework/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/w5/shape_homework/shape_homework.iml b/w5/shape_homework/shape_homework.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/w5/shape_homework/shape_homework.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/w5/shape_homework/src/Circle.java b/w5/shape_homework/src/Circle.java new file mode 100644 index 0000000..06dd727 --- /dev/null +++ b/w5/shape_homework/src/Circle.java @@ -0,0 +1,6 @@ +public class Circle extends Shape { + @Override + public void draw() { + System.out.println("绘制圆形"); + } +} diff --git a/w5/shape_homework/src/Main.java b/w5/shape_homework/src/Main.java new file mode 100644 index 0000000..0dbfb07 --- /dev/null +++ b/w5/shape_homework/src/Main.java @@ -0,0 +1,12 @@ +public class Main { + public static void main(String[] args) { + ShapeDrawer drawer = new ShapeDrawer(); + + Shape s1 = new Circle(); + Shape s2 = new Rectangle(); + + // 调用正确的方法名 + drawer.drawShape(s1); + drawer.drawShape(s2); + } +} \ No newline at end of file diff --git a/w5/shape_homework/src/Rectangle.java b/w5/shape_homework/src/Rectangle.java new file mode 100644 index 0000000..9d0e9ee --- /dev/null +++ b/w5/shape_homework/src/Rectangle.java @@ -0,0 +1,6 @@ +public class Rectangle extends Shape { + @Override + public void draw() { + System.out.println("绘制矩形"); + } +} diff --git a/w5/shape_homework/src/Shape.java b/w5/shape_homework/src/Shape.java new file mode 100644 index 0000000..18bcb4e --- /dev/null +++ b/w5/shape_homework/src/Shape.java @@ -0,0 +1,3 @@ +public abstract class Shape { + public abstract void draw(); +} diff --git a/w5/shape_homework/src/ShapeDrawer.java b/w5/shape_homework/src/ShapeDrawer.java new file mode 100644 index 0000000..4fe44cc --- /dev/null +++ b/w5/shape_homework/src/ShapeDrawer.java @@ -0,0 +1,6 @@ +public class ShapeDrawer { + // 作业要求的方法名:drawShape + public void drawShape(Shape s) { + s.draw(); + } +} \ No newline at end of file diff --git a/w5/shape_homework/屏幕截图 2026-03-31 110300.png b/w5/shape_homework/屏幕截图 2026-03-31 110300.png new file mode 100644 index 0000000..49874da Binary files /dev/null and b/w5/shape_homework/屏幕截图 2026-03-31 110300.png differ