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
      编程太难,无法搞定。写出来一点,但无法运行。

  • 相关阅读:
    作业帮:最长连续序列(头部插入)
    作业帮:字符串反转(头部插入)
    作业帮:给定一个整数数组,找出其中两个数相加等于目标值(去重set)
    JVM系列之七:HotSpot 虚拟机
    JVM系列之六:内存溢出、内存泄漏 和 栈溢出
    JVM系列之四:运行时数据区
    JVM系列之五:垃圾回收
    JVM系列之三:类装载器子系统
    JVM系列之二:编译过程
    JVM系列之一:JVM架构
  • 原文地址:https://www.cnblogs.com/yuanai/p/4422989.html
Copyright © 2011-2022 走看看