⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 person.cs

📁 集学生管理系统、学生选课系统、老师管理系统与一身 不错的
💻 CS
字号:
// Person.cs - Chapter 14 version.

// Copyright 2004 by Jacquie Barker and Grant Palmer - all rights reserved.

// A MODEL class.

using System;

// We are making this class abstract because we do not wish for it
// to be instantiated.

public abstract class Person {
  //------------
  // Fields.
  //------------

  private string name;
  private string ssn;
	
  //----------------
  // Constructor(s).
  //----------------

  // Initialize the field values using the set 
  // accessor of the associated property.

  public Person(string name, string ssn) {
    this.Name = name;
    this.Ssn = ssn;
  } 
	
  // We're replacing the default constructor that got "wiped out"
  // as a result of having created a constructor above. We reuse
  // the two-argument constructor with dummy values.

  public Person() : this("?", "???-??-????")  {
  }

  //-----------------
  // Properties.
  //-----------------

  public string Name {
    get {
      return name;
    }
    set {
      name = value;
    }
  }

  public string Ssn {
    get {
      return ssn;
    }
    set {
      ssn = value;
    }
  }

  //-----------------------------
  // Miscellaneous other methods.
  //-----------------------------

  // We'll let each subclass determine how it wishes to be
  // represented as a String value.

  public abstract override string ToString(); 

  // Used for testing purposes.

  public virtual void Display() {
    Console.WriteLine("Person Information:");
    Console.WriteLine("\tName:  " + this.Name);
    Console.WriteLine("\tSoc. Security No.:  " + this.Ssn);
  }
}	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -