KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > freeformlib > SumNumbers


1 /*
2  * SumNmbers.java
3  *
4  * Created on 07 January 2005, 14:48
5  */

6
7 package org.netbeans.test.freeformlib;
8
9 /**
10  *
11  * @author Administrator
12  */

13 public class SumNumbers {
14     
15     private int x = 0;
16     private int y = 0;
17     
18     /** Creates a new instance of SumNmbers */
19     public SumNumbers() {
20     }
21     /** Creates a new instance of SumNmbers */
22     public SumNumbers(int x, int y) {
23         this.x = x;
24         this.y = y;
25     }
26     
27     /**
28      * Count the sum from parameters.
29      * @param x first argument for sum.
30      * @param y second argument for sum.
31      */

32     public static int sum(int x, int y) {
33         return x + y;
34     }
35     
36     /**
37      * Count the sum from initialized variables of object.
38      */

39     public int getSum() {
40         return x + y;
41     }
42     
43     public int getX() {
44         return x;
45     }
46     public void setX(int x) {
47         this.x = x;
48     }
49     
50     public int getY() {
51         return x;
52     }
53     public void setY(int y) {
54         this.y = y;
55     }
56 }
57
Popular Tags