Yurttas/PL/OOL/Java/F/02/07/00/A/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
15class A {
16
17  public int a0;
18
19  protected int a1;
20
21  private int a2;
22
23  A(){
24    a0=2;
25    a1=4;
26    a2=8;
27    System.out.println("A - " + a0 + a1 + a2);
28  }
29
30  void ma(){
31    a0+=2;
32    a1+=4;
33    a2+=8;
34    System.out.println("A.ma - " + a0 + a1 + a2);
35  }
36
37}
38
39
40class AA extends A {
41
42  AA(){
43    super();
44    System.out.println("AA - " + a0 + a1);
45  }
46
47  void maa(){
48    a0-=2;
49    a1-=4;
50    System.out.println("AA.maa - " + a0 + a1);
51  }
52
53}
54
55
56class AAA extends AA {
57
58  AAA(){
59    super();
60    System.out.println("AAA - " + a0 + a1);
61  }
62
63  void maaa(){
64    ++a0;
65    ++a1;
66    System.out.println("AAA.maaa - " + a0 + a1);
67  }
68
69}
70
71
72class A00 {  
73
74  public static void main(String[] args) {
75    A a = new A();
76
77    System.out.println("a.a0 - " + a.a0);
78
79    AA aa = new AA();
80
81    System.out.println("aa.a0 - " + aa.a0);
82
83    AAA aaa = new AAA();
84
85    System.out.println("aaa.a0 - " + aaa.a0);
86  }
87
88}