add Programmyday form github
This commit is contained in:
80
StudentenDatenbank/Datenbank.cs
Normal file
80
StudentenDatenbank/Datenbank.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user