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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| public class Test {
public class A{
boolean f;
public A (int v1) {
f=m(v1);
}
private boolean m(int v1) {
System.out.println("A "+ v1);
if (v1<0)
return true;
else
return false;
}
protected int m(int v1, int v2) {
System.out.println ("A "+ v1 + " " + v2);
if (f)
return v1;
else return v2;
}
}
public class B extends A{
public B(int v1) {
super(v1);
}
protected double mm(double v1, int v2) {
System.out.println("B "+ v1 + " " + v2);
return v1/m(v2, v2+1);
}
}
public class C extends A{
public C(int v1, int v2) {
super(v1+v2);
}
protected boolean mmm(int v1, double v2) {
System.out.println("C" +v1 +" " + v2);
if (v1>v2)
return true;
else
return false;
}
}
public void myMain ( ){
int v1 = 10, v2 = 6;
B b = new B(v2);
C c= new C (v1,v2);
c.mmm(v2, b.mm(1.0 , v1));
b.m(c.m(v1, v2),v1);
}
public static void main (String[] args ) {
Test myTest = new Test();
myTest.myMain();
}
} |
Partager