Java-multi-state motherboard instance

Source: Internet
Author: User
/* Requirement: computer running instance computer running based on Motherboard */interface PCI // interface {public void open (); Public void close ();} class mainboard // motherboard {public void run () {system. out. println ("mainboard Run");} public void usepci (pCI p) {If (P! = NULL) {P. open (); p. close () ;}} class netcard implements PCI // Nic implementing the PCI interface {public void open () {system. out. println ("netcard open");} public void close () {system. out. println ("netcard close") ;}} class Soundcard implements PCI // The sound card that implements the PCI interface {public void open () {system. out. println ("Soundcard open");} public void close () {system. out. println ("Soundcard close") ;}} class duotaidemo2 {public static void main (string [] ar GS) {mainboard MB = new mainboard (); MB. run (); MB. usepci (New netcard (); MB. usepci (New Soundcard (); system. out. println ("Hello world! ");}}

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.