项目简介:
团队选择难度为C的原因主要是囿于二人的能力有限,故选择了较为简单且具有一定实用性的计算器作为本次项目。这对我们巩固基础,继续深究有很大帮助,不足之处还请老师指正。
项目主要技术:文件、大部分注释、GUI界面、面向对象程序设计、线程等
项目需求:
1、简洁清晰的操作界面(适应大众正常使用习惯的界面);
2、功能区分明显、让用户一眼明了。
3、能够满足大部分计算需求(四则运算,指数,对数等)。
项目亮点: 1、构思和设计过程中多次调试修改。2、在原有四则运算基础上拓展了多种新的计算方法。3、友好的GUI操作界面。
任务分配:
成员 |
任务分配 |
田文俊 |
1、负责主体代码书写和调试运行2、检查整体代码和框架以及进一步完善修改。 |
田茂耀 |
1.负责git仓库创建、团队博客创建及书写整理 2、负责整个用户界面构建(窗口、下拉条、对话框、和各类操作设置)。 |
运行界面
项目git地址:(gitee)
https://gitee.com/tianmaoyao/calculator.git
git提交记录:
代码部分:
//JSQ
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JSQ extends Frame implements ActionListener, WindowListener
{
private Container container;
private GridBagLayout layout;
private GridBagConstraints constraints;
private JTextField displayField; //计算结果显示区
private String lastCommand; //保存+,-,*,/,=命令0
private double result; //保存计算结果
private boolean start; //判断是否为数字的开始
private JMenuBar menubar;
private JMenuItem m_exit;
private JMenuItem m2_ejz;
private JMenuItem m2_bjz;
private Dialog dialog;
private Label label_dialog;
private JButton button_sqrt;
private JButton button_plusminus;
private JButton button_CE;
private JButton button_cancel;
private JButton button_1;
private JButton button_2;
private JButton button_3;
private JButton button_4;
private JButton button_5;
private JButton button_6;
private JButton button_7;
private JButton button_8;
private JButton button_9;
private JButton button_0;
private JButton button_plus;
private JButton button_minus;
private JButton button_multiply;
private JButton button_divide;
private JButton button_point;
private JButton button_equal;
private JButton button_log;
private JButton button_tan;
private JButton button_cos;
private JButton button_sin;
private JButton button_exp;
public JSQ() //构造方法设置布局、为按钮注册事件监听器
{
super( "计算器" );
this.setLocation( 300,200 );
this.setSize( 328,424);
this.setResizable( true );
this.setLayout( new GridLayout( 7,1 ) );//网格布局
this.addmyMenu(); //调用成员方法添加菜单
displayField = new JTextField( 30 );
displayField.setBackground(new Color(233,240,247));
displayField.setForeground(new Color(30,57,91));
// 设置outputField内的默认内容,应该显示为“0”
displayField.setText("0");
displayField.setFont(new Font("黑体",Font.BOLD,25));
// 禁止从界面(键盘)向outputField输入信息,其内容只能通过程序内部改变
displayField.setEditable(false);
this.setResizable(false);
this.add( displayField );
start = true;
result = 0;
lastCommand = "=";
JPanel panel0 = new JPanel();
panel0.setLayout( new GridLayout( 1,4,4,4 ) );
JPanel panel1 = new JPanel();
panel1.setLayout( new GridLayout( 1,5,4,4 ) );
this.add( panel1 );
button_sqrt = new JButton( "sqrt" );//根号
button_sqrt.setBackground(new Color(233,240,247));
button_plusminus = new JButton( "+/-" );
button_plusminus.setBackground(new Color(233,240,247));
button_exp = new JButton( "exp" );//底数e的n次幂
button_exp.setBackground(new Color(233,240,247));
button_CE = new JButton( "退位");
button_CE.setBackground(new Color(233,240,247));
button_CE.setForeground(new Color(30,57,91));
button_cancel = new JButton( "CE" );//清除
button_cancel.setBackground(new Color(233,240,247));
button_cancel.setForeground(new Color(30,57,91));
JPanel panel2 = new JPanel();
panel2.setLayout( new GridLayout( 1,5,4,4 ) );
this.add( panel2 );
button_7 = new JButton( "7" );
button_7.setBackground(new Color(233,240,247));
button_7.setForeground(new Color(30,57,91));
button_8 = new JButton( "8" );
button_8.setBackground(new Color(233,240,247));
button_8.setForeground(new Color(30,57,91));
button_9 = new JButton( "9" );
button_9.setBackground(new Color(233,240,247));
button_9.setForeground(new Color(30,57,91));
button_log = new JButton( "log" );//对数
button_log.setBackground(new Color(233,240,247));
button_log.setForeground(new Color(30,57,91));
button_divide = new JButton( "/" );//除
button_divide.setBackground(new Color(233,240,247));
button_divide.setForeground(new Color(30,57,91));
JPanel panel3 = new JPanel();
panel3.setLayout( new GridLayout(1,5,4,4) );
this.add( panel3 );
button_4 = new JButton( "4" );
button_4.setBackground(new Color(233,240,247));
button_4.setForeground(new Color(30,57,91));
button_5 = new JButton( "5" );
button_5.setBackground(new Color(233,240,247));
button_5.setForeground(new Color(30,57,91));
button_6 = new JButton( "6" );
button_6.setBackground(new Color(233,240,247));
button_6.setForeground(new Color(30,57,91));
button_tan = new JButton( "tan" );//正切
button_tan.setBackground(new Color(233,240,247));
button_tan.setForeground(new Color(30,57,91));
button_multiply = new JButton( "*" );//乘法
button_multiply.setBackground(new Color(233,240,247));
button_multiply.setForeground(new Color(30,57,91));
JPanel panel4=new JPanel();
panel4.setLayout( new GridLayout( 1,5,4,4 ) );
this.add(panel4);
button_1 = new JButton( "1" );
button_1.setBackground(new Color(233,240,247));
button_1.setForeground(new Color(30,57,91));
button_2 = new JButton( "2" );
button_2.setBackground(new Color(233,240,247));
button_2.setForeground(new Color(30,57,91));
button_3 = new JButton( "3" );
button_3.setBackground(new Color(233,240,247));
button_3.setForeground(new Color(30,57,91));
button_cos = new JButton( "cos");//余弦
button_cos.setBackground(new Color(233,240,247));
button_cos.setForeground(new Color(30,57,91));
button_minus = new JButton( "-" );
button_minus.setBackground(new Color(233,240,247));
button_minus.setForeground(new Color(30,57,91));
JPanel panel5 = new JPanel();
panel5.setLayout( ne