Yurttas/PL/OOL/CS/F/02/05/04/00/A.java

Revision as of 07:25, 7 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="java" line start="1" enclose="div">/** * Copyright(C) 1998 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc.. * * P...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 1/**
 2 *  Copyright(C) 1998
 3 *  All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4 *
 5 *  Permission to use, copy, modify, and distribute this
 6 *  software and its documentation for EDUCATIONAL purposes
 7 *  and without fee is hereby granted provided that this
 8 *  copyright notice appears in all copies.
 9 *
10 *  @date   : January 1, 1998.
11 *  @author : Salih Yurttas.
12 */
13
14
15import java.util.Vector;
16
17public class A {
18
19  protected Vector a;
20
21  public A(final int n) {
22    a = new Vector();
23    for(int i=0; i<n; i++)
24      a.addElement(new Integer(i+1));
25  }
26
27  public int sum() {
28    int s = 0;
29
30    int n = a.size();
31    for(int i=0; i<n; i++)
32      s += ((Integer)a.elementAt(i)).intValue();
33
34    return s;
35  }
36
37  public int sum(final int b) {
38    int s = 0;
39
40    int n = a.size();
41    for(int i=b; i<n; i++)
42      s += ((Integer)a.elementAt(i)).intValue();
43
44    return s;
45  }
46
47  public int sum(final int b,
48                 final int e) {
49    int s = 0;
50
51    for(int i=b; i<e; i++)
52      s += ((Integer)a.elementAt(i)).intValue();
53
54    return s;
55  }
56
57}