Implement Octet Class from Septet Class in Java using JavaTuples

Prerequisite: Octet Class, Septet Class

Below are the methods to implement a Octet Class using Septet Class in Java:

  1. Using direct values
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // Java program to illustrate
    // implementing Octet Class 
    // from Septet Class 
    // using direct values
      
    import java.util.*;
    import org.javatuples.*;
      
    class GfG {
      
        public static void main(String[] args)
        {
            // Create Septet
            Septet<String, String, String, String, String, String, String>
                septet = new Septet<String, String, String, String, String, String, String>(
                    "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
      
            // Create Octet from Septet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet",
                    septet.getValue0(),
                    septet.getValue1(),
                    septet.getValue2(),
                    septet.getValue3(),
                    septet.getValue4(),
                    septet.getValue5(),
                    septet.getValue6());
      
            // Print the Octet
            System.out.println("Octet: " + octet);
        }
    }

    chevron_right

    
    

    Output:

    Septet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    
  2. Using Septet.add() method
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // Java program to illustrate
    // implementing Octet Class 
    // from Septet Class 
    // using Septet.add()
      
    import java.util.*;
    import org.javatuples.*;
      
    class GfG {
        public static void main(String[] args)
        {
            // Create Septet
            Septet<String, String, String, String, String, String, String>
                septet = new Septet<String, String, String, String, String, String, String>(
                    "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
      
            // Create Octet from Septet
            Octet<String, String, String, String, String, String, String, String>
                octet = septet.add("Octet");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
        }
    }

    chevron_right

    
    

    Output:

    Septet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Octet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit, Octet]
    
  3. Using Septet.addAtX() method

    Program 1: Adding at Position 0 using addAt0()



    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // Java program to illustrate
    // implementing Octet Class 
    // from Septet Class 
    // using Septet.addAtX()
      
    import java.util.*;
    import org.javatuples.*
      
        class GfG {
        public static void main(String[] args)
        {
            // Create Septet
            Septet<String, String, String, String, String, String, String>
                septet = new Septet<String, String, String, String, String, String, String>(
                    "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
      
            // Create Octet from Septet
            Octet<String, String, String, String, String, String, String, String>
                octet = septet.addAt0("Octet");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
        }
    }

    chevron_right

    
    

    Output:

    Septet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    

    Program 2: Adding at Position 1 using addAt1()

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    import java.util.*;
    import org.javatuples.*;
      
    class GfG {
        public static void main(String[] args)
        {
            // Create Septet
            Septet<String, String, String, String, String, String, String>
                septet = new Septet<String, String, String, String, String, String, String>(
                    "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
      
            // Create Octet from Septet
            Octet<String, String, String, String, String, String, String, String>
                octet = septet.addAt1("Octet");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
        }
    }

    chevron_right

    
    

    Output:

    Septet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Octet: [Septet, Octet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    

    Program 3: Adding at Position 2 using addAt2()

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // Below is a Java program to demonstrate
    // use of addAt2() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
        class GfG {
        public static void main(String[] args)
        {
            // Create Septet
            Septet<String, String, String, String, String, String, String>
                septet = new Septet<String, String, String, String, String, String, String>(
                    "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
      
            // Create Octet from Septet
            Octet<String, String, String, String, String, String, String, String>
                octet = septet.addAt2("Octet");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
        }
    }

    chevron_right

    
    

    Output:

    Septet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Octet: [Septet, Sextet, Octet, Quintet, Quartet, Triplet, Pair, Unit]
    

    Program 4: Adding at Position 3 using addAt3()

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // Below is a Java program to demonstrate
    // use of addAt3() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
        class GfG {
        public static void main(String[] args)
        {
            // Create Septet
            Septet<String, String, String, String, String, String, String>
                septet = new Septet<String, String, String, String, String, String, String>(
                    "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
      
            // Create Octet from Septet
            Octet<String, String, String, String, String, String, String, String>
                octet = septet.addAt3("Octet");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
        }
    }

    chevron_right

    
    

    Output:

    Septet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Octet: [Septet, Sextet, Quintet, Octet, Quartet, Triplet, Pair, Unit]
    

    Program 5: Adding at Position 4 using addAt4()

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // Below is a Java program to demonstrate
    // use of addAt4() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
       class GfG {
        public static void main(String[] args)
        {
            // Create Septet
            Septet<String, String, String, String, String, String, String>
                septet = new Septet<String, String, String, String, String, String, String>(
                    "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
      
            // Create Octet from Septet
            Octet<String, String, String, String, String, String, String, String>
                octet = septet.addAt4("Octet");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
        }
    }

    chevron_right

    
    

    Output:

    Septet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Octet: [Septet, Sextet, Quintet, Quartet, Octet, Triplet, Pair, Unit]
    

    Program 6: Adding at Position 5 using addAt5()



    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // Below is a Java program to demonstrate
    // use of addAt5() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
        class GfG {
        public static void main(String[] args)
        {
            // Create Septet
            Septet<String, String, String, String, String, String, String>
                septet = new Septet<String, String, String, String, String, String, String>(
                    "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
      
            // Create Octet from Septet
            Octet<String, String, String, String, String, String, String, String>
                octet = septet.addAt5("Octet");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
        }
    }

    chevron_right

    
    

    Output:

    Septet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Octet: [Septet, Sextet, Quintet, Quartet, Triplet, Octet, Pair, Unit]
    

    Program 7: Adding at Position 6 using addAt6()

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // Below is a Java program to demonstrate
    // use of addAt6() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
       class GfG {
        public static void main(String[] args)
        {
            // Create Septet
            Septet<String, String, String, String, String, String, String>
                septet = new Septet<String, String, String, String, String, String, String>(
                    "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
      
            // Create Octet from Septet
            Octet<String, String, String, String, String, String, String, String>
                octet = septet.addAt6("Octet");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
        }
    }

    chevron_right

    
    

    Output:

    Septet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Octet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Octet, Unit]
    

    Program 8: Adding at Position 7 using addAt6()

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // Below is a Java program to demonstrate
    // use of addAt7() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
       class GfG {
        public static void main(String[] args)
        {
            // Create Septet
            Septet<String, String, String, String, String, String, String>
                septet = new Septet<String, String, String, String, String, String, String>(
                    "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
      
            // Create Octet from Septet
            Octet<String, String, String, String, String, String, String, String>
                octet = septet.addAt7("Octet");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
        }
    }

    chevron_right

    
    

    Output:

    Septet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Octet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit, Octet]
    


    My Personal Notes arrow_drop_up

    Check out this Author's contributed articles.

    If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

    Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




    Article Tags :
    Practice Tags :


    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.