C # Implementation of the USB Interface program code.
namespace ConsoleApplication1
{
Class Program
{
static void Main (string[] args)
{
USB USB;
USB = new Udisk ()//insert U disk
USB. OutputFile ()//Read the file from U disk
USB. Inputfile ()//write file to u disk
USB. Dispose ();//Pull out U disk
Console.WriteLine ("");
USB = new MDisk ()//insert a removable hard drive
USB. OutputFile ()//Read the file from the mobile hard drive
USB. Inputfile ()//write file to mobile hard drive
USB. Dispose ();//unplug the removable hard drive
Console.WriteLine ("");
USB = new MP4 ()//Insert MP4
USB. OutputFile ()//Read files from MP4
USB. Inputfile ()//write file to MP4
USB. Dispose ();/Pull out MP4
Console.readkey ();
}
//usb Interface
public interface Usb:idisposable
{
void OutputFile ()//read out file
void Inputfile ()//write file
}
//u Disk
public class Udisk:usb
{
public Udisk ()
{
Console.WriteLine ("U Disk Ready ...");
}
public void outputfile ()
{
Console.WriteLine ("Read the file from U disk");
}
public void Inputfile ()
{
Console.WriteLine ("Write File to U disk");
}
public void Dispose ()
{
Console.WriteLine ("U disk has been unplugged");
}
}
//removable hard disk
public class Mdisk:usb
{
Public MDisk ()
{
Console.WriteLine ("Mobile HDD Ready ...");
}
public void outputfile ()
{
Console.WriteLine ("Read the file from the mobile hard Drive");
}
public void Inputfile ()
{
Console.WriteLine ("Write file to mobile hard disk");
}
public void Dispose ()
{
Console.WriteLine ("Removable hard drive has been unplugged");
}
}
//mp4
public class Mp4:usb
{
public MP4 ()
{
Console.WriteLine ("MP4 Ready ...");
}
public void outputfile ()
{
Console.WriteLine ("Read the document from the MP4");
}
public void Inputfile ()
{
Console.WriteLine ("Write File to MP4");
}
public void Dispose ()
{
Console.WriteLine ("MP4 has been pulled out");
}
}
}
}