08 Mobile Device Storage

Source: Internet
Author: User

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespace_08 Mobile device Storage {classProgram {Static voidMain (string[] args) {Mobiledisk MD=NewMobiledisk (); MP3 mp3=NewMp3 (); Udisk UD=NewUdisk (); Computer CPU=Newcomputer (); //incoming mobile Hard disk parameters, that is, the method of performing moving hard plate class//because the mobile storage parent class is abstract and cannot be instantiated, it can only create a new CPU generic class for read-write. and passes the abstract parent class into the CPU action method//CPU.            Cpuread (MD); //CPU.            Cpuwrite (MD); //the second method, defining propertiescpu.ms = MP3;//inserting the MP3 into your computerCPU.            Cpuread (); Cpu.            Cpuwrite (); MP3.                        Playmusic ();        Console.readkey (); }    }    Abstract classMobilestorage { Public Abstract voidRead ();  Public Abstract voidWrite (); }    classMobiledisk:mobilestorage { Public Override voidRead () {Console.WriteLine ("The removable hard drive is reading"); }         Public Override voidWrite () {Console.WriteLine ("The removable hard disk is written"); }    }    classUdisk:mobilestorage { Public Override voidRead () {Console.WriteLine ("USB drive is reading"); }         Public Override voidWrite () {Console.WriteLine ("the USB drive is writing"); }    }    classMp3:mobilestorage { Public Override voidRead () {Console.WriteLine ("MP3 is reading"); }         Public Override voidWrite () {Console.WriteLine ("mp3 in writing"); }         Public voidPlaymusic () {Console.WriteLine ("MP3 is playing music"); }    }    //computers to identify various devices and perform read and write methods//Polymorphic , which is to see all the subclass objects as parent objects    classComputer {//Public void Cpuread (mobilestorage ms)//{        //    //The method of the parent class is executed, but the subclass overrides the parent class method, and the child class method is actually executed .//Ms.        Read (); //}        //Public void Cpuwrite (mobilestorage ms)//{        //Ms.        Write (); //}        //the second method, which defines the class property, is essentially equal to the argument//Automatic Properties         Publicmobilestorage ms {Get;Set; }         Public voidCpuread () { This. Ms.        Read (); }         Public voidCpuwrite () { This. Ms.        Write (); }    }}

08 Mobile Device Storage

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.