Starting from:

$30

INFO5100-Assignment 5 Solved

Implement the below Diagram for decorator pattern. Test using code given below. 

 

public class DecoratorPatternTest {

 

    public static void main(String[] args) {

        Car sportsCar = new SportsCar(new BasicCar());         sportsCar.assemble();          

        System.out.println();

 

        Car sportsLuxuryCar = new SportsCar(new LuxuryCar(new BasicCar()));         sportsLuxuryCar.assemble();

    }

 

}  o/p:

Basic Car. Adding features of Sports Car.  

 

Basic Car. Adding features of Luxury Car. Adding features of Sports Car.

 

Implement the below Diagram for Façade design pattern. Test using code given below. 
 

 

public class FacadePatternDemo {

    public static void main(String[] args) {         ShapeMaker shapeMaker = new ShapeMaker();

         shapeMaker.drawCircle();         shapeMaker.drawRectangle();         shapeMaker.drawSquare();

    }

}  O/P:

Drawing a Circle 

Drawing a Rectangle 

Drawing a Square 

 

 

Implement the below Diagram for Strategy pattern. Test using code given below. 

                 

                 

public class StrategyPatternDemo {     public static void main(String[] args) {         ShoppingCart cart = new ShoppingCart();

 

        Item item1 = new Item("1234",10);

        Item item2 = new Item("5678",40);

         cart.addItem(item1);         cart.addItem(item2);

         cart.pay(new PaypalStrategy("myemail@example.com"));         cart.pay(new CreditCardStrategy( "1234567890123456"));

    }

}  o/p: Paypal : $50

CreditCard : $50

 

More products