81 lines
2.0 KiB
C#
81 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.Intrinsics.X86;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace StudentenDatenbank
|
|
{
|
|
internal class Datenbank
|
|
{
|
|
private Student[] studenten;
|
|
|
|
public Datenbank(int anzahl)
|
|
{
|
|
studenten = new Student[anzahl];
|
|
}
|
|
public bool AddStudent(Student student)
|
|
{
|
|
for (int i = 0; i < studenten.Length; i++)
|
|
{
|
|
if (studenten[i] == null)
|
|
{
|
|
studenten[i] = student;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
public bool RemoveStudent(Student student)
|
|
{
|
|
for (int i = 0; i < studenten.Length; i++)
|
|
{
|
|
if (studenten[i] == student)
|
|
{
|
|
studenten[i] = null;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
public bool RemoveStudent (int martrieklNr)
|
|
{
|
|
for (int i = 0; i < studenten.Length; i++)
|
|
{
|
|
if (studenten[i] != null)
|
|
{
|
|
if (studenten[i].GetMatrikelNr() == martrieklNr)
|
|
{
|
|
studenten[i] = null;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
public int CountStudents()
|
|
{
|
|
int cnt = 0;
|
|
for (int i = 0; i < studenten.Length; i++)
|
|
{
|
|
if (studenten[i] != null)
|
|
{
|
|
cnt++;
|
|
}
|
|
}
|
|
return cnt;
|
|
}
|
|
public void PrintMe()
|
|
{
|
|
for (int i = 0; i < studenten.Length; i++)
|
|
{
|
|
if (studenten[i] != null)
|
|
{
|
|
studenten[i].PrintMe();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|