From c0cb368e884e22635debd420969f1e82516c1d6f Mon Sep 17 00:00:00 2001
From: Cyh Name <2308880173@qq.com>
Date: Thu, 10 Oct 2024 17:08:28 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E9=99=88=E6=B0=B8=E8=BE=89=E6=96=B0?=
=?UTF-8?q?=E5=A2=9E=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/.gitignore | 3 +
.idea/cys_cyh_UML.iml | 11 +
.idea/dbnavigator.xml | 403 ++++++++++++++++++
.idea/misc.xml | 6 +
.idea/modules.xml | 8 +
.idea/vcs.xml | 6 +
out/production/cys_cyh_UML/.idea/.gitignore | 3 +
.../cys_cyh_UML/.idea/cys_cyh_UML.iml | 11 +
.../cys_cyh_UML/.idea/dbnavigator.xml | 403 ++++++++++++++++++
out/production/cys_cyh_UML/.idea/misc.xml | 6 +
out/production/cys_cyh_UML/.idea/modules.xml | 8 +
out/production/cys_cyh_UML/.idea/vcs.xml | 6 +
out/production/cys_cyh_UML/README.md | 2 +
out/production/cys_cyh_UML/uml10_10.class | Bin 0 -> 3045 bytes
14 files changed, 876 insertions(+)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/cys_cyh_UML.iml
create mode 100644 .idea/dbnavigator.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 out/production/cys_cyh_UML/.idea/.gitignore
create mode 100644 out/production/cys_cyh_UML/.idea/cys_cyh_UML.iml
create mode 100644 out/production/cys_cyh_UML/.idea/dbnavigator.xml
create mode 100644 out/production/cys_cyh_UML/.idea/misc.xml
create mode 100644 out/production/cys_cyh_UML/.idea/modules.xml
create mode 100644 out/production/cys_cyh_UML/.idea/vcs.xml
create mode 100644 out/production/cys_cyh_UML/README.md
create mode 100644 out/production/cys_cyh_UML/uml10_10.class
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..359bb53
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
diff --git a/.idea/cys_cyh_UML.iml b/.idea/cys_cyh_UML.iml
new file mode 100644
index 0000000..b107a2d
--- /dev/null
+++ b/.idea/cys_cyh_UML.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml
new file mode 100644
index 0000000..6dafaf6
--- /dev/null
+++ b/.idea/dbnavigator.xml
@@ -0,0 +1,403 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..0548357
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..5a188cc
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/cys_cyh_UML/.idea/.gitignore b/out/production/cys_cyh_UML/.idea/.gitignore
new file mode 100644
index 0000000..359bb53
--- /dev/null
+++ b/out/production/cys_cyh_UML/.idea/.gitignore
@@ -0,0 +1,3 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
diff --git a/out/production/cys_cyh_UML/.idea/cys_cyh_UML.iml b/out/production/cys_cyh_UML/.idea/cys_cyh_UML.iml
new file mode 100644
index 0000000..b107a2d
--- /dev/null
+++ b/out/production/cys_cyh_UML/.idea/cys_cyh_UML.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/cys_cyh_UML/.idea/dbnavigator.xml b/out/production/cys_cyh_UML/.idea/dbnavigator.xml
new file mode 100644
index 0000000..6dafaf6
--- /dev/null
+++ b/out/production/cys_cyh_UML/.idea/dbnavigator.xml
@@ -0,0 +1,403 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/cys_cyh_UML/.idea/misc.xml b/out/production/cys_cyh_UML/.idea/misc.xml
new file mode 100644
index 0000000..0548357
--- /dev/null
+++ b/out/production/cys_cyh_UML/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/cys_cyh_UML/.idea/modules.xml b/out/production/cys_cyh_UML/.idea/modules.xml
new file mode 100644
index 0000000..5a188cc
--- /dev/null
+++ b/out/production/cys_cyh_UML/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/cys_cyh_UML/.idea/vcs.xml b/out/production/cys_cyh_UML/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/out/production/cys_cyh_UML/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/cys_cyh_UML/README.md b/out/production/cys_cyh_UML/README.md
new file mode 100644
index 0000000..7915642
--- /dev/null
+++ b/out/production/cys_cyh_UML/README.md
@@ -0,0 +1,2 @@
+# cys_cyh_UML
+
diff --git a/out/production/cys_cyh_UML/uml10_10.class b/out/production/cys_cyh_UML/uml10_10.class
new file mode 100644
index 0000000000000000000000000000000000000000..9df78f8910aee981f8c6fe1ef38b7db24f11ac6a
GIT binary patch
literal 3045
zcmaJ?ZE#f88GcUo?!9+67YGRp*?ctdgSs0Ml3-Xgk!VPWT};3l3_@)2X7?H{>{oa1
zM(Bqh1r1tFX{}X)P=#u0i-P{xP@(X%Go9)9r~mtln9g*Dnf|D4$C^H8@5aO?B
zAvxP}I4p-Fe)y2kk<^irQPNVG(eOPVvdH-nfFq^6j&VPp!cnO?CWr6q_<@ceO7kD-
zcv|{CqvKgW!gx*&Kh|+v#|i25ytIEo!-R&D0_uHs%67U1JfZNgfYO_eTLNna?3A@T
zpB%Nad(F`VHI)PDn3)(hv$kB9l!|l6&I$Mj^2tPd+rjp>E&-pD?z3Wc(o6`f4-FhP
z$IaG+nHp;ya~VRt1MISfepV@CN-##2Me356ix_Rp>=?sT
ztzg3QwZ(KxvD0wDz_0O+jPS03Y5Yc@VeZn*-1S#)KL5__$EW6QoVj_jaO>L1EiLVl
zTi0H^b!|$+dj@`sa|V7V!MKRCJnff0pPu<(_N|E(+ynw&8qK}?+}s~7&c1T~)2S2k
z81J(&uFLFemv6rRIo_*s|
zG5jTYg3D+Y&=-15_!b+oXY{ZYBm0-A+#Zqi2`e?`94bB;yuYgKQ4dX(P&CY2P_-DO
zccFXau$?PiaV69nKEM-`q$Hu0wPVBXV<0yeZ}p=8pjk}AOU+jy)Ylj8W4U&2z;eh4
zfpRDPsC+wmi^P}iOs|?$rQ!lDD?C2SZ~fw3uA~353%aGtv>|e?{>O`faOG$no1nSuFuYpYAi_dbk
zVu%E5_Qn$FoQ2!?L2BYh6Hp-J+rqJht5(i}v$tsm;zJ5$*vwHaDm~l=4A%f{Xy?iY
zlAanmi-XYl2PQq+J>5+OlqvCu5>U?I>85~EfG6S&c&|V?je0qIBWm45K%J#B<=1%^)?+U=
zAdYH`(dszr@B)2aMne&W$9eJ){W`Ff=V{WHZ#{HMjP054%xxW_PFJK5EKF4OUsrKJ2+9w~E64=sQrP(3EK?9@&7?P-~p7nsW%&)Mg^yW=~7N+fl%}eKoa-uIc%|NsIDk
zPeqH=H50(gjO#+yO?ZGinQJ3~3vm@DIGfN%yHML!?17iO^0Obdd=66ObK*;z1sK
z505Gd)6F{Dv6}j=1cMb*zm>C;TnN@+CqeHc1OZ0aiGF5pWTXf2EoPQrtb?lk7Xb}X
z4Z9v7Bt8)|h{r=1DBHdbiO{wZ)ImfsOz3iy&SE!y
zPx%Ih@JDJt!DILb4&a{{DYows5-&%;LAF%h?$2nyhjTgpj)(DW!e5QQ;*lbQoA75w
zkqjQ@2VXK>Vazr*TDJZZ(&bU=)M88TfHDsYx`ts5`-IT&7<()D`h1RU;y
Date: Thu, 17 Oct 2024 16:44:37 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E9=99=88=E6=B0=B8=E8=BE=89=E6=96=B0?=
=?UTF-8?q?=E5=A2=9E=E5=8A=9F=E8=83=BD2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
uml10_10.java | 108 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 71 insertions(+), 37 deletions(-)
diff --git a/uml10_10.java b/uml10_10.java
index ef8bfa8..517f820 100644
--- a/uml10_10.java
+++ b/uml10_10.java
@@ -1,22 +1,24 @@
-import java.util.Scanner;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
public class uml10_10 {
- // 将任意进制字符串转换为十进制整数
+ // 将任意进制字符串转换为十进制整数
public static int toDecimal(String number, int base) {
int decimal = 0;
int power = 0;
-
- // 从字符串的末尾开始处理
+ // 从字符串的末尾开始处理
for (int i = number.length() - 1; i >= 0; i--) {
char digit = number.charAt(i);
- // 如果是数字字符(0-9)
+ // 如果是数字字符(0-9)
if (Character.isDigit(digit)) {
int value = Character.getNumericValue(digit);
decimal += value * Math.pow(base, power);
}
- // 如果是字母字符(A-F 或 a-f),表示10-15
+ // 如果是字母字符(A-F 或 a-f),表示10-15
else if (Character.isLetter(digit)) {
char upperDigit = Character.toUpperCase(digit);
int value = upperDigit - 'A' + 10;
@@ -31,14 +33,14 @@ public class uml10_10 {
return decimal;
}
- // 将十进制整数转换为任意进制字符串
+ // 将十进制整数转换为任意进制字符串
public static String fromDecimal(int number, int base) {
if (number == 0) {
return "0";
}
StringBuilder result = new StringBuilder();
- char[] digits = "0123456789ABCDEF".toCharArray(); // 支持到16进制
+ char[] digits = "0123456789ABCDEF".toCharArray(); // 支持到16进制
boolean isNegative = number < 0;
if (isNegative) {
@@ -59,34 +61,66 @@ public class uml10_10 {
}
public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
-
- System.out.print("请输入源进制(2-16):");
- int sourceBase = scanner.nextInt();
- scanner.nextLine(); // 消耗掉换行符
-
- System.out.print("请输入目标进制(2-16):");
- int targetBase = scanner.nextInt();
- scanner.nextLine(); // 消耗掉换行符
-
- System.out.print("请输入要转换的" + sourceBase + "进制数字:");
- String number = scanner.nextLine().trim(); // 读取实际的数字输入
-
- // 验证源进制数字是否有效
- for (char c : number.toCharArray()) {
- if (!Character.isDigit(c) && !(Character.isLetter(c) && (Character.toUpperCase(c) >= 'A' && Character.toUpperCase(c) <= 'F') && sourceBase > 10)) {
- throw new IllegalArgumentException("Invalid character in source base number: " + c);
+ // 创建窗口
+ JFrame frame = new JFrame("进制转换器");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setSize(400, 300);
+ frame.setLayout(new GridLayout(5, 2)); // 网格布局
+
+ // 创建组件
+ JLabel sourceBaseLabel = new JLabel("源进制(2-16):");
+ JTextField sourceBaseField = new JTextField();
+
+ JLabel targetBaseLabel = new JLabel("目标进制(2-16):");
+ JTextField targetBaseField = new JTextField();
+
+ JLabel numberLabel = new JLabel("要转换的数字:");
+ JTextField numberField = new JTextField();
+
+ JButton convertButton = new JButton("转换");
+ JLabel resultLabel = new JLabel("转换结果:");
+
+ // 添加组件到窗口
+ frame.add(sourceBaseLabel);
+ frame.add(sourceBaseField);
+ frame.add(targetBaseLabel);
+ frame.add(targetBaseField);
+ frame.add(numberLabel);
+ frame.add(numberField);
+ frame.add(convertButton);
+ frame.add(resultLabel);
+
+ // 添加按钮事件处理
+ convertButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ try {
+ int sourceBase = Integer.parseInt(sourceBaseField.getText().trim());
+ int targetBase = Integer.parseInt(targetBaseField.getText().trim());
+ String number = numberField.getText().trim();
+
+ // 验证源进制数字是否有效
+ for (char c : number.toCharArray()) {
+ if (!Character.isDigit(c) &&
+ !(Character.isLetter(c) && (Character.toUpperCase(c) >= 'A' && Character.toUpperCase(c) <= 'F') && sourceBase > 10)) {
+ throw new IllegalArgumentException("Invalid character in source base number: " + c);
+ }
+ }
+
+ // 将源进制数字转换为十进制
+ int decimalNumber = toDecimal(number, sourceBase);
+
+ // 将十进制数字转换为目标进制
+ String convertedNumber = fromDecimal(decimalNumber, targetBase);
+
+ // 显示结果
+ resultLabel.setText("转换后的" + targetBase + "进制数字是:" + convertedNumber);
+ } catch (IllegalArgumentException ex) {
+ JOptionPane.showMessageDialog(frame, "错误: " + ex.getMessage(), "输入错误", JOptionPane.ERROR_MESSAGE);
+ }
}
- }
-
- // 将源进制数字转换为十进制
- int decimalNumber = toDecimal(number, sourceBase);
-
- // 将十进制数字转换为目标进制
- String convertedNumber = fromDecimal(decimalNumber, targetBase);
-
- System.out.println("转换后的" + targetBase + "进制数字是:" + convertedNumber);
-
- scanner.close();
+ });
+ // 显示窗口
+ frame.setVisible(true);
}
-}
\ No newline at end of file
+}