Compare commits

...

2 Commits

@ -1,4 +1,3 @@
<?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" />

@ -11,7 +11,6 @@ public class Computer extends JFrame{
public static void main(String[] args) {
Computer t = new Computer();
}
public Computer() {
this.setTitle("计算器");
Container c = getContentPane();
@ -38,7 +37,6 @@ public class Computer extends JFrame{
aJButtons[13]=new JButton("/");
aJButtons[14]=new JButton("=");
aJButtons[15]=new JButton(".");
aj.add(aJButtons[7]);
aj.add(aJButtons[8]);
aj.add(aJButtons[9]);
@ -58,7 +56,6 @@ public class Computer extends JFrame{
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() {
@ -118,22 +115,18 @@ public class Computer extends JFrame{
}
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]);
}

Loading…
Cancel
Save