jzzh #1

Closed
fdzcxy212206329 wants to merge 0 commits from master into main

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

3
.idea/.gitignore vendored

@ -0,0 +1,3 @@
# 默认忽略的文件
/shelf/
/workspace.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<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,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/1010Lession/1010Lession.iml" filepath="$PROJECT_DIR$/1010Lession/1010Lession.iml" />
<module fileurl="file://$PROJECT_DIR$/gitCode.iml" filepath="$PROJECT_DIR$/gitCode.iml" />
</modules>
</component>
</project>

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

@ -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,15 @@
//TIP 要<b>运行</b>代码,请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
public static void main(String[] args) {
//TIP 当文本光标位于高亮显示的文本处时按 <shortcut actionId="ShowIntentionActions"/>
// 查看 IntelliJ IDEA 建议如何修正。
System.out.printf("Hello and welcome!");
for (int i = 1; i <= 5; i++) {
//TIP 按 <shortcut actionId="Debug"/> 开始调试代码。我们已经设置了一个 <icon src="AllIcons.Debugger.Db_set_breakpoint"/> 断点
// 但您始终可以通过按 <shortcut actionId="ToggleLineBreakpoint"/> 添加更多断点。
System.out.println("i = " + i);
}
}
}

@ -0,0 +1,97 @@
package jzzh;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class BaseConverterApp extends Application {
// 将任意 R 进制的数转换为十进制
public static int convertToDecimal(String number, int base) {
return Integer.parseInt(number, base);
}
// 将十进制数转换为任意目标进制
public static String convertFromDecimal(int decimalNumber, int targetBase) {
return Integer.toString(decimalNumber, targetBase).toUpperCase();
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Base Converter");
// 创建布局
GridPane grid = new GridPane();
grid.setPadding(new Insets(10, 10, 10, 10));
grid.setVgap(8);
grid.setHgap(10);
// 原始进制标签和输入框
Label originalBaseLabel = new Label("原始进制 (2-16):");
GridPane.setConstraints(originalBaseLabel, 0, 0);
TextField originalBaseInput = new TextField();
GridPane.setConstraints(originalBaseInput, 1, 0);
// 要转换的数字标签和输入框
Label numberLabel = new Label("请输入进制数:");
GridPane.setConstraints(numberLabel, 0, 1);
TextField numberInput = new TextField();
GridPane.setConstraints(numberInput, 1, 1);
// 目标进制标签和输入框
Label targetBaseLabel = new Label("目标进制 (2-16):");
GridPane.setConstraints(targetBaseLabel, 0, 2);
TextField targetBaseInput = new TextField();
GridPane.setConstraints(targetBaseInput, 1, 2);
// 转换按钮
Button convertButton = new Button("转换");
GridPane.setConstraints(convertButton, 1, 3);
// 结果标签
Label resultLabel = new Label();
GridPane.setConstraints(resultLabel, 1, 4);
// 设置按钮事件处理
convertButton.setOnAction(e -> {
try {
// 获取用户输入
int originalBase = Integer.parseInt(originalBaseInput.getText());
String number = numberInput.getText().toUpperCase();
int targetBase = Integer.parseInt(targetBaseInput.getText());
// 检查输入的进制范围是否合法
if (originalBase < 2 || originalBase > 16 || targetBase < 2 || targetBase > 16) {
resultLabel.setText("进制范围必须在2到16之间");
} else {
// 执行进制转换
int decimalNumber = convertToDecimal(number, originalBase);
String result = convertFromDecimal(decimalNumber, targetBase);
resultLabel.setText("转换后的结果: " + result);
}
} catch (NumberFormatException ex) {
resultLabel.setText("输入格式错误,请检查!");
} catch (Exception ex) {
resultLabel.setText("转换失败: " + ex.getMessage());
}
});
// 将所有控件添加到布局中
grid.getChildren().addAll(originalBaseLabel, originalBaseInput, numberLabel, numberInput, targetBaseLabel, targetBaseInput, convertButton, resultLabel);
// 创建场景并显示
Scene scene = new Scene(grid, 400, 250);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

@ -1,2 +0,0 @@
# jzzh

@ -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,15 @@
//TIP 要<b>运行</b>代码,请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
public static void main(String[] args) {
//TIP 当文本光标位于高亮显示的文本处时按 <shortcut actionId="ShowIntentionActions"/>
// 查看 IntelliJ IDEA 建议如何修正。
System.out.printf("Hello and welcome!");
for (int i = 1; i <= 5; i++) {
//TIP 按 <shortcut actionId="Debug"/> 开始调试代码。我们已经设置了一个 <icon src="AllIcons.Debugger.Db_set_breakpoint"/> 断点
// 但您始终可以通过按 <shortcut actionId="ToggleLineBreakpoint"/> 添加更多断点。
System.out.println("i = " + i);
}
}
}
Loading…
Cancel
Save