Wednesday, November 20, 2024
Google search engine
HomeLanguagesJavaImplement Octet Class from Septet Class in Java using JavaTuples

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




    // 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);
        }
    }

    
    

    Output:

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




    // 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);
        }
    }

    
    

    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()




    // 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);
        }
    }

    
    

    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()




    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);
        }
    }

    
    

    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()




    // 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);
        }
    }

    
    

    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()




    // 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);
        }
    }

    
    

    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()




    // 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);
        }
    }

    
    

    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()




    // 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);
        }
    }

    
    

    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()




    // 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);
        }
    }

    
    

    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()




    // 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);
        }
    }

    
    

    Output:

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

RELATED ARTICLES

Most Popular

Recent Comments