Initial commit

This commit is contained in:
2025-11-06 10:29:13 +08:00
commit 0becd14830
318 changed files with 7145 additions and 0 deletions

29
Experiment/.gitignore vendored Normal file
View File

@@ -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

10
Experiment/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,10 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# 依赖于环境的 Maven 主目录路径
/mavenHomeManager.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

5
Experiment/.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,5 @@
<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
Experiment/.idea/modules.xml generated Normal file
View File

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

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="AbFather.Main" type="Application" factoryName="Application" folderName="Exp4">
<option name="MAIN_CLASS_NAME" value="Exp4.Task3.Main" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ArithmaticOp" type="Application" factoryName="Application" folderName="Exp1">
<option name="MAIN_CLASS_NAME" value="Exp1.Task4.ArithmaticOp" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ArrayRefer" type="Application" factoryName="Application" folderName="Exp1">
<option name="MAIN_CLASS_NAME" value="Exp1.Task5.ArrayRefer" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="BackAnimal" type="Application" factoryName="Application" folderName="Exp4" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp4.Task1.BackAnimal" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Ball.Class1" type="Application" factoryName="Application" folderName="Extra">
<option name="MAIN_CLASS_NAME" value="Extra.Ball.Class1" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="CircleCalc" type="Application" factoryName="Application" folderName="Exp1">
<option name="MAIN_CLASS_NAME" value="Exp1.Task6.CircleCalc" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="CircleTest" type="Application" factoryName="Application" folderName="Exp3" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp3.Task2.CircleTest" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="CircularFactorial" type="Application" factoryName="Application" folderName="Exp2">
<option name="MAIN_CLASS_NAME" value="Exp2.Task3.CircularFactorial" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="CollectionStringProcessing" type="Application" factoryName="Application" folderName="Exp5" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp5.Task3.CollectionStringProcessing" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="DivideByZero" type="Application" factoryName="Application" folderName="Exp6" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp6.Task1.DivideByZero" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="FibonacciSeq" type="Application" factoryName="Application" folderName="Exp7" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp7.Task2.FibonacciSeq" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="FibonacciSum" type="Application" factoryName="Application" folderName="Exp7" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp7.Task3.FibonacciSum" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="FileContentCopy" type="Application" factoryName="Application" folderName="Exp7" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp7.Task1.FileContentCopy" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Graphic.Test" type="Application" factoryName="Application" folderName="Exp4">
<option name="MAIN_CLASS_NAME" value="Exp4.Task5.Test" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="GuessNumber.Start" type="Application" factoryName="Application" folderName="Exp4">
<option name="MAIN_CLASS_NAME" value="Exp4.Task2.Start" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="HelloWorld" type="Application" factoryName="Application" folderName="Exp1">
<option name="MAIN_CLASS_NAME" value="Exp1.Task1.HelloWorld" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ManyException" type="Application" factoryName="Application" folderName="Exp6" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp6.Task2.ManyException" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Max" type="Application" factoryName="Application" folderName="Exp1">
<option name="MAIN_CLASS_NAME" value="Exp1.Task2.Max" />
<module name="Experiment" />
<option name="PROGRAM_PARAMETERS" value="23 45 34" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MaxArray.Test" type="Application" factoryName="Application" folderName="Extra">
<option name="MAIN_CLASS_NAME" value="Extra.MaxArray.Test" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PersonTest" type="Application" factoryName="Application" folderName="Exp3" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp3.Task2.PersonTest" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Person.Test" type="Application" factoryName="Application" folderName="Extra">
<option name="MAIN_CLASS_NAME" value="Extra.Person.Test" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PrimeNum" type="Application" factoryName="Application" folderName="Exp2">
<option name="MAIN_CLASS_NAME" value="Exp2.Task4.PrimeNum" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PythagoreanTheorem" type="Application" factoryName="Application" folderName="Exp1">
<option name="MAIN_CLASS_NAME" value="Exp1.Task6.PythagoreanTheorem" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="RRect.Class1" type="Application" factoryName="Application" folderName="Exp4">
<option name="MAIN_CLASS_NAME" value="Exp4.Task4.Class1" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Rectangle.Test1" type="Application" factoryName="Application" folderName="Exp3">
<option name="MAIN_CLASS_NAME" value="Exp3.Task1.Test1" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="RecursiveFactorial" type="Application" factoryName="Application" folderName="Exp2">
<option name="MAIN_CLASS_NAME" value="Exp2.Task3.RecursiveFactorial" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SafeTriangle" type="Application" factoryName="Application" folderName="Exp6" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp6.Task3.SafeTriangle" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Say" type="Application" factoryName="Application" folderName="Exp1">
<option name="MAIN_CLASS_NAME" value="Exp1.Task2.Say" />
<module name="Experiment" />
<option name="PROGRAM_PARAMETERS" value="妈妈 我爱你!!!" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SimpleTypes" type="Application" factoryName="Application" folderName="Exp1">
<option name="MAIN_CLASS_NAME" value="Exp1.Task3.SimpleTypes" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SortNum" type="Application" factoryName="Application" folderName="Exp2">
<option name="MAIN_CLASS_NAME" value="Exp2.Task1.SortNum" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="StringManipulation" type="Application" factoryName="Application" folderName="Exp5" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp5.Task1.StringManipulation" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="StringReplacement" type="Application" factoryName="Application" folderName="Exp5" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp5.Task2.StringReplacement" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TestMyDateTools" type="Application" factoryName="Application" folderName="Exp5" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp5.Task4.TestMyDateTools" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TransCard" type="Application" factoryName="Application" folderName="Exp6" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Exp6.Task4.TransCard" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="U2" type="Application" factoryName="Application" folderName="Exp2">
<option name="MAIN_CLASS_NAME" value="Exp2.Task2.U2" />
<module name="Experiment" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

124
Experiment/.idea/uiDesigner.xml generated Normal file
View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

4
Experiment/.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings" defaultProject="true" />
</project>

11
Experiment/Experiment.iml Normal file
View File

@@ -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>

View File

@@ -0,0 +1,14 @@
flowchart TD
A[开始] --> B[计算 a = 5 + 4]
B --> C[计算 b = a * 2]
C --> D[计算 c = b / 4]
D --> E[计算 d = b - c]
E --> F[计算 e = -d]
F --> G[计算 f = e % 4]
G --> H[定义 g = 18.4]
H --> I[计算 h = g % 4]
I --> J[定义 i = 3]
J --> K[计算 j = i++]
K --> L[计算 k = ++i]
L --> M[输出所有变量的值]
M --> N[结束]

View File

@@ -0,0 +1,14 @@
flowchart TD
A[开始] --> B[定义变量 i]
B --> C[创建大小为5的整型数组 arrayA]
C --> D[初始化循环 i = 0]
D --> E{i < 5?}
E -->|是| F["arrayA[i] = i"]
F --> G[i++]
G --> E
E -->|否| H[重置循环 i = 0]
H --> I{i < arrayA.length?}
I -->|是| J["输出 arrayA[i] 的值"]
J --> K[i++]
K --> I
I -->|否| L[结束]

View File

@@ -0,0 +1,7 @@
flowchart TD
A[开始] --> B[定义半径 radius = 3.0]
B --> C[计算周长 circumference = 2 * Math.PI * radius]
C --> D[计算面积 area = Math.PI * radius * radius]
D --> E[输出圆的周长]
E --> F[输出圆的面积]
F --> G[结束]

View File

@@ -0,0 +1,12 @@
flowchart TD
A[开始] --> B[定义变量 max]
B --> C[从命令行参数获取 a, b, c]
C --> D{a > b 且 a > c?}
D -->|是| E[max = a]
D -->|否| F{b > c?}
F -->|是| G[max = b]
F -->|否| H[max = c]
E --> I[输出最大值]
G --> I
H --> I
I --> J[结束]

View File

@@ -0,0 +1,9 @@
flowchart TD
A[开始] --> B[输出提示信息: 请输入直角三角形的两条直角边的长度]
B --> C[创建Scanner对象]
C --> D[读取第一个数值 a]
D --> E[读取第二个数值 b]
E --> F[关闭Scanner对象]
F --> G["计算斜边长度 $$c = \sqrt{a² + b²}$$"]
G --> H[输出斜边长度]
H --> I[结束]

View File

@@ -0,0 +1,8 @@
flowchart TD
A[开始] --> B{命令行参数数量 < 2?}
B -->|是| C[输出错误信息]
C --> D[退出程序]
B -->|否| E[获取参数 name 和 word]
E --> F[输出格式化消息]
F --> G[结束]
D --> G

View File

@@ -0,0 +1,11 @@
flowchart TD
A[开始] --> B[定义 byte b = 055]
B --> C[定义 short s = 0x55FF]
C --> D[定义 int i = 1000000]
D --> E[定义 long l = 3615L]
E --> F[定义 char c = 'c']
F --> G[定义 float f = 0.23F]
G --> H[定义 double d = 0.7E-3]
H --> I[定义 boolean bool = true]
I --> J[输出所有变量的值]
J --> K[结束]

View File

@@ -0,0 +1,12 @@
flowchart TD
A[开始] --> B[定义 n = 10]
B --> C[初始化 result = 1]
C --> D{n == 0 或 n == 1?}
D -- 是 --> E[result = 1]
D -- 否 --> F[循环: i = 2 到 n]
F --> G[result *= i]
G --> H{i < n?}
H -- 是 --> F
H -- 否 --> I[输出 n! = result]
E --> I
I --> J[结束]

View File

@@ -0,0 +1,26 @@
flowchart TD
A[开始] --> B[定义 start = 100, end = 2000]
B --> C[初始化 num_in_line = 0]
C --> D["输出 100~2000之间的素数有"]
D --> E[循环: i = start 到 end]
E --> F{"isPrime(i)?"}
F -- 是 --> G[num_in_line++]
G --> H{num_in_line % 5 == 0?}
H -- 是 --> I[输出 i 并换行]
H -- 否 --> J[输出 i 和空格]
I --> K{i < end?}
J --> K
K -- 是 --> E
K -- 否 --> L[结束]
F -- 否 --> K
subgraph isPrime函数
M["isPrime(n)"] --> N{n <= 1?}
N -- 是 --> O[返回 false]
N -- 否 --> P["循环: i = 2 到 sqrt(n)"]
P --> Q{n % i == 0?}
Q -- 是 --> R[返回 false]
Q -- 否 --> S{"i < sqrt(n)?"}
S -- 是 --> P
S -- 否 --> T[返回 true]
end

View File

@@ -0,0 +1,12 @@
flowchart TD
A[开始] --> B[定义 n = 10]
B --> C["调用 factorial(n)"]
C --> D[输出 n! = result]
D --> E[结束]
subgraph factorial函数
F["factorial(n)"] --> G{n == 0 或 n == 1?}
G -- 是 --> H[返回 1]
G -- 否 --> I["返回 n * factorial(n-1)"]
I -- "递归调用 factorial(n-1)" --> F
end

View File

@@ -0,0 +1,16 @@
flowchart TD
A[开始] --> B[定义 a=9, b=5, c=7, t]
B --> C{a > b?}
C -->|是| D[t=a, a=b, b=t]
C -->|否| E[继续]
D --> E
E --> F{a > c?}
F -->|是| G[t=a, a=c, c=t]
F -->|否| H[继续]
G --> H
H --> I{b > c?}
I -->|是| J[t=b, b=c, c=t]
I -->|否| K[继续]
J --> K
K --> L[输出 a, b, c的值]
L --> M[结束]

View File

@@ -0,0 +1,18 @@
flowchart TD
A[开始] --> B[定义 score = 55]
B --> C["switch(score / 10)"]
C --> D{case 0,1,2,3,4,5}
D -- 匹配 --> E[输出 score 分是D等]
C --> F{case 6}
F -- 匹配 --> G[输出 score 分是C等]
C --> H{case 7,8}
H -- 匹配 --> I[输出 score 分是B等]
C --> J{case 9,10}
J -- 匹配 --> K[输出 score 分是A等]
C --> L{default}
L -- 匹配 --> M[输出 数据错误]
E --> N[结束]
G --> N
I --> N
K --> N
M --> N

View File

@@ -0,0 +1,10 @@
flowchart TD
Start([开始]) --> A[创建Circle对象c半径为5]
A --> B1[Circle构造函数执行]
B1 --> B2[设置radius=5]
B2 --> B3[计算周长$$perimeter=2\times π\times radius$$]
B3 --> B4[计算面积$$area=π\times radius\times radius$$]
B4 --> C["调用c.getRadius()打印半径"]
C --> D["调用c.getPerimeter()打印周长"]
D --> E["调用c.getArea()打印面积"]
E --> End([结束])

View File

@@ -0,0 +1,11 @@
flowchart TD
Start([开始]) --> A[创建Person对象p]
A --> B[调用p.addPerson方法]
B --> B1[设置IdPerson=123]
B1 --> B2["设置Name='John Doe'"]
B2 --> B3[设置Sex='M']
B3 --> B4[设置Birthday=1990-01-01]
B4 --> B5["设置HomeAddress='123 Main St'"]
B5 --> C[调用p.showPerson方法]
C --> C1[打印IdPerson, Name, Sex, Birthday, HomeAddress]
C1 --> End([结束])

View File

@@ -0,0 +1,16 @@
flowchart TD
Start([开始]) --> A["创建Rectangle对象rect1(5,3)"]
A --> A1[设置lx=0, ly=0]
A1 --> A2[设置rx=5, ry=3]
A2 --> B[打印rect1周长]
B --> B1["计算周长:$$2\times(|rx-lx|+|ry-ly|)$$"]
B1 --> C[打印rect1面积]
C --> C1["计算面积:$$|rx-lx|\times|ry-ly|$$"]
C1 --> D["创建Rectangle对象rect2(1,6,6,2)"]
D --> D1[设置lx=1, ly=6]
D1 --> D2[设置rx=6, ry=2]
D2 --> E[打印rect2周长]
E --> E1["计算周长:$$2\times(|rx-lx|+|ry-ly|)$$"]
E1 --> F[打印rect2面积]
F --> F1["计算面积:$$|rx-lx|\times|ry-ly|$$"]
F1 --> End([结束])

View File

@@ -0,0 +1,27 @@
classDiagram
class Father {
<<abstract>>
# double height
# double weight
+ Father(double height, double weight)
+ double getHeight()
+ void setHeight(double height)
+ double getWeight()
+ void setWeight(double weight)
+ void hobby()
}
class Son {
- String personality
+ Son(double height, double weight, String personality)
+ String getPersonality()
+ void setPersonality(String personality)
+ void hobby()
}
class Main {
+ main(String[] args)
}
Father <|-- Son : 继承
Main --> Son : 创建与使用

View File

@@ -0,0 +1,33 @@
classDiagram
class Graphic {
<<interface>>
+ double area()
+ double perimeter()
}
class Circle {
- double radius
+ Circle(double radius)
+ double area()
+ double perimeter()
+ double getRadius()
}
class Rectangle {
- double width
- double height
+ Rectangle(double width, double height)
+ double area()
+ double perimeter()
+ double getWidth()
+ double getHeight()
}
class Test {
+ main(String[] args)
}
Graphic <|.. Circle : 实现
Graphic <|.. Rectangle : 实现
Test --> Circle : 创建与使用
Test --> Rectangle : 创建与使用

View File

@@ -0,0 +1,26 @@
classDiagram
class calrect {
<<interface>>
+ int calarea()
+ int calgirth()
+ int getx()
+ int gety()
}
class RRect {
- int x
- int y
+ RRect()
+ int calarea()
+ int calgirth()
+ int getx()
+ int gety()
}
class Class1 {
+ RRect rect
+ main(String[] args)
}
calrect <|.. RRect : 实现
Class1 --> RRect : 创建与使用

View File

@@ -0,0 +1,26 @@
graph TD
A[开始] --> B[初始化: 定义英文文本];
B --> C[输出: 原始文本];
C --> D[--- ArrayList 处理 ---];
D --> E{预处理文本: 转小写, 去标点, 按空格拆分};
E --> F["将拆分后的单词存入 ArrayList (wordList)"];
F --> G[移除 ArrayList 中的空字符串];
G --> H{"计算: wordList 的大小 (单词总数)"};
H --> I[输出: 单词总个数];
I --> J{创建副本并排序: 对 wordList 进行排序};
J --> K[输出: 排序后的所有单词];
K --> L[--- HashSet 处理 ---];
L --> M{"创建: 从 wordList 创建 HashSet (uniqueWordsSet) 以获取不重复单词"};
M --> N{"计算: uniqueWordsSet 的大小 (不同单词个数)"};
N --> O[输出: 不同单词的个数];
O --> P[输出:所有不同的单词];
P --> Q[--- HashMap 处理 ---];
Q --> R{"创建: 初始化空的 HashMap (wordCountMap)"};
R --> S{遍历 wordList 中的每个单词};
S -- 存在 --> T{更新: 单词在 wordCountMap 中已存在, 个数+1};
S -- 不存在 --> U{添加: 单词首次出现, 存入 wordCountMap, 个数设为1};
T --> V[遍历完所有单词];
U --> V;
V --> W{遍历 wordCountMap};
W --> X[输出: 每个单词及其出现的次数];
X --> Y[结束];

View File

@@ -0,0 +1,10 @@
graph TD
A[开始] --> B{输入: 请输入一串字符数据};
B --> C[读取用户输入的字符串];
C --> D{处理: 统计字符串长度};
D --> E[输出: 字符个数];
E --> F{处理: 将字符串转为大写};
F --> G[输出: 大写字符串];
G --> H{处理: 逆序大写字符串};
H --> I[输出: 逆序后的大写字符串];
I --> J[结束];

View File

@@ -0,0 +1,7 @@
graph TD
A[开始] --> B[初始化: 定义原始字符串];
B --> C[输出: 原始字符串];
C --> D{处理: 将所有 she 替换为 he};
D --> E{处理: 将所有 She 替换为 He};
E --> F[输出: 替换后的字符串];
F --> G[结束];

View File

@@ -0,0 +1,11 @@
graph TD
A[开始] --> B[创建 MyDateTools 对象实例];
B --> C1["调用 dateTools.getNow(null)"];
C1 --> C2["输出: getNow(null) 的结果"];
C2 --> C3["调用 dateTools.getNow('yyyy-MM-dd')"];
C3 --> C4["输出: getNow('yyyy-MM-dd') 的结果"];
C4 --> D1["调用 dateTools.getYear()"];
D1 --> D2[输出: 当前年份];
D2 --> E1["调用 dateTools.getMonth()"];
E1 --> E2[输出: 当前月份];
E2 --> F[结束];

View File

@@ -0,0 +1,11 @@
graph TD
A[开始] --> B{初始化 num1 = 100};
B --> C[创建 Scanner 对象 in];
C --> D{从控制台读取整数 num2};
D --> E{尝试块开始};
E --> F{计算 num1 = num1 / num2};
F --> G[打印结果 “结果为: ” + num1];
G --> H[结束];
E -- ArithmeticException --> I[捕获 ArithmeticException];
I --> J[打印 “除数不能为0”];
J --> H;

View File

@@ -0,0 +1,23 @@
graph TD
A[开始] --> B{第一个 try 块};
B --> C{计算 result = 8 / 0};
C -- ArithmeticException --> D[捕获 ArithmeticException];
D --> E[打印 “算术异常”];
E --> F{第二个 try 块};
C --> F;
F --> G{获取 null 字符串的长度};
G -- NullPointerException --> H[捕获 NullPointerException];
H --> I[打印 “空指针异常”];
I --> J{第三个 try 块};
G --> J;
J --> K{创建大小为4的float数组 arr};
K --> L{"访问 arr[4]"};
L -- ArrayIndexOutOfBoundsException --> M[捕获 ArrayIndexOutOfBoundsException];
M --> N[打印 “数组下标越界异常”];
N --> O{第四个 try 块};
L --> O;
O --> P{将字符串 '23U' 转换为 double};
P -- NumberFormatException --> Q[捕获 NumberFormatException];
Q --> R[打印 “字符串转换异常”];
R --> S[结束];
P --> S;

View File

@@ -0,0 +1,34 @@
graph TD
subgraph getArea 方法
GA_A["开始 getArea(a, b, c)"] --> GA_B{判断 a+b>c 且 a+c>b 且 b+c>a};
GA_B -- false --> GA_C[抛出 IllegalArgumentException “无法构成三角形”];
GA_B -- true --> GA_D["计算 (a+b+c)/2"];
GA_D --> GA_E[返回结果];
GA_C --> GA_E;
end
subgraph main 方法
M_A[开始 main] --> M_B[创建 SafeTriangle 对象 triangle];
M_B --> M_C{try 块};
M_C --> M_D[打印 “请输入三角形的三条边长:”];
M_D --> M_E[创建 Scanner 对象];
M_E --> M_F[读取一行输入];
M_F --> M_G[按空格分割输入为 parts 数组];
M_G --> M_H{判断 parts.length < 3};
M_H -- true --> M_I[抛出 IllegalArgumentException “请输入三条边长”];
M_H -- false --> M_J[初始化 a, b, c = 0];
M_J --> M_K{内部 try 块};
M_K --> M_L["解析 parts[0] 为 a"];
M_L --> M_M["解析 parts[1] 为 b"];
M_M --> M_N["解析 parts[2] 为 c"];
M_N --> M_O["调用 triangle.getArea(a, b, c) 获取面积 area"];
M_O --> M_P[打印 “三角形面积: ” + area];
M_P --> M_Q[结束 try 块];
M_K -- NumberFormatException --> M_R[捕获 NumberFormatException];
M_R --> M_S[抛出 IllegalArgumentException “边长必须是数字”];
M_S --> M_T{捕获外部 IllegalArgumentException};
M_I --> M_T;
M_Q --> M_U[结束 main];
M_T --> M_V["打印异常信息 e.getMessage()"];
M_V --> M_U;
end

View File

@@ -0,0 +1,22 @@
graph TD
subgraph pay 方法
P_A["开始 pay(amount)"] --> P_B{判断 amount > balance};
P_B -- true --> P_C[抛出 InsufficientBalanceException “余额不足”];
P_B -- false --> P_D[balance -= amount];
P_D --> P_E[打印 “支付成功,当前余额: ” + balance];
P_E --> P_F[结束 pay];
P_C --> P_F;
end
subgraph main 方法
M_A[开始 main] --> M_B[创建 TransCard 对象 card];
M_B --> M_C[设置 card.balance = 100.0];
M_C --> M_D{try 块};
M_D --> M_E["调用 card.pay(50.0)"];
M_E --> M_F["调用 card.pay(60.0)"];
M_F --> M_G[结束 try 块];
M_D -- InsufficientBalanceException --> M_H[捕获 InsufficientBalanceException];
M_H --> M_I["打印异常信息 e.getMessage()"];
M_I --> M_J[结束 main];
M_G --> M_J;
end

View File

@@ -0,0 +1,19 @@
flowchart TD
A[开始] --> B["定义 n=20并创建 int[] fib"]
B --> C["fib[0]=0; fib[1]=1"]
C --> D["循环 i=2~19 计算 fib[i]=fib[i-1]+fib[i-2]"]
D --> E[生成完毕,打开 FileWriter 写入 in.txt]
E --> F[初始化 i=0]
F --> G{是否 i < n?}
G -- 是 --> H["写入 fib[i] 的字符串形式"]
H --> I{"(i+1)%5==0?"}
I -- 是 --> J["写入 \n"]
I -- 否 --> K{i < n-1?}
K -- 是 --> L["写入 , "]
K -- 否 --> M[不写分隔符]
J --> N[i++]
L --> N[i++]
M --> N[i++]
N --> G
G -- 否 --> O[关闭 FileWriter]
O --> P[程序结束]

View File

@@ -0,0 +1,22 @@
flowchart TD
A[开始] --> B[初始化 sum=0]
B --> C[创建 FileReader 读取 in.txt]
C --> D[创建 StringBuilder number]
D --> E{"reader.read() 返回 ch"}
E -- != -1 --> F{"Character.isDigit(ch)?"}
F -- 是 --> G["number.append(ch 转字符)"]
F -- 否 --> H{ch 是 ',' 或 '\n'?}
H -- 是 --> I{number 是否为空?}
I -- 否 --> J["sum += Integer.parseInt(number)"]
J --> K["number.setLength(0)"]
K --> E
H -- 否 --> E
E -- == -1 --> L{"number.length()>0?"}
L -- 是 --> M["sum += Integer.parseInt(number)"]
L -- 否 --> N[跳过]
M --> N
N --> O[关闭 FileReader]
O --> P[创建 FileWriter 写入 sum.txt]
P --> Q[将 sum 转为字符串写入]
Q --> R[关闭 FileWriter]
R --> S[程序结束]

View File

@@ -0,0 +1,8 @@
flowchart TD
A[开始] --> B[创建 FileReader 读取 source.txt]
B --> C[创建 FileWriter 写入 object.txt]
C --> D{"reader.read() 返回值"}
D -- != -1 --> E[将字符写入 object.txt]
E --> D
D -- == -1 --> F[关闭 reader 和 writer]
F --> G[程序结束]

4
Experiment/in.txt Normal file
View File

@@ -0,0 +1,4 @@
0, 1, 1, 2, 3
5, 8, 13, 21, 34
55, 89, 144, 233, 377
610, 987, 1597, 2584, 4181

1
Experiment/object.txt Normal file
View File

@@ -0,0 +1 @@
Hello World

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

1
Experiment/source.txt Normal file
View File

@@ -0,0 +1 @@
Hello World

View File

@@ -0,0 +1,7 @@
package Exp1.Task1;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}

View File

@@ -0,0 +1,18 @@
package Exp1.Task2;
public class Max {
public static void main(String[] args) {
int max;
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = Integer.parseInt(args[2]);
if (a > b && a > c) {
max = a;
} else if (b > c) {
max = b;
} else {
max = c;
}
System.out.println("三个数中最大的是:" + max);
}
}

View File

@@ -0,0 +1,13 @@
package Exp1.Task2;
public class Say {
public static void main(String[] args) {
if (args.length < 2) {
System.out.println("需要两个命令行参数!");
System.exit(1);
}
String name = args[0];
String word = args[1];
System.out.println("我想对" + name + "悄悄地说:" + word);
}
}

View File

@@ -0,0 +1,22 @@
package Exp1.Task3;
public class SimpleTypes {
public static void main(String[] args) {
byte b = 055;
short s = 0x55FF;
int i = 1000000;
long l = 3615L;
char c = 'c';
float f = 0.23F;
double d = 0.7E-3;
boolean bool = true;
System.out.println("b=" + b);
System.out.println("s=" + s);
System.out.println("i=" + i);
System.out.println("l=" + l);
System.out.println("c=" + c);
System.out.println("f=" + f);
System.out.println("d=" + d);
System.out.println("bool=" + bool);
}
}

View File

@@ -0,0 +1,28 @@
package Exp1.Task4;
public class ArithmaticOp {
public static void main(String[] args) {
int a = 5 + 4;
int b = a * 2;
int c = b / 4;
int d = b - c;
int e = -d;
int f = e % 4;
double g = 18.4;
double h = g % 4;
int i = 3;
int j = i++;
int k = ++i;
System.out.println("a=" + a);
System.out.println("b=" + b);
System.out.println("c=" + c);
System.out.println("d=" + d);
System.out.println("e=" + e);
System.out.println("f=" + f);
System.out.println("g=" + g);
System.out.println("h=" + h);
System.out.println("i=" + i);
System.out.println("j=" + j);
System.out.println("k=" + k);
}
}

View File

@@ -0,0 +1,14 @@
package Exp1.Task5;
public class ArrayRefer {
public static void main(String[] args) {
int i;
int arrayA[] = new int[5];
for (i = 0; i < 5; i++) {
arrayA[i] = i;
}
for (i = 0; i < arrayA.length; i++) {
System.out.println("arrayA[" + i + "] = " + arrayA[i]);
}
}
}

View File

@@ -0,0 +1,11 @@
package Exp1.Task6;
public class CircleCalc {
public static void main(String[] args) {
double radius = 3.0;
double circumference = 2 * Math.PI * radius;
double area = Math.PI * radius * radius;
System.out.println("圆的周长是:" + circumference);
System.out.println("圆的面积是:" + area);
}
}

View File

@@ -0,0 +1,13 @@
package Exp1.Task6;
public class PythagoreanTheorem {
public static void main(String[] args) {
System.out.println("请输入直角三角形的两条直角边的长度:");
java.util.Scanner scanner = new java.util.Scanner(System.in);
double a = scanner.nextDouble();
double b = scanner.nextDouble();
scanner.close();
double c = Math.sqrt(a * a + b * b);
System.out.println("直角三角形的斜边长为:" + c);
}
}

View File

@@ -0,0 +1,23 @@
package Exp2.Task1;
public class SortNum {
public static void main(String[] args) {
int a = 9, b = 5, c = 7, t;
if (a > b) {
t = a;
a = b;
b = t;
}
if (a > c) {
t = a;
a = c;
c = t;
}
if (b > c) {
t = b;
b = c;
c = t;
}
System.out.println("a=" + a + ", b=" + b + ", c=" + c);
}
}

View File

@@ -0,0 +1,17 @@
package Exp2.Task2;
public class U2 {
public static void main(String[] args) {
int score = 55;
switch (score / 10) {
case 0: case 1: case 2: case 3: case 4:
case 5: System.out.println(score+"分是D等"); break;
case 6: System.out.println(score+"分是C等"); break;
case 7:
case 8: System.out.println(score+"分是B等"); break;
case 9:
case 10: System.out.println(score+"分是A等"); break;
default: System.out.println("数据错误"); break;
}
}
}

View File

@@ -0,0 +1,16 @@
package Exp2.Task3;
public class CircularFactorial {
public static void main(String[] args) {
int n = 10;
int result = 1;
if (n == 0 || n == 1) {
result = 1;
} else {
for (int i = 2; i <= n; i++) {
result *= i;
}
}
System.out.println("n! = " + result);
}
}

View File

@@ -0,0 +1,17 @@
package Exp2.Task3;
public class RecursiveFactorial {
public static void main(String[] args) {
int n = 10;
int result = factorial(n);
System.out.println("n! = " + result);
}
public static int factorial(int n) {
if (n == 0 || n == 1) {
return 1;
} else {
return n * factorial(n - 1);
}
}
}

View File

@@ -0,0 +1,32 @@
package Exp2.Task4;
public class PrimeNum {
public static void main(String[] args) {
int start = 100;
int end = 2000;
int num_in_line = 0;
System.out.println("100~2000之间的素数有");
for (int i = start; i <= end; i++) {
if (isPrime(i)) {
num_in_line++;
if (num_in_line % 5 == 0) {
System.out.println(i);
} else {
System.out.print(i + " ");
}
}
}
}
public static boolean isPrime(int n) {
if (n <= 1) {
return false;
}
for (int i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,43 @@
package Exp3.Task1;
import static java.lang.Math.abs;
public class Rectangle {
private double lx, ly, rx, ry;
public Rectangle(double rx, double ry) {
this.lx = 0;
this.ly = 0;
this.rx = rx;
this.ry = ry;
}
public Rectangle(double lx, double ly, double rx, double ry) {
this.lx = lx;
this.ly = ly;
this.rx = rx;
this.ry = ry;
}
public double getAttribute(String attribute) {
return switch (attribute) {
case "lx" -> lx;
case "ly" -> ly;
case "rx" -> rx;
case "ry" -> ry;
default -> 0;
};
}
public void setAttribute(String attribute, double value) {
switch (attribute) {
case "lx": lx = value; break;
case "ly": ly = value; break;
case "rx": rx = value; break;
case "ry": ry = value; break;
default: System.out.println("Invalid attribute"); break;
}
}
public double getC() {
return 2 * (abs(rx - lx) + abs(ry - ly));
}
public double getArea() {
return abs((rx - lx) * (ry - ly));
}
}

View File

@@ -0,0 +1,13 @@
package Exp3.Task1;
public class Test1 {
public static void main(String[] args) {
Rectangle rect1 = new Rectangle(5, 3);
System.out.println("矩形1周长: " + rect1.getC());
System.out.println("矩形1面积: " + rect1.getArea());
Rectangle rect2 = new Rectangle(1, 6, 6, 2);
System.out.println("矩形2周长: " + rect2.getC());
System.out.println("矩形2面积: " + rect2.getArea());
}
}

View File

@@ -0,0 +1,24 @@
package Exp3.Task2;
public class Circle {
private double radius, perimeter, area;
public Circle() {
this.radius = 0;
this.perimeter = 0;
this.area = 0;
}
public Circle(double radius) {
this.radius = radius;
this.perimeter = 2 * Math.PI * radius;
this.area = Math.PI * radius * radius;
}
public double getRadius() {
return radius;
}
public double getPerimeter() {
return perimeter;
}
public double getArea() {
return area;
}
}

View File

@@ -0,0 +1,10 @@
package Exp3.Task2;
public class CircleTest {
public static void main(String[] args) {
Circle c = new Circle(5);
System.out.println("半径为:" + c.getRadius());
System.out.println("周长为:" + c.getPerimeter());
System.out.println("面积为:" + c.getArea());
}
}

View File

@@ -0,0 +1,26 @@
package Exp3.Task2;
import java.time.LocalDate;
public class Person {
private int IdPerson;
private String Name;
private char Sex;
private LocalDate Birthday;
private String HomeAddress;
public void addPerson(int id, String name, char sex, LocalDate birthday, String homeAddress) {
this.IdPerson = id;
this.Name = name;
this.Sex = sex;
this.Birthday = birthday;
this.HomeAddress = homeAddress;
}
public void showPerson() {
System.out.println("Id: " + IdPerson);
System.out.println("Name: " + Name);
System.out.println("Sex: " + Sex);
System.out.println("Birthday: " + Birthday);
System.out.println("Home Address: " + HomeAddress);
}
}

View File

@@ -0,0 +1,11 @@
package Exp3.Task2;
import java.time.LocalDate;
public class PersonTest {
public static void main(String[] args) {
Person p = new Person();
p.addPerson(123, "John Doe", 'M', LocalDate.of(1990, 1, 1), "123 Main St");
p.showPerson();
}
}

Some files were not shown because too many files have changed in this diff Show More