section.cs

来自「学生注册管理系统」· CS 代码 · 共 70 行

CS
70
字号
// Section.cs - Chapter 14 version.

using System;

public class Section {
  private int sectionNo;
  private Professor instructor;
  // etc.
  // Constructor.
  public Section(int sNo) {
    this.SectionNo = sNo;

    // A Professor has not yet been identified.
    this.Instructor = null;
  }

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

  public int SectionNo {
    get {
      return sectionNo;
    }
    set {
      sectionNo = value;
    }
  }

  public Professor Instructor {
    get {
      return instructor;
    }
    set {
      instructor = value;
    }
  }

  // Used for testing purposes.
  public void Display() {
    Console.WriteLine("\tSection No.:  " + this.SectionNo);
    Console.WriteLine("\tProfessor:  " + this.Instructor.Name);
//    Professor p = this.Instructor;
//    if (p != null) Console.WriteLine("\tProfessor:  " + p.Name);
  }

  // etc.

}

public class Professor
{
  private String name;

  public Professor(string n) {
    this.Name = n;
  }

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

}

⌨️ 快捷键说明

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