Yurttas/PL/OOL/CS/F/06/01/02/TA.java

From ZCubes Wiki
Jump to navigation Jump to search
 1/**
 2 *  Copyright(C) 2004
 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   : September 1, 2004.
11 *  author : Salih Yurttas.
12 */
13
14
15public class TA<T0,
16                T1> {
17
18  private final static int N0=4;
19  private T0[] a0;
20
21  private final static int N1=4;
22  private T1[] a1;
23
24  public TA(final T0 v0,
25            final T1 v1) {
26    this.a0 = new T0[N0];    // this won't compile!
27    for(int i=0; i<N0; i++)
28      this.a0[i] = v0;
29
30    this.a1 = new T1[N1];    // this won't compile!
31    for(int i=0; i<N1; i++)
32      this.a1[i] = v1;
33  }
34
35  public int getSize0() {
36    return this.N0;
37  }
38
39  public T0[] getA0() {
40    return this.a0;
41  }
42
43  public void setA0(final T0 v) {
44    for(int i=0; i<N0; i++)
45      this.a0[i] = v;
46  }
47
48  public int getSize1() {
49    return this.N1;
50  }
51
52  public T1[] getA1() {
53    return this.a1;
54  }
55
56  public void setA1(final T1 v) {
57    for(int i=0; i<N1; i++)
58      this.a1[i] = v;
59  }
60
61  public void output() {
62    for(int i=0; i<N0; i++)
63      System.out.println(this.a0[i]);
64
65    System.out.println();
66
67    for(int i=0; i<N1; i++)
68      System.out.println(this.a1[i]);
69    System.out.println();
70  }
71
72}