/*****************************************************************/ /* Copyright 2013 Code Strategies */ /* This code may be freely used and distributed in any project. */ /* However, please do not remove this credit if you publish this */ /* code in paper or electronic form, such as on a web site. */ /*****************************************************************/ package com.cakes; public class Demo { public static void main(String[] args) { Lunch lunch = new Lunch(); // receiver Command lunchCommand = new LunchCommand(lunch); // concrete command Dinner dinner = new Dinner(); // receiver Command dinnerCommand = new DinnerCommand(dinner); // concrete command MealInvoker mealInvoker = new MealInvoker(lunchCommand); // invoker mealInvoker.invoke(); mealInvoker.setCommand(dinnerCommand); mealInvoker.invoke(); } }