zoukankan      html  css  js  c++  java
  • 抽象类

    类中有抽象的方法,此类即为抽象类,抽象方法必须在子类中被重写
    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace ConsoleApplication10
    {
        
    class Program
        
    {
            
    static void Main(string[] args)
            
    {
                HR a 
    = new HR();
                Sales b 
    = new Sales();
                manger c 
    = new manger();
                
    string d = Console.ReadLine();
                
    if (d == "HR")
                
    {
                    a.pay();
                    Console.ReadKey();
                }

                
    if (d == "Sales")
                
    {
                    b.pay();
                    Console.ReadKey();
                }

                
    if (d == "manger")
                
    {
                    c.pay();
                    Console.ReadKey();
                }

            }

        }

        
        
    public abstract class user
        
    {
            
            
    public abstract void pay();
           
        }

        
    public class HR:user
        
    {
            
    public override void pay()
            
    {
                Console.WriteLine(
    "4000");
            }

        }

        
    public class Sales : user
        
    {
            
    public override void pay()
            
    {
                Console.WriteLine(
    "2000") ;
            }

        }

        
    public class manger : user
        
    {
            
    public override void pay()
            
    {
                Console.WriteLine(
    "10000");
            }

        }

    }

    肩负责任,永不退缩
  • 相关阅读:
    dart 函数迭代器
    dart 编译
    dart 扩展方法
    dart 包
    默认2345导航
    (24)WPF 数据绑定
    (22)WPF 控件模板
    JSP慕课网之Session
    HTML <td> 标签的 colspan 属性
    HTML Input属性
  • 原文地址:https://www.cnblogs.com/ATP/p/860637.html
Copyright © 2011-2022 走看看