Easy calculator Encapsulation

Source: Internet
Author: User

Calculator. java:

/*** @ Title: Calculator. java * @ Package: com. you. model * @ Description: The value class for encapsulation calculation * @ author: Youhaidong (Youhaidong) * @ date: 10:40:34 * @ version V1.0 */package com. you. model; import java. io. serializable;/*** class Function Description * class modifier modification date * modification Description *

Title: Calculator. java

*

Description: Personal Development of youhaidong

*

Copyright: Copyright (c) 2013

* @ Author: You Haidong * @ date: 10:40:34 * @ version V1.0 */public class Calculator implements Serializable {/*** @ Fields serialVersionUID: serialize */private static final long serialVersionUID = 1L;/*** operand 1 */private double operandOne;/*** operand 2 */private double operandTwo; /*** operation result */private double result = 0.0;/*** operator */private String operator;/*** addition */public double addition () {result = operandOne + operandTwo; return result;}/*** subtraction */public double subtraction () {result = operandOne-operandTwo; return result ;} /*** multiplication */public double multiplication () {result = operandOne * operandTwo; return result;}/*** division */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 ;}}


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.