using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 实验五案例一
{
class student
{
private string name;
private string sex;
private double hight;
private int age;
static private int count=0;
public student()
{
count++;
}
public student(string name, string sex, double hight, int age)
{
this.name = name;
this.sex = sex;
this.hight = hight;
this.age = age;
count++;
}
public void setinfo(string name, string sex, double hight, int age)
{
this.name = name;
this.sex = sex;
this.hight = hight;
this.age = age;
}
public void display()
{
Console.WriteLine("性名:{0}\n性别:{1}\n身高:{2}\n年龄:{3}\n学生总人数:{4}",name,sex,hight,age,count);
}
static public void display(student []a)
{
foreach (student S in a)
{
S.display();
Console.WriteLine();
}
}
static public student changesex(student a)
{
if(a.sex=="男")
{
a.sex="女";
}
else
a.sex="男";
return a;
}
}
class Program
{
static void Main(string[] args)
{
student S1 = new student();
student S2 = new student("李四", "男", 173.5, 20);
student[] S = new student[2];
S[0] = new student("张三", "男", 172, 11);
S[1] = new student("李四", "男", 171, 12);
S1.setinfo("张三","男",174,21);
student.changesex(S1);
S1.display();
Console.WriteLine();
S2.display();
Console.WriteLine();
student.display(S);
Console.ReadLine();
}
}
}