Prerrequisito: Clase Enéada , Clase Octeto
A continuación se muestran los métodos para implementar una clase Ennead usando la clase Octet en Java:
- Usando valores directos
// Java program to illustrate
// implementing Ennead Class
// from Octet Class
// using direct values
import
java.util.*;
import
org.javatuples.*;
class
GfG {
public
static
void
main(String[] args)
{
// Create Octet
Octet<String, String, String, String, String, String, String, String>
octet =
new
Octet<String, String, String, String, String, String, String, String>(
"Octet"
,
"Septet"
,
"Sextet"
,
"Quintet"
,
"Quartet"
,
"Triplet"
,
"Pair"
,
"Unit"
);
// Print the Octet
System.out.println(
"Octet: "
+ octet);
// Create Ennead from Octet
Ennead<String, String, String, String, String, String, String, String, String>
ennead =
new
Ennead<String, String, String, String, String, String, String, String, String>(
"Ennead"
,
octet.getValue0(),
octet.getValue1(),
octet.getValue2(),
octet.getValue3(),
octet.getValue4(),
octet.getValue5(),
octet.getValue6(),
octet.getValue7());
// Print the Ennead
System.out.println(
"Ennead: "
+ ennead);
}
}
Producción:
Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit] Ennead: [Ennead, Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
- Usando el método Octet.add()
// Java program to illustrate
// implementing Ennead Class
// from Octet Class
// using Octet.add()
import
java.util.*;
import
org.javatuples.*;
class
GfG {
public
static
void
main(String[] args)
{
// Create Octet
Octet<String, String, String, String, String, String, String, String>
octet =
new
Octet<String, String, String, String, String, String, String, String>(
"Octet"
,
"Septet"
,
"Sextet"
,
"Quintet"
,
"Quartet"
,
"Triplet"
,
"Pair"
,
"Unit"
);
// Print the Octet
System.out.println(
"Octet: "
+ octet);
// Create Ennead from Octet
Ennead<String, String, String, String, String, String, String, String, String>
ennead = octet.add(
"Ennead"
);
// Print the Ennead
System.out.println(
"Ennead: "
+ ennead);
}
}
Producción:
Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit] Ennead: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit, Ennead]
- Usando el método Octet.addAtX()
Programa 1: Agregar en la Posición 0 usando addAt0()
// Java program to illustrate
// implementing Ennead Class
// from Octet Class
// using addAtx()
import
java.util.*;
import
org.javatuples.*
class
GfG {
public
static
void
main(String[] args)
{
// Create Octet
Octet<String, String, String, String, String, String, String, String>
octet =
new
Octet<String, String, String, String, String, String, String, String>(
"Octet"
,
"Septet"
,
"Sextet"
,
"Quintet"
,
"Quartet"
,
"Triplet"
,
"Pair"
,
"Unit"
);
// Print the Octet
System.out.println(
"Octet: "
+ octet);
// Create Ennead from Octet
Ennead<String, String, String, String, String, String, String, String, String>
ennead = octet.addAt0(
"Ennead"
);
// Print the Ennead
System.out.println(
"Ennead: "
+ ennead);
}
}
Producción:
Octet: [Octet, Sextet, Quintet, Quartet, Triplet, Pair, Unit] Ennead: [Ennead, Octet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
Programa 2: Agregar en la Posición 1 usando addAt1()
// Java program to illustrate
// implementing Ennead Class
// from Octet Class
// using addAt1()
import
java.util.*;
import
org.javatuples.*;
class
GfG {
public
static
void
main(String[] args)
{
// Create Octet
Octet<String, String, String, String, String, String, String, String>
octet =
new
Octet<String, String, String, String, String, String, String, String>(
"Octet"
,
"Septet"
,
"Sextet"
,
"Quintet"
,
"Quartet"
,
"Triplet"
,
"Pair"
,
"Unit"
);
// Print the Octet
System.out.println(
"Octet: "
+ octet);
// Create Ennead from Octet
Ennead<String, String, String, String, String, String, String, String, String>
ennead = octet.addAt1(
"Ennead"
);
// Print the Ennead
System.out.println(
"Ennead: "
+ ennead);
}
}
Producción:
Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit] Ennead: [Octet, Ennead, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
Programa 3: Agregar en la Posición 2 usando 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 Octet
Octet<String, String, String, String, String, String, String, String>
octet =
new
Octet<String, String, String, String, String, String, String, String>(
"Octet"
,
"Septet"
,
"Sextet"
,
"Quintet"
,
"Quartet"
,
"Triplet"
,
"Pair"
,
"Unit"
);
// Print the Octet
System.out.println(
"Octet: "
+ octet);
// Create Ennead from Octet
Ennead<String, String, String, String, String, String, String, String, String>
ennead = octet.addAt2(
"Ennead"
);
// Print the Ennead
System.out.println(
"Ennead: "
+ ennead);
}
}
Producción:
Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit] Ennead: [Octet, Septet, Ennead, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
Programa 4: Agregar en la Posición 3 usando 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 Octet
Octet<String, String, String, String, String, String, String, String>
octet =
new
Octet<String, String, String, String, String, String, String, String>(
"Octet"
,
"Septet"
,
"Sextet"
,
"Quintet"
,
"Quartet"
,
"Triplet"
,
"Pair"
,
"Unit"
);
// Print the Octet
System.out.println(
"Octet: "
+ octet);
// Create Ennead from Octet
Ennead<String, String, String, String, String, String, String, String, String>
ennead = octet.addAt3(
"Ennead"
);
// Print the Ennead
System.out.println(
"Ennead: "
+ ennead);
}
}
Producción:
Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit] Ennead: [Octet, Septet, Sextet, Ennead, Quintet, Quartet, Triplet, Pair, Unit]
Programa 5: Agregar en la Posición 4 usando 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 Octet
Octet<String, String, String, String, String, String, String, String>
octet =
new
Octet<String, String, String, String, String, String, String, String>(
"Octet"
,
"Septet"
,
"Sextet"
,
"Quintet"
,
"Quartet"
,
"Triplet"
,
"Pair"
,
"Unit"
);
// Print the Octet
System.out.println(
"Octet: "
+ octet);
// Create Ennead from Octet
Ennead<String, String, String, String, String, String, String, String, String>
ennead = octet.addAt4(
"Ennead"
);
// Print the Ennead
System.out.println(
"Ennead: "
+ ennead);
}
}
Producción:
Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit] Ennead: [Octet, Septet, Sextet, Quintet, Ennead, Quartet, Triplet, Pair, Unit]
Programa 6: Agregar en la Posición 5 usando 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 Octet
Octet<String, String, String, String, String, String, String, String>
octet =
new
Octet<String, String, String, String, String, String, String, String>(
"Octet"
,
"Septet"
,
"Sextet"
,
"Quintet"
,
"Quartet"
,
"Triplet"
,
"Pair"
,
"Unit"
);
// Print the Octet
System.out.println(
"Octet: "
+ octet);
// Create Ennead from Octet
Ennead<String, String, String, String, String, String, String, String, String>
ennead = octet.addAt5(
"Ennead"
);
// Print the Ennead
System.out.println(
"Ennead: "
+ ennead);
}
}
Producción:
Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit] Ennead: [Octet, Septet, Sextet, Quintet, Quartet, Ennead, Triplet, Pair, Unit]
Programa 7: Agregar en la Posición 6 usando 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 Octet
Octet<String, String, String, String, String, String, String, String>
octet =
new
Octet<String, String, String, String, String, String, String, String>(
"Octet"
,
"Septet"
,
"Sextet"
,
"Quintet"
,
"Quartet"
,
"Triplet"
,
"Pair"
,
"Unit"
);
// Print the Octet
System.out.println(
"Octet: "
+ octet);
// Create Ennead from Octet
Ennead<String, String, String, String, String, String, String, String, String>
ennead = octet.addAt6(
"Ennead"
);
// Print the Ennead
System.out.println(
"Ennead: "
+ ennead);
}
}
Producción:
Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit] Ennead: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Ennead, Pair, Unit]
Programa 8: Agregar en la Posición 7 usando addAt7()
// 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 Octet
Octet<String, String, String, String, String, String, String, String>
octet =
new
Octet<String, String, String, String, String, String, String, String>(
"Octet"
,
"Septet"
,
"Sextet"
,
"Quintet"
,
"Quartet"
,
"Triplet"
,
"Pair"
,
"Unit"
);
// Print the Octet
System.out.println(
"Octet: "
+ octet);
// Create Ennead from Octet
Ennead<String, String, String, String, String, String, String, String, String>
ennead = octet.addAt7(
"Ennead"
);
// Print the Ennead
System.out.println(
"Ennead: "
+ ennead);
}
}
Producción:
Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit] Ennead: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Ennead, Unit]
Programa 9: Agregar en la Posición 8 usando addAt8()
// Below is a Java program to demonstrate
// use of addAt8() method with
// direct value
import
java.util.*;
import
org.javatuples.*
class
GfG {
public
static
void
main(String[] args)
{
// Create Octet
Octet<String, String, String, String, String, String, String, String>
octet =
new
Octet<String, String, String, String, String, String, String, String>(
"Octet"
,
"Septet"
,
"Sextet"
,
"Quintet"
,
"Quartet"
,
"Triplet"
,
"Pair"
,
"Unit"
);
// Print the Octet
System.out.println(
"Octet: "
+ octet);
// Create Ennead from Octet
Ennead<String, String, String, String, String, String, String, String, String>
ennead = octet.addAt8(
"Ennead"
);
// Print the Ennead
System.out.println(
"Ennead: "
+ ennead);
}
}
Producción:
Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit] Ennead: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit, Ennead]