The façade mode of Java design pattern

Source: Internet
Author: User

http://www.verejava.com/?id=16999102164568

Package Com.facade.theory;public class testfacade{public static void Main (string[] args) {facade facade=new        Facade ();        Facade.sing ();        Facade.dance ();    Facade.act ();    }}package Com.facade.theory;public class facade{private light light;    Private music music;        Private video video;        Public facade () {light=new lightimpl ();        Music=new Musicimpl ();    Video=new Videoimpl ();        } public void Sing () {System.out.println ("Start singing accompany");        Light.flash ();    Music.play ();        } public void Dance () {System.out.println ("Start dancing accompanies");        Light.flash ();        Music.play ();    Video.show ();        } public Void Act () {System.out.println ("Starting sketch companion");        Light.flash ();    Video.show (); }}package Com.facade.theory;public interface light{public void Flash ();} Package Com.facade.theory;public class Lightimpl implements light{@Override public void Flash ()    {System.out.println ("flashing lights"); }}package Com.facade.theory;public interface music{public void play (); Package Com.facade.theory;public class Musicimpl implements music{@Override public void Play () {SYSTEM.O            Ut.println ("Play classical music"); }}package Com.facade.theory;public interface video{public void Show (); Package Com.facade.theory;public class Videoimpl implements video{@Override public void Show () {SYSTEM.O            Ut.println ("Show mountain Stream video"); }}

http://www.verejava.com/?id=16999102164568

The façade mode of Java design pattern

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.