Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on

  • Be the first to comment

  • Be the first to like this


  1. 1. Programa utilizando Patrones de diseñoClase BebidaCafeinadapublic abstract class BebidaCafeinada{ public final void prepararReceta() { hervir(); poner(); servir(); agregarCondimentos(); } public abstract void poner(); public abstract void agregarCondimentos(); public void hervir() { System.out.println( "Hirviendo Agua" ); } public void servir() { System.out.println( "Siriviendo" ); }}
  2. 2. Clase Cafepublic class Cafe extends BebidaCafeinada{ public void poner() { System.out.println( "Poniendo Cafe" ); } public void agregarCondimentos() { System.out.println( "Agregando azucar y leche" ); }}Clase Tepublic class Te extends BebidaCafeinada{ public void poner() { System.out.println( "Poniendo Te" ); } public void agregarCondimentos() { System.out.println( "Agregando limón" ); }}
  3. 3. Clase PruebaBebidapublic class PruebaBebida{ public static void main( String[] args ){ Te miTe = new Te(); Cafe miCafe = new Cafe(); System.out.println( "nPreparando Te" ); miTe.prepararReceta(); System.out.println( "nPreparando Cafe" ); miCafe.prepararReceta(); }}