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