Yurttas/PL/OOL/CS/F/02/05/03/00/A00.java

From ZCubes Wiki
Jump to navigation Jump to search
 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 A00 {
18
19  public static void main(String[] args) {
20
21    Vector vA = new Vector();
22
23    vA = init();
24
25    Vector vB = new Vector();
26
27    vB = compute(vA);
28
29    out(vB);
30
31  }
32
33  public static Vector init() {
34    byte[] b = {0,
35                15,
36                31,
37                63};
38
39    int n = b.length;
40
41    Vector v = new Vector();
42
43    for(int i=0; i<n; i++)
44      v.addElement(new Byte(b[i]));
45
46    return v;
47  }
48
49  public static Vector compute(Vector a) {
50    Vector v = new Vector();
51
52    int n = a.size();
53
54    for(int i=0; i<n; i++) {
55      byte t = ((Byte)a.elementAt(i)).byteValue();
56      v.addElement(new Byte(t));
57      v.addElement(new Byte(++t));
58    }
59
60    return v;
61  }
62
63  public static void out(Vector a) {
64    int n = a.size();
65
66    for(int i=0; i<n; i+=2)
67      System.out.println((Byte)a.elementAt(i));
68
69    System.out.println();
70
71    for(int i=1; i<n; i+=2)
72      System.out.println((Byte)a.elementAt(i));
73  }
74
75}