aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/test3/TransNewClass.java
blob: a8a7da172f342ecb0fca45ba09445cb0168cdde7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package test3;

class TransNewClassOld {
    int k = 1;
    TransNewClassOld() {}
    TransNewClassOld(int i) { k = i; }
    TransNewClassOld(TransNewClassOld obj) { k = obj.k; }
}

class TransNewClassNew extends TransNewClassOld {
    TransNewClassNew() { k = 10; }
    TransNewClassNew(int i) { k = i * 10; }
    TransNewClassNew(TransNewClassOld obj) { k = obj.k * 2; }
}

class TransNewClassNot extends TransNewClassOld {
    TransNewClassNot() { k = 100; }
}

public class TransNewClass {
    public static class TransNewClass2 {
        public int test() {
            TransNewClassOld obj = new TransNewClassOld();
            TransNewClassOld obj2 = new TransNewClassOld();
            TransNewClassOld obj3 = new TransNewClassOld(3);
            return obj.k + obj2.k + obj3.k;
        }
    }

    public int test() {
        TransNewClassOld obj = new TransNewClassOld();
        TransNewClassOld obj2 = new TransNewClassOld(4);
        TransNewClassOld obj3 = new TransNewClassNot();
        TransNewClassOld obj4 = new TransNewClassOld(new TransNewClassOld());
        return obj.k + obj2.k + obj3.k + obj4.k;
    }
}