All pastes #821933 Raw Edit

Unbenannt

public java v1 · immutable
·published 2007-12-18 12:28 UTC
rendered paste body
public class Team {// instance variables:private Student[] team;private int zteam; //Zeiger auf Array team = Anzahl der Teammitglieder/**   * Constructor for objects of class Team   */public Team(int maxTeam) {// initialise instance variables team = new Student[maxTeam];zteam=0;}//Team// nicht gefordert: Standard-Team mit Größe 10public Team(){ this(10); }public void add(Student neu) {if(zteam<team.length) {team[zteam] = neu;zteam++;}//if  }//sampleMethodpublic int size(){ return zteam;}public Student get(int index){if(index>=0 &&index<zteam) return team[index];// es könnte auch ein Student objekt ohne Inhalte geliefert werden:// return new Student("","",0);else return null; //kein Objekt - leere Adresse}//getpublic void remove(int index){if(index>=0 &&index<zteam) {for(int i=index;index<zteam-1;index++)team[index] = team[index+1];zteam--; //Ein Mitglied weniger}//if  }//removepublic void ausgabe(){IntIO io = new IntIO();io.writeln("Unser Team:");for(int i=0;i<zteam;i++) io.writeln((i+1)+". "+team[i]);}//ausgabeprivate static void sort(String[] a){    for(int i = a.length - 1; i > 0; i--)    {         for(int j = 0; j < i; j++)         {             if((a[j].compareTo(a[j + 1])) > 0)             {                 String z = a[j];                 a[j] = a[j + 1];                 a[j + 1] = z;             }         }     }}}//Team