• 制作简易计算器封装类


    Calculator.java:

    /**
     * @Title:Calculator.java
     * @Package:com.you.model
     * @Description:封装计算的数值类
     * @author:Youhaidong(游海东)
     * @date:2014-6-15 下午10:40:34
     * @version V1.0
     */
    package com.you.model;
    
    import java.io.Serializable;
    
    /**
     * 类功能说明
     * 类修改者 修改日期
     * 修改说明
     * <p>Title:Calculator.java</p>
     * <p>Description:游海东个人开发</p>
     * <p>Copyright:Copyright(c)2013</p>
     * @author:游海东
     * @date:2014-6-15 下午10:40:34
     * @version V1.0
     */
    public class Calculator implements Serializable 
    {
    	/**
    	 * @Fields  serialVersionUID:序列化
    	 */
    	private static final long serialVersionUID = 1L;
    	
    	/**
    	 * 操作数一
    	 */
    	private double operandOne;
    	
    	/**
    	 * 操作数二
    	 */
    	private double operandTwo;
    	
    	/**
    	 * 运算结果
    	 */
    	private double result = 0.0;
    	
    	/**
    	 * 运算符
    	 */
    	private String operator;
    	
    	/**
    	 * 加法
    	 */
    	public double addition()
    	{
    		result = operandOne + operandTwo;
    		return result;
    	}
    	
    	/**
    	 * 减法
    	 */
    	public double subtraction()
    	{
    		result = operandOne - operandTwo;
    		return result;
    	}
    	
    	/**
    	 * 乘法
    	 */
    	public double multiplication()
    	{
    		result = operandOne * operandTwo;
    		return result;
    	}
    	
    	/**
    	 * 除法
    	 */
    	public double division()
    	{
    		result = operandOne / operandTwo;
    		return result;
    	}
    
    	/**
    	 * @return the operandOne
    	 */
    	public double getOperandOne() {
    		return operandOne;
    	}
    
    	/**
    	 * @param operandOne the operandOne to set
    	 */
    	public void setOperandOne(double operandOne) {
    		this.operandOne = operandOne;
    	}
    
    	/**
    	 * @return the operandTwo
    	 */
    	public double getOperandTwo() {
    		return operandTwo;
    	}
    
    	/**
    	 * @param operandTwo the operandTwo to set
    	 */
    	public void setOperandTwo(double operandTwo) {
    		this.operandTwo = operandTwo;
    	}
    
    	/**
    	 * @return the result
    	 */
    	public double getResult() {
    		return result;
    	}
    
    	/**
    	 * @param result the result to set
    	 */
    	public void setResult(double result) {
    		this.result = result;
    	}
    
    	/**
    	 * @return the operator
    	 */
    	public String getOperator() {
    		return operator;
    	}
    
    	/**
    	 * @param operator the operator to set
    	 */
    	public void setOperator(String operator) {
    		this.operator = operator;
    	}
    	
    }
    


  • 相关阅读:
    TCP通过哪些措施,保证传输可靠
    http协议---简述
    单播、广播、组播、多播
    axios 设置超时时间 timeout
    axios 处理并发请求
    vue 模板语法
    vue keep-alive
    v-if 条件渲染分组
    debounce 防抖动函数
    vue scoped 深度作用选择器
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13315029.html
Copyright © 2020-2023  润新知