Book of tasks on programming. Old version

 

 by Aliaksandr N. Prykhodzka

 

system, clipboard, xml, shr, label, monitor, until, file, interface, cell, промежуточный, университет, схема, logical, forward, реализация, отчет, обучение
 

for valuable work you must have JavaScript (allow active content)

Java. J.19. Nest of tasks. Classes

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.19.1     Answer      Pascal-analogue

Determine a value produced by function AA


import java.awt.*;
import java.applet.*;

public class Obj1
{
    int C1(int x)
    {
        return x*x;
    }

    int C2(int x)
    {
        return C1(x) / 3;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj2 extends Obj1
{
    int C1(int x)
    {
        int s=0;
        for (int i=1; i         return s;
    }    
}

-----------------------------------------------
Функция AA внутри класса Applet1

int AA()
{
    Obj2 XX = new Obj2();
    int Man=XX.C2(6);
    return Man;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.19.2     Answer      Pascal-analogue

Determine a value produced by function AA


import java.awt.*;
import java.applet.*;

public class Obj1
{
    int C1(int x)
    {
        return x+5;
    }

    int C2(int x)
    {
        return C1(x)*C1(x);
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj2 extends Obj1
{
    int C1(int x)
    {
        return x*2;
    }
}

-----------------------------------------------
Функция AA внутри класса Applet1

int AA()
{
    Obj2 XX = new Obj2();
    int Man=XX.C2(6);
    return Man;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.19.3     Answer      Pascal-analogue

Determine a value produced by function AA


import java.awt.*;
import java.applet.*;

class Obj_Fox
{
    int I_Fox;
    void N(int x)
    {
        I_Fox=x;
    }

    int Get_Fox()
    {
        return I_Fox;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj_Wolf extends Obj_Fox
{
    int I_Wolf;
    void N(int x)
    {
        I_Wolf=x / 3;
        super.N(x-I_Wolf);
    }

    int Get_Wolf()
    {
        return I_Wolf;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj_Bear extends Obj_Wolf
{
    int I_Bear;
    void N(int x)
    {
        I_Bear=x / 2;
        super.N(x-I_Bear);
    }

    int Get_Bear()
    {
        return I_Bear;
    }
}

-----------------------------------------------
Функция AA внутри класса Applet1

int AA()
{
    Obj_Bear Z = new Obj_Bear();
    Z.N(10);
    int Man=Z.Get_Fox()+(Z.Get_Wolf()*2)+(Z.Get_Bear()*3);
    return Man;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.19.4     Answer      Pascal-analogue

Determine a value produced by function AA


import java.awt.*;
import java.applet.*;

class Obj_Fox
{
    int I_Fox;
    void N(int x)
    {
        I_Fox=x;
    }

    int Get_Fox()
    {
        return I_Fox;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj_Wolf extends Obj_Fox
{
    int I_Wolf;
    void N(int x)
    {
        I_Wolf=x % 3;
        super.N(x-I_Wolf);
    }

    int Get_Wolf()
    {
        return I_Wolf;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj_Bear extends Obj_Wolf
{
    int I_Bear;
    void N(int x)
    {
        I_Bear=x % 2;
        super.N(x-I_Bear);
    }

    int Get_Bear()
    {
        return I_Bear;
    }
}

-----------------------------------------------
Функция AA внутри класса Applet1

int AA()
{
    Obj_Bear Z = new Obj_Bear();
    Z.N(10);
    int Man=Z.Get_Fox()+(Z.Get_Wolf()*2)+(Z.Get_Bear()*3);
    return Man;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.19.5     Answer      Pascal-analogue

Determine a value produced by function AA


import java.awt.*;
import java.applet.*;

class Obj_Fox
{
    int I_Fox;
    void N(int x)
    {
        I_Fox=x;
    }

    int Get_Fox()
    {
        return I_Fox;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj_Wolf extends Obj_Fox
{
    int I_Wolf;
    void N(int x)
    {
        I_Wolf=x * 3;
        super.N(x-I_Wolf);
    }

    int Get_Wolf()
    {
        return I_Wolf;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj_Bear extends Obj_Wolf
{
    int I_Bear;
    void N(int x)
    {
        I_Bear=x * 2;
        super.N(x-I_Bear);
    }

    int Get_Bear()
    {
        return I_Bear;
    }
}

-----------------------------------------------
Функция AA внутри класса Applet1

int AA()
{
    Obj_Bear Z = new Obj_Bear();
    Z.N(10);
    int Man=Z.Get_Fox()+(Z.Get_Wolf()*2)+(Z.Get_Bear()*3);
    return Man;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.19.6     Answer      Pascal-analogue

Determine a value produced by function AA


import java.awt.*;
import java.applet.*;

class Obj_Fox
{
    int I_Fox;
    void N(int x)
    {
        I_Fox=x;
    }

    int Get_Fox()
    {
        return I_Fox;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj_Wolf extends Obj_Fox
{
    int I_Wolf;
    void N(int x)
    {
        I_Wolf=+x;
        super.N(x-I_Wolf);
    }

    int Get_Wolf()
    {
        return I_Wolf;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj_Bear extends Obj_Wolf
{
    int I_Bear;
    void N(int x)
    {
        I_Bear=+x;
        super.N(x-I_Bear);
    }

    int Get_Bear()
    {
        return I_Bear;
    }
}

-----------------------------------------------
Функция AA внутри класса Applet1

int AA()
{
    Obj_Bear Z = new Obj_Bear();
    Z.N(10);
    int Man=Z.Get_Fox()+(Z.Get_Wolf()*2)+(Z.Get_Bear()*3);
    return Man;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.19.7     Answer      Pascal-analogue

Determine a value produced by function AA


import java.awt.*;
import java.applet.*;

class Obj_Fox
{
    int I_Fox;
    void N(int x)
    {
        I_Fox=x;
    }

    int Get_Fox()
    {
        return I_Fox;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj_Wolf extends Obj_Fox
{
    int I_Wolf;
    void N(int x)
    {
        I_Wolf=x-1;
        super.N(x-I_Wolf);
    }

    int Get_Wolf()
    {
        return I_Wolf;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Obj_Bear extends Obj_Wolf
{
    int I_Bear;
    void N(int x)
    {
        I_Bear=x-1;
        super.N(x-I_Bear);
    }

    int Get_Bear()
    {
        return I_Bear;
    }
}

-----------------------------------------------
Функция AA внутри класса Applet1

int AA()
{
    Obj_Bear Z = new Obj_Bear();
    Z.N(10);
    int Man=Z.Get_Fox()+(Z.Get_Wolf()*2)+(Z.Get_Bear()*3);
    return Man;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.19.8     Answer      Pascal-analogue

Determine a value produced by function AA


import java.awt.*;
import java.applet.*;

class Sun1
{
    int A()
    {
        return 7;
    }

    int B()
    {
        return A()*A();
    }

    int C()
    {
        return A()+B();
    }

    int D()
    {
        return A()+B()+C();
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Sun2 extends Sun1
{    
    int B()
    {
        return A() / 2;
    }

    int D()
    {
        return C() % 10;
    }
}

-----------------------------------------------
Функция AA внутри класса Applet1

int AA()
{
    Sun1 XX = new Sun1();
    Sun2 YY = new Sun2();
    int Man=XX.D()+YY.D();
    return Man;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.19.9     Answer      Pascal-analogue

Determine a value produced by function AA


import java.awt.*;
import java.applet.*;

class Sun1
{    
    int A()
    {
        return 3;
    }

    int B()
    {
        return A()*A();
    }

    int C()
    {
        return A()+B();
    }

    int D()
    {
        return C() / 2;
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Sun2 extends Sun1
{    
    int B()
    {
        return A() / 2;
    }

    int D()
    {
        return C() % 5;
    }
}

-----------------------------------------------
Функция AA внутри класса Applet1

int AA()
{
    Sun1 XX = new Sun1();
    Sun2 YY = new Sun2();
    int Man=XX.D()+YY.D();
    return Man;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.19.10     Answer      Pascal-analogue

Determine a value produced by function AA


import java.awt.*;
import java.applet.*;

class Sky1
{        
    int B()
    {
        return 1;
    }

    int C()
    {
        return B()+2;
    }

    int D()
    {
        return B()+C();
    }
}

-----------------------------------------------

import java.awt.*;
import java.applet.*;

class Sky2 extends Sky1
{    
    int B()
    {
        return 2;
    }

    int D()
    {
        return C() % 3;
    }
}

-----------------------------------------------
Функция AA внутри класса Applet1

int AA()
{
    Sky1 XX = new Sky1();
    Sky2 YY = new Sky2();
    int Man=XX.D()+YY.D();
    return Man;
}



 

©   Aliaksandr Prykhodzka    1993 - 2007