zoukankan      html  css  js  c++  java
  • 接口的例子

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        public interface IPrints
        {
            double a { set; }
            void Print();
            void PrintPreview();
        }
        public class IPrint
        {
            static void Main()
            {
                Console.WriteLine("Plesas select printer:");
                string printerName = Console.ReadLine();
                IPrints printer = null;
    
                if (printerName == "HP")
                {
                    printer = new test();
                }
                else if (printerName == "IBM")
                {
                    printer = new IBMPrint();
                }
                else if (printerName == "Epsom")
                {
                    printer = new EpsomPrint();
                }
    
                printer.PrintPreview();
                Console.ReadKey();
                printer.Print();
                Console.ReadKey();
    
                test aa = new test();
                aa.testt();
                Console.ReadKey();
            }
        }
        public class HPPrint : IPrints
        {
            public double a { get; set; }
            public void PrintPreview()
            {
                Console.WriteLine(a.ToString());
            }
            public void Print()
            {
                Console.WriteLine("this is HP Printer");
            }
        }
        public class test : HPPrint
        {
            double zB = 0;
            public double B
            {
                set{zB=value;}
                get { return zB; }
            }
            HPPrint hp = new HPPrint();
            public void testt()
            {
                zB = 10;
                hp.a = 123;
                hp.a += zB;
                hp.PrintPreview();
            }
        }
        public class IBMPrint : IPrints
        {
            public double a { get; set; }
            public void PrintPreview()
            {
                Console.WriteLine("this is IBM Printer");
            }
            public void Print()
            {
                Console.WriteLine("this is IBM Printer");
            }
        }
        public class EpsomPrint : IPrints
        {
            public double a { get; set; }
            public void PrintPreview()
            {
                Console.WriteLine("this is Epsom Printer");
            }
            public void Print()
            {
                Console.WriteLine("this is Epsom Printer");
            }
            public void PrinSt()
            {
                Console.WriteLine("this is Epsom Printer");
            }
        }
    }
    
  • 相关阅读:
    spring mvc注解文件上传下载
    html,图片上传预览,input file获取文件等相关操作
    three.js、webGL、canvas区别于关联
    html添加新元素兼容和访问
    关于HTML,css3自适应屏幕,自适应宽度
    数据库设计的规则 入门
    mysql 索引入门
    一 .linux上安装 python git redis nginx
    一 .git和github
    一 .Django+Alipay(支付宝支付使用)和微信支付
  • 原文地址:https://www.cnblogs.com/swtool/p/4192416.html
Copyright © 2011-2022 走看看