Compare commits
No commits in common. 'master' and 'main' have entirely different histories.
@ -1,29 +0,0 @@
|
||||
### 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
|
||||
@ -1,3 +0,0 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
@ -1,6 +0,0 @@
|
||||
<?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>
|
||||
@ -1,9 +0,0 @@
|
||||
<?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>
|
||||
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,11 +0,0 @@
|
||||
<?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>
|
||||
@ -1,15 +0,0 @@
|
||||
//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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,103 +0,0 @@
|
||||
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("进制转换器");
|
||||
|
||||
// 创建布局
|
||||
GridPane grid = new GridPane();
|
||||
grid.setPadding(new Insets(10));
|
||||
grid.setVgap(8);
|
||||
grid.setHgap(10);
|
||||
|
||||
// 原始进制输入
|
||||
Label originalBaseLabel = new Label("原始进制 (2-16):");
|
||||
grid.add(originalBaseLabel, 0, 0);
|
||||
TextField originalBaseInput = new TextField();
|
||||
grid.add(originalBaseInput, 1, 0);
|
||||
|
||||
// 要转换的数输入
|
||||
Label numberLabel = new Label("要转换的数:");
|
||||
grid.add(numberLabel, 0, 1);
|
||||
TextField numberInput = new TextField();
|
||||
grid.add(numberInput, 1, 1);
|
||||
|
||||
// 目标进制输入
|
||||
Label targetBaseLabel = new Label("目标进制 (2-16):");
|
||||
grid.add(targetBaseLabel, 0, 2);
|
||||
TextField targetBaseInput = new TextField();
|
||||
grid.add(targetBaseInput, 1, 2);
|
||||
|
||||
// 转换结果显示
|
||||
Label resultLabel = new Label("转换结果:");
|
||||
grid.add(resultLabel, 0, 3);
|
||||
TextField resultOutput = new TextField();
|
||||
resultOutput.setEditable(false);
|
||||
grid.add(resultOutput, 1, 3);
|
||||
|
||||
// 转换按钮
|
||||
Button convertButton = new Button("转换");
|
||||
grid.add(convertButton, 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) {
|
||||
showAlert("错误", "进制应在2到16之间。");
|
||||
return;
|
||||
}
|
||||
|
||||
// 进行转换
|
||||
int decimalNumber = convertToDecimal(number, originalBase);
|
||||
String result = convertFromDecimal(decimalNumber, targetBase);
|
||||
resultOutput.setText(result);
|
||||
} catch (NumberFormatException ex) {
|
||||
showAlert("错误", "请输入有效的数字和进制。");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
showAlert("错误", "输入的数不符合原始进制。");
|
||||
}
|
||||
});
|
||||
|
||||
// 创建场景并显示
|
||||
Scene scene = new Scene(grid, 400, 250);
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
// 弹出提示框
|
||||
private void showAlert(String title, String message) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle(title);
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText(message);
|
||||
alert.showAndWait();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
<?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>
|
||||
@ -1,15 +0,0 @@
|
||||
//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…
Reference in new issue