将代码补充完整 using System; using System.Collections.Generic; using System.Text; namespace one { /// <summary> /// 班级 /// </summary> class Classes { private int _count;//学生人数 private int _size;//允许存储学生人数的最大值 Student[] Data;//学生信息集 public Classes() { //编写代码 } public int Count { get {return _count;} //编写代码 } /// <summary> /// 增加学生 /// </summary> /// <param name="s">学生</param> public void Add(Student s) { if (_count < _size) { //编写代码 } } /// <summary> /// 删除学生信息 /// </summary> /// <param name="Code">学号</param> public void Delete(string Code) { int i, p; for (i = 0; i < _count && Data[i].code != Code; i++) ; if (i < Count) { for (p = i; p < _count; p++) //编写代码 _count--; } } public Student this[int index] { get { if (index <= Count) return Data[index - 1]; else return null; } } } }
时间: 2024-02-10 09:19:13 浏览: 54
using System;
using System.Collections.Generic;
using System.Text;
namespace one
{
/// <summary>
/// 班级
/// </summary>
class Classes
{
private int _count;//学生人数
private int _size;//允许存储学生人数的最大值
Student[] Data;//学生信息集
public Classes(int size)
{
_count = 0;
_size = size;
Data = new Student[size];
}
public int Count
{
get { return _count; }
}
/// <summary>
/// 增加学生
/// </summary>
/// <param name="s">学生</param>
public void Add(Student s)
{
if (_count < _size)
{
Data[_count++] = s;
}
}
/// <summary>
/// 删除学生信息
/// </summary>
/// <param name="Code">学号</param>
public void Delete(string Code)
{
int i, p;
for (i = 0; i < _count && Data[i].code != Code; i++) ;
if (i < Count)
{
for (p = i; p < _count - 1; p++)
Data[p] = Data[p + 1];
_count--;
}
}
public Student this[int index]
{
get
{
if (index <= Count)
return Data[index - 1];
else
return null;
}
}
}
}
阅读全文