Browse Source

添加w4作业文件夹

main
jingjiaying 3 weeks ago
parent
commit
c741169725
  1. 30
      w4/.gitignore
  2. 10
      w4/.idea/.gitignore
  3. 6
      w4/.idea/misc.xml
  4. 8
      w4/.idea/modules.xml
  5. 6
      w4/.idea/vcs.xml
  6. 11
      w4/W4.iml
  7. 12
      w4/src/Circle.java
  8. 11
      w4/src/Main.java
  9. 14
      w4/src/Rectangle.java
  10. 3
      w4/src/Shape.java
  11. 7
      w4/src/ShapeUtil.java
  12. 14
      w4/src/Triangle.java
  13. BIN
      w4/反思.doc
  14. BIN
      w4/实验报告.docx
  15. BIN
      w4/实验结果.png
  16. BIN
      w4/类图.png

30
w4/.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

10
w4/.idea/.gitignore

@ -0,0 +1,10 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 已忽略包含查询文件的默认文件夹
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/

6
w4/.idea/misc.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
w4/.idea/modules.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/W4.iml" filepath="$PROJECT_DIR$/W4.iml" />
</modules>
</component>
</project>

6
w4/.idea/vcs.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

11
w4/W4.iml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

12
w4/src/Circle.java

@ -0,0 +1,12 @@
public class Circle extends Shape {
private double radius;
public Circle(double radius) {
this.radius = radius;
}
@Override
public double getArea() {
return Math.PI * radius * radius;
}
}

11
w4/src/Main.java

@ -0,0 +1,11 @@
public class Main {
public static void main(String[] args) {
Shape circle = new Circle(2);
Shape rectangle = new Rectangle(3, 4);
Shape triangle = new Triangle(3, 4);
ShapeUtil.printArea(circle);
ShapeUtil.printArea(rectangle);
ShapeUtil.printArea(triangle);
}
}

14
w4/src/Rectangle.java

@ -0,0 +1,14 @@
public class Rectangle extends Shape {
private double width;
private double height;
public Rectangle(double width, double height) {
this.width = width;
this.height = height;
}
@Override
public double getArea() {
return width * height;
}
}

3
w4/src/Shape.java

@ -0,0 +1,3 @@
public abstract class Shape {
public abstract double getArea();
}

7
w4/src/ShapeUtil.java

@ -0,0 +1,7 @@
public class ShapeUtil {
public static void printArea(Shape shape) {
if (shape != null) {
System.out.println("面积:" + shape.getArea());
}
}
}

14
w4/src/Triangle.java

@ -0,0 +1,14 @@
public class Triangle extends Shape {
private double base;
private double height;
public Triangle(double base, double height) {
this.base = base;
this.height = height;
}
@Override
public double getArea() {
return 0.5 * base * height;
}
}

BIN
w4/反思.doc

Binary file not shown.

BIN
w4/实验报告.docx

Binary file not shown.

BIN
w4/实验结果.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

BIN
w4/类图.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Loading…
Cancel
Save