Skip to content

Instantly share code, notes, and snippets.

Created May 23, 2018
What would you like to do?

Patrón Adapter

import java.util.List;
public class AdaptadorDeSuma implements Sumable {
private Sumador sumador;
public AdaptadorDeSuma(Sumador sumador) {
this.sumador = sumador;
public int sumatoria(List<Integer> lista) {
int resultado = 0;
for (Integer valor : lista) {
resultado = sumador.sumar(resultado, valor);
return resultado;
import java.util.List;
public interface Sumable {
int sumatoria(List<Integer> lista);
public class Sumador {
public int sumar(int a, int b) {
return a + b;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment