Implement Septet Class from Sextet Class in Java using JavaTuples

Prerequisite: Septet Class, Sextet Class

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

  1. Using direct values
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

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

    chevron_right

    
    

    Output:

    Sextet: [Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Septet: [Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    
  2. Using Sextet.add() method
    // Java program to illustrate
    // implementing Septet Class
    // from Sextet Class
    // using add()

    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 Sextet
            Sextet<String, String, String, String, String, String>
                sextet = new Sextet<String, String, String, String, String, String>(
                    "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Sextet
            System.out.println("Sextet: " + sextet);
      
            // Create Septet from Sextet
            Septet<String, String, String, String, String, String, String>
                septet = sextet.add("Septet");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
        }
    }

    chevron_right

    
    

    Output:



    Sextet: [Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Septet: [Sextet, Quintet, Quartet, Triplet, Pair, Unit, Septet]
    
  3. Using Sextet.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 Septet Class 
    // from Sextet Class 
    // using addAt0()
      
    import java.util.*;
    import org.javatuples.*
      
        class GfG {
        public static void main(String[] args)
        {
            // Create Sextet
            Sextet<String, String, String, String, String, String>
                sextet = new Sextet<String, String, String, String, String, String>(
                    "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Sextet
            System.out.println("Sextet: " + sextet);
      
            // Create Septet from Sextet
            Septet<String, String, String, String, String, String, String>
                septet = sextet.addAt0("Septet");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
        }
    }

    chevron_right

    
    

    Output:

    Sextet: [Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Septet: [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

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

    chevron_right

    
    

    Output:

    Sextet: [Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Septet: [Sextet, Septet, 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 Sextet
            Sextet<String, String, String, String, String, String>
                sextet = new Sextet<String, String, String, String, String, String>(
                    "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Sextet
            System.out.println("Sextet: " + sextet);
      
            // Create Septet from Sextet
            Septet<String, String, String, String, String, String, String>
                septet = sextet.addAt2("Septet");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
        }
    }

    chevron_right

    
    

    Output:

    Sextet: [Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Septet: [Sextet, Quintet, Septet, 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 Sextet
            Sextet<String, String, String, String, String, String>
                sextet = new Sextet<String, String, String, String, String, String>(
                    "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Sextet
            System.out.println("Sextet: " + sextet);
      
            // Create Septet from Sextet
            Septet<String, String, String, String, String, String, String>
                septet = sextet.addAt3("Septet");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
        }
    }

    chevron_right

    
    

    Output:

    Sextet: [Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Septet: [Sextet, Quintet, Quartet, Septet, 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 Sextet
            Sextet<String, String, String, String, String, String>
                sextet = new Sextet<String, String, String, String, String, String>(
                    "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Sextet
            System.out.println("Sextet: " + sextet);
      
            // Create Septet from Sextet
            Septet<String, String, String, String, String, String, String>
                septet = sextet.addAt4("Septet");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
        }
    }

    chevron_right

    
    

    Output:

    Sextet: [Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Septet: [Sextet, Quintet, Quartet, Triplet, Septet, 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 Sextet
            Sextet<String, String, String, String, String, String>
                sextet = new Sextet<String, String, String, String, String, String>(
                    "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Sextet
            System.out.println("Sextet: " + sextet);
      
            // Create Septet from Sextet
            Septet<String, String, String, String, String, String, String>
                septet = sextet.addAt5("Septet");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
        }
    }

    chevron_right

    
    

    Output:

    Sextet: [Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Septet: [Sextet, Quintet, Quartet, Triplet, Pair, Septet, 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 Sextet
            Sextet<String, String, String, String, String, String>
                sextet = new Sextet<String, String, String, String, String, String>(
                    "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Sextet
            System.out.println("Sextet: " + sextet);
      
            // Create Septet from Sextet
            Septet<String, String, String, String, String, String, String>
                septet = sextet.addAt6("Septet");
      
            // Print the Septet
            System.out.println("Septet: " + septet);
        }
    }

    chevron_right

    
    

    Output:

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


    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.