O'Reilly logo

IBM Rational Application Developer V6 Portlet Application Development and Portal Tools by Ryan Wilson, Gianfranco Rutigliano, George Kroner, Belen Gonzalez, Karla Galvan, Cristiano Cesario, Juan R. Rodriguez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

17.1. The calculator application

The first application to be created is a simple calculator. A JavaBean named CalculatorBean is included to provide the basic mathematical operations on two integer (long) numbers.

This bean has five properties:

  • Operand 1

  • Operand 2

  • Operation

  • Result

  • Error message

The bean also has associated getter and setter methods for all of its properties. In addition, the calculate() method calculates the result of one of the following operations:

  • Add

  • Subtract

  • Multiply

  • Divide

The result is stored in the first number (operand 1) for subsequent operations. If a division does not result in an integer, an exception is thrown. Finally, a toString() method displays the numbers and the operation.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required