zoukankan      html  css  js  c++  java
  • 构建之法——现代软件工程


     import java.awt.*;
    import java.awt.event.ActionListener;
     
    import javax.swing.*;
     
     public class F {
     JFrame frame = new JFrame("计算机");
     
     JPanel pl = new JPanel();
     
     JPanel p2 = new JPanel();
     
     static JTextField show = new JTextField();
     
     static JButton b0 = new JButton("0");
     
     static JButton b1 = new JButton("1");
     
     static JButton b2 = new JButton("2");
     
     static JButton b3 = new JButton("3");
     
     static JButton b4 = new JButton("4");
     
     static JButton b5 = new JButton("5");
     
     static JButton b6 = new JButton("6");
     
     static JButton b7 = new JButton("7");
     
     static JButton b8 = new JButton("8");
     
     static JButton b9 = new JButton("9");
     
     JButton bjia = new JButton("+");
     
     JButton bjian = new JButton("-");
     
     JButton bcheng = new JButton("*");
     
     JButton bchu = new JButton("/");
     
     JButton bdian = new JButton(".");
     
     JButton bdeng = new JButton("=");
     
     JButton bqingchu = new JButton("清除");
     
     public void y() {
     pl.setLayout(new GridLayout(1, 1));
     pl.add(show);
     }
     
     public void p() {
     b1.addActionListener(new U());
     b2.addActionListener(new U());
     b3.addActionListener(new U());
     b4.addActionListener(new U());
     b5.addActionListener(new U());
     b6.addActionListener(new U());
     b7.addActionListener(new U());
     b8.addActionListener(new U());
     b9.addActionListener(new U());
     b0.addActionListener(new U());
     
     bjia.addActionListener(new Fu());
     bjian.addActionListener(new Fu());
     bcheng.addActionListener(new Fu());
     bchu.addActionListener(new Fu());
     
     bdeng.addActionListener(new Deng());
     bqingchu.addActionListener(new Qing());
     
     p2.setLayout(new GridLayout(6, 3));
     p2.add(b1);
     p2.add(b2);
     p2.add(b3);
     p2.add(b4);
     p2.add(b5);
     p2.add(b6);
     p2.add(b7);
     p2.add(b8);
     p2.add(b9);
     p2.add(b0);
     p2.add(bjia);
     p2.add(bjian);
     p2.add(bcheng);
     p2.add(bchu);
     p2.add(bdian);
     p2.add(bqingchu);
     p2.add(bdeng);
     }
     
     public void o() {
     frame.setLayout(new BorderLayout());
     frame.add(pl, BorderLayout.NORTH);
     frame.add(p2, BorderLayout.CENTER);
     frame.setSize(400, 300);
     frame.setVisible(true);
     
     }
     
     public static void main(String[] args) {
     F f = new F();
     f.y();
     f.p();
     f.o();
     
     }
     
     }
     ////

     import java.awt.event.ActionEvent;
     import java.awt.event.ActionListener;
     
     public class ya implements ActionListener {
     public static String str = "";
     
     public static String a = "";
     
     public static String b = "";
     
     public static String k = "";
     
     public void actionPerformed(ActionEvent e) {
     String w = e.getActionCommand();//字
     
     if (k.equals("")) {
     a += w;
     F.show.setText(a);
     
     } else {
     b += w;
     F.show.setText(b);
     }
     
     }
     
     }
    ////
    import java.awt.event.ActionEvent;
     import java.awt.event.ActionListener;
     
     public class Deng implements ActionListener {
     
     public void actionPerformed(ActionEvent e) {
     int a = Integer.parseInt(U.a);
     int b = Integer.parseInt(U.b);
     int c = 0;
     if (U.k.equals("+")) {
     c = a + b;
     
     } else
     
     if (U.k.equals("-")) {
     c = a - b;
     
     } else
     
     if (U.k.equals("*")) {
     c = a * b;
     
     } else
     
     if (U.k.equals("/")) {
     c = a / b;
     
     } else {
     
     }
     
     String d = String.valueOf(c);
     F.show.setText(d);
     U.a = d;
     U.b = "";
     U.k = "";
     }
     }
    ///

     import java.awt.event.ActionEvent;
     import java.awt.event.ActionListener;
     
     public class Qing implements ActionListener {
     
     public void actionPerformed(ActionEvent e) {
     U.a = "";
     U.b = "";
     U.k = "";
     F.show.setText("");
     
     }
     
     }
    ///

     import java.awt.event.ActionEvent;
     import java.awt.event.ActionListener;
     
     public class Qing implements ActionListener {
     
     public void actionPerformed(ActionEvent e) {
     U.a = "";
     U.b = "";
     U.k = "";
     F.show.setText("");
     
     }
     
     }
    ///
    2
      编程太难,无法搞定。写出来一点,但无法运行。

  • 相关阅读:
    MPlayer源代码分析
    洛谷 P1025 数的划分
    洛谷 P1209 [USACO1.3]修理牛棚 Barn Repair
    洛谷 P1744 采购特价商品
    洛谷 P1443 马的遍历
    洛谷 P1294 高手去散步
    洛谷 P2104 二进制
    洛谷 P1088 火星人
    洛谷 P1062 数列
    洛谷 P2005 A/B Problem II
  • 原文地址:https://www.cnblogs.com/yuanai/p/4422989.html
Copyright © 2011-2022 走看看