日期:2011-06-16  浏览次数:20402 次


using System;
using System.Collections;
using System.IO;

namespace SEI.DL88250.SourceCodes.CSharp
{
 public interface IStudent
 {
 // Properties
  string ID
  {
   get;
   set;
  }

  string Name
  {
   get;
   set;
  }

  string Gender
  {
   get;
   set;
  }

  string ClassNum
  {
   get;
   set;
  }

  string Specialty
  {
   get;
   set;
  }

  string BDay
  {
   get;
   set;
  }
 }

 public interface IStudentIMP
 {
 // Methods
  // Add a new student's info into ArrayList
  void AddInfo();
  // Print out all students' info to console
  void DisplayInfo();
  // Delete a student's info
  void DropInfo();
  // Save all students' info into disk
  void SaveFile();
  // Search a student's info by ID
  // If find info return the student's ID hash code,
  // otherwise return reserved ID(20051120000) hash code
  int SearchInfo(string ID);
 }


 class Student
 {
 // Fields
  private string _ID;
  private string _name;
  private string _gender;
  private string _classNum;
  private string _specialty;
  private System.DateTime _bday;
 
 // Properties
  public string ID
  {
   get
   {
    return _ID;
   }
   set
   {
    _ID = value;
   }
  }

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

  public string Gender
  {
   get
   {
    return _gender;
   }
   set
   {
    _gender = value;
   }
  }

  public string ClassNum
  {
   get
   {
    return _classNum;
   }
   set
   {
    _classNum = value;
   }
  }

  public string Specialty
  {
   get
   {
    return _specialty;
   }
   set
   {
    _specialty = value.ToString();
   }
  }

  public string BDay
  {
   get
   {
    return _bday.ToShortDateString();
   }
   set
   {
    _bday = System.DateTime.Parse(value);
   }
  }
 
 // Constructors
  public Student(string id, string name, string gender,
          string classNum, string specialty, string bday)
  {
   _ID = id;
   _name = name;
   _gender = gender;
   _classNum = classNum;
   _specialty = specialty;
   _bday = System.DateTime.Parse(bday);
  }
 

 }

 class StudentIMP : IStudentIMP
 {
 // Fileds
  private static string[] _mainMenu; // function description
  private static string