/*
 * [TestExtendingInnerAndNested.java]
 *
 * Summary: How to extend an inner class.
 *
 * Copyright: (c) 2009-2016 Roedy Green, Canadian Mind Products, http://mindprod.com
 *
 * Licence: This software may be copied and used freely for any purpose but military.
 *          http://mindprod.com/contact/nonmil.html
 *
 * Requires: JDK 1.8+
 *
 * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
 *
 * Version History:
 *  1.0 2007-11-21
 */
package com.mindprod.example;
import static java.lang.System.*;
/**
 * How to extend an inner class.
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0 2007-11-21
 * @since 2007-11-21
 */
public final class TestExtendingInnerAndNested
    {
    /**
     * main program to allocate an Outer/Inner/Nested class and extended Outer/Inner/Nested class
     *
     * @param args command line not used.
     */
    public static void main( String[] args )
        {
        // allocate Outer
        Outer o = new Outer();
        // allocate Inner
        Outer.Inner i = o.new Inner();
        out.println( i.indicator() );// prints 0
        // allocate nested
        Outer.Nested n = new Outer.Nested();
        out.println( n.indicator() );// prints 1
        // allocate extended Outer
        OuterE oe = new OuterE();
        // allocate extended Inner
        OuterE.InnerE ie = oe.new InnerE();
        out.println( ie.indicator() );// prints 2
        // allocate extended nested
        OuterE.NestedE ne = new OuterE.NestedE();
        out.println( ne.indicator() );// prints 3
        }
    }
/**
 * base Outer class
 */
class Outer
    {
    /**
     * nested static class
     */
    static class Nested
        {
        int indicator()
            {
            return 1;
            }
        }
    /**
     * Inner class
     */
    class Inner
        {
        int indicator()
            {
            return 0;
            }
        }
    }
/**
 * extended Outer class
 */
class OuterE extends Outer
    {
    /**
     * extended nested static class
     */
    static class NestedE extends Nested
        {
        int indicator()
            {
            return 3;
            }
        }
    /**
     * extended Inner class
     */
    class InnerE extends Inner
        {
        int indicator()
            {
            return 2;
            }
        }
    }