Git Product home page Git Product logo

adapterpattern's Introduction

Adapter Pattern

Little Kata in java to practise easily the implementation of Adapter pattern

We have an application where you can create a song or a fly lesson from Birds Canary and Sparrow.

We need to add new “birds” a Bat, MagicPotato and Duck , but this classes can not be modify and they do not have the methods necessary to use our existing implantation.

You need to use the Adapter Pattern to find a solution.

Getting Started

You have two different projects

AdapterPatternBefore Base code of the KATA

AdapterPatternAfter Solution of the Kata

Prerequisites

Eager to learn!!

Running the tests

Test that show how you can create a song


@Test
public void make_ALL_Birds_create_a_Melody() {

    Bird isCaptain = new Sparrow();
    Bird canary = new Canary();

    String song = canary.sing()+" "+isCaptain.sing();

    Melody melody = new Melody(song);
    Melody melodyExpected = new Melody("Melodious PIO PIO Chirp Chirp");

    melody.printMelody();

    assertEquals(melodyExpected.melody,melody.melody);
}

Test that show how you can create a Fly Lesson

@Test
public void make_ALL_birds_teach_Flylessons(){

    Bird isCaptain = new Sparrow();
    Bird canary = new Canary();

    String lesson =canary.fly()+" "+isCaptain.fly();
    FlyTime flylesson = new FlyTime(lesson);
    FlyTime flyLessonExpected = new FlyTime("Flying like a canary Flying to steal your Bread");

    flylesson.printFlyLessons();

    assertEquals(flyLessonExpected.flyLesson,flylesson.flyLesson);
}

Built With

  • Maven - Dependency Management

Authors

Laura Gonzalez - Laura

adapterpattern's People

Contributors

lauragonfer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.