C # experiments [2]

Source: Internet
Author: User
Tags save file

Experimental requirements
1. To achieve a student information management system, including information: School number, name, sex, date of birth, professional, notes and other information.
2. Require that the appropriate data type or custom type be selected for each field in the student information;
3. The design system requires an object-oriented approach to abstract and encapsulate the classes you have analyzed;
4. Define the appropriate access access permissions for each class member that you abstract
5. Define the appropriate public interfaces (attributes and indexers) for each class you abstract.
6. Requirements can be implemented in the system of Student information: Add, delete, modify and query function;
7. Require student information to be saved to a specified text file, which supports the ability to read and write files.



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 [] _addinfo; Add info prompt

private static string [] _saveinfo; Save File prompt

private static string [] _modifyinfo; Modify Menu Prompt

private static string [] _helpinfo; Help infomation

Private Hashtable _stdinfo; Store Student Info

Consturctors

Studentimp ()

{

Initial some prompt info

_mainmenu = new String []{

"1. Add",

"2. Modify",

"3. Drop",

"4 Save file",

"5 Display Info",

"6. Help",

"7. Exit"

};

_helpinfo = new String []{

"1. ID must unique.",

                 "2.  Modify function can ' t change id. if you want to change the  ID,     please drop this record and new one again.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.