陈永锐提交

master
Eterlaze 10 months ago
parent b8dfe87d65
commit 9870d9b94b

29
.gitignore vendored

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

8
.idea/.gitignore vendored

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

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/Product1113.java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/allclasses-frame.html" charset="GBK" />
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/allclasses-noframe.html" charset="GBK" />
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/constant-values.html" charset="GBK" />
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/deprecated-list.html" charset="GBK" />
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/help-doc.html" charset="GBK" />
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-1.html" charset="GBK" />
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-2.html" charset="GBK" />
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-3.html" charset="GBK" />
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index-files/index-4.html" charset="GBK" />
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/index.html" charset="GBK" />
<file url="file://$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc/overview-tree.html" charset="GBK" />
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

@ -0,0 +1,10 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="127" name="Java" />
</Languages>
</inspection_tool>
</profile>
</component>

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="lession00">
<CLASSES>
<root url="jar://$PROJECT_DIR$/_01Lession1113/src/Java1113/lession00.zip!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<<<<<<< HEAD
=======
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" value="$PROJECT_DIR$/Java1113/_01Lesson1113/src/Java1113/lesson01/javadoc" />
<option name="OPTION_SCOPE" value="public" />
<option name="OPTION_INCLUDE_LIBS" value="true" />
</component>
>>>>>>> b127eb2ca79831ab03cfe24ad4732db233126931
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<<<<<<< HEAD
<module fileurl="file://$PROJECT_DIR$/Calculater.iml" filepath="$PROJECT_DIR$/Calculater.iml" />
=======
<module fileurl="file://$PROJECT_DIR$/Java1113/_00Lesson1113/_00Lesson1113.iml" filepath="$PROJECT_DIR$/Java1113/_00Lesson1113/_00Lesson1113.iml" />
<module fileurl="file://$PROJECT_DIR$/Java1113/_01Lesson1113/_01Lesson1113.iml" filepath="$PROJECT_DIR$/Java1113/_01Lesson1113/_01Lesson1113.iml" />
<module fileurl="file://$PROJECT_DIR$/Java1113/_02Lesson1113/_02Lesson1113.iml" filepath="$PROJECT_DIR$/Java1113/_02Lesson1113/_02Lesson1113.iml" />
<module fileurl="file://$PROJECT_DIR$/Java1113/_03Lesson1113/_03Lesson1113.iml" filepath="$PROJECT_DIR$/Java1113/_03Lesson1113/_03Lesson1113.iml" />
<module fileurl="file://$PROJECT_DIR$/Java1113/_04Lesson1113/_04Lesson1113.iml" filepath="$PROJECT_DIR$/Java1113/_04Lesson1113/_04Lesson1113.iml" />
<module fileurl="file://$PROJECT_DIR$/Java1113/_05Lesson1113/_05Lesson1113.iml" filepath="$PROJECT_DIR$/Java1113/_05Lesson1113/_05Lesson1113.iml" />
>>>>>>> b127eb2ca79831ab03cfe24ad4732db233126931
</modules>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SwaggerSettings">
<remoteSpecificationUrls>
<UrlInfo>
<option name="urlString" value="https://api.swaggerhub.com/apis/RAJKUMARSINGH07/OpenAPIcourse/1.0/swagger.yaml" />
</UrlInfo>
</remoteSpecificationUrls>
</component>
</project>

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

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

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

@ -0,0 +1 @@
Calculater.java

@ -0,0 +1,149 @@
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);
GridPane gridPane = createButtonGrid();
VBox layout = new VBox(10);
layout.setPadding(new Insets(10));
layout.setAlignment(Pos.CENTER);
layout.getChildren().addAll(display, gridPane);
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;
}
}

@ -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);
}
}
}
Loading…
Cancel
Save