class Chief
{
    
    private class HelpUpdate {
	private int i;


	HelpUpdate()
	{
	    i=0;
	}

	void update ( int n )
	{
	    if ( i<1 ) {
		value = n;
		i=3;
	    }
	    else
		update2( n );
	}

	void update2( int n )
	{
	    if ( i>1 ) {
		value = n*2 - 5;
		i--;
	    }
	    else
		update3 ( n );
	}

	void update3 ( int n )
	{
	    value = n%i;
	    i=0;
	}

    }

    private class HelpShow {
	void show_value ()
	{
	    System.out.print(value+"\n");
	}
	int get_value ()
	{
	    return value;
	}
    }


    public class HelpUp2 {
	private int i;
	
	HelpUp2()
	{
	    i = 1;
	}
	
	void update( int n )
	{
	    value = n*i;
	    i = n/2 * value;
	}
    }

    private int value;
    public HelpShow hs;

    Chief(int n)
    {
	value = n;
	hs =  new HelpShow();
    }

    public HelpUpdate mkUpdate()
    {
	return new HelpUpdate();
    }

    public HelpUp2 mkUp2()
    {

	return new HelpUp2();
    }

    void old_main()
    {

	Chief a = new Chief(10);
	Chief b = new Chief(20);

	a.hs.show_value();
	b.hs.show_value();

	//int i = b.hs.i;
	//not legal becuase i is private

	HelpUpdate aupdate, bupdate;
	//legal because the class is visable

	aupdate = new HelpUpdate();
	//legal but will result in bizzar values because aupdate is not
	//tied to a specific version of Chief.

	aupdate = a.mkUpdate();
	bupdate = b.mkUpdate();

	aupdate.update(5);
	bupdate.update(12);

	a.hs.show_value();
	b.hs.show_value();
	
    }

}

public class Chief2
{
    
    public static void main (String []args )
    {
	Chief tonto1 = new Chief(10);
	tonto1.hs.show_value();


	//HelpUpdate tontoupdate;
	//totontoupdate = tonto1.mkUpdate();
	//not legal because help update is not visable (private)

	//Chief.HelpUp2 up2 = new Chief.HelpUp2();
	//errors out because of scoping problems for value

	Chief.HelpUp2 up2;

	up2 = tonto1.mkUp2();
	up2.update(5);
	tonto1.hs.show_value();
    }
}

