Compare commits

...

No commits in common. 'main' and 'master' have entirely different histories.

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,5 @@
<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,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/UML.iml" filepath="$PROJECT_DIR$/UML.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>

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

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

Binary file not shown.

@ -0,0 +1,148 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Computer extends JFrame{
private static final long serialVersionUID = 1L;
JPanel xs, aj;
JTextField xsArea;
JButton[] aJButtons = new JButton[16];
String a;
int flag = 0;
public static void main(String[] args) {
Computer t = new Computer();
}
public Computer() {
this.setTitle("计算器");
Container c = getContentPane();
c.setLayout(new BorderLayout());
xs = new JPanel(new FlowLayout());
xsArea = new JTextField(20);
xsArea.setFont(new Font("宋体", Font.PLAIN, 38));
xs.add(xsArea);
c.add(xs, BorderLayout.NORTH);
aj = new JPanel(new GridLayout(4,4));
aJButtons[0]=new JButton("0");
aJButtons[1]=new JButton("1");
aJButtons[2]=new JButton("2");
aJButtons[3]=new JButton("3");
aJButtons[4]=new JButton("4");
aJButtons[5]=new JButton("5");
aJButtons[6]=new JButton("6");
aJButtons[7]=new JButton("7");
aJButtons[8]=new JButton("8");
aJButtons[9]=new JButton("9");
aJButtons[10]=new JButton("+");
aJButtons[11]=new JButton("-");
aJButtons[12]=new JButton("*");
aJButtons[13]=new JButton("/");
aJButtons[14]=new JButton("=");
aJButtons[15]=new JButton(".");
aj.add(aJButtons[7]);
aj.add(aJButtons[8]);
aj.add(aJButtons[9]);
aj.add(aJButtons[13]);
aj.add(aJButtons[4]);
aj.add(aJButtons[5]);
aj.add(aJButtons[6]);
aj.add(aJButtons[12]);
aj.add(aJButtons[1]);
aj.add(aJButtons[2]);
aj.add(aJButtons[3]);
aj.add(aJButtons[11]);
aj.add(aJButtons[0]);
aj.add(aJButtons[15]);
aj.add(aJButtons[10]);
aj.add(aJButtons[14]);
c.add(aj, BorderLayout.CENTER);
setSize(400, 400);
setVisible(true);
for(int i = 0; i < 10; i++) {
final String o = aJButtons[i].getActionCommand();
aJButtons[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
a = xsArea.getText();
a = a + o;
xsArea.setText(a);
}
});
}
aJButtons[10].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
a = xsArea.getText();
a = a + "+";
flag = 1;//加法
xsArea.setText(a);
}
});
aJButtons[11].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
a = xsArea.getText();
a = a + "-";
flag = 2;//减法
xsArea.setText(a);
}
});
aJButtons[12].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
a=xsArea.getText();
a=a+"*";
flag=3;//乘法
xsArea.setText(a);
}
});
aJButtons[13].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
a=xsArea.getText();
a=a+"/";
flag=4;//除法
xsArea.setText(a);
}
});
aJButtons[14].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
a = xsArea.getText();
String[] sz = new String[2];
sz=a.split("\\+|\\-|\\*|\\/");
double b = 0;
if(flag == 0) {
b = Double.parseDouble(a);
}
else if(flag == 1) {
b = Double.parseDouble(sz[0]) + Double.parseDouble(sz[1]);
}
else if(flag == 2) {
b = Double.parseDouble(sz[0]) - Double.parseDouble(sz[1]);
}
else if(flag == 3) {
b = Double.parseDouble(sz[0]) * Double.parseDouble(sz[1]);
}
else if(flag == 4) {
b = Double.parseDouble(sz[0]) / Double.parseDouble(sz[1]);
}
a = ""+b;
xsArea.setText(a);
}
});
aJButtons[15].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
a=xsArea.getText();
a=a+".";
xsArea.setText(a);
}
});
}
}

@ -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);
}
}
}

Binary file not shown.
Loading…
Cancel
Save