All pastes #346495 Raw Edit

klasse

public text v1 · immutable
·published 2007-02-09 12:37 UTC
rendered paste body
public class Klasse{
  private String[] fach;
  private String stufe;
  private Schueler[] schueler;
  private Lehrer[] lehrer;
  public Klasse(String s, String[] stoff){
    this.fach=(String[])stoff.clone();
    this.stufe=s;
    this.schueler=new Schueler[30];
    for(int i=0; i<30; i++) this.schueler[i]= new Schueler();
    this.lehrer=new Lehrer[5];
    for (int i=0; i<5; i++) this.lehrer[i]= new Lehrer();
  }
  public Klasse(){
    this("", new String[0]);
  }
  public void setStufe(String s){
    this.stufe=s;
    return;
  }
  public String getStufe(){
    return this.stufe;
  }
  public void setFach(String[] stoff){
    this.fach=(String[])stoff.clone();
    return;
  }
  public String[] getFach(){
    return (String[])fach.clone();
  }
  public String stringFach(){
    String s="";
    if (fach.length>0)
    for (int i=0; i<fach.length; i++){
      s=s+", "+this.fach[i];
    }
    else s="keine Fächer";
    return s;
  }
  public boolean neuerSchueler(Schueler k){
    for (int i=0; i<30; i++){
      if ((this.schueler[i]).getVorname().equals("")) {
        this.schueler[i]=k;
        return true;
      }
    }
    return false;
  }
  public boolean neuerLehrer(Lehrer k){
    for (int i=0; i<5; i++){
      if ((this.lehrer[i]).getVorname().equals("")) {
        this.lehrer[i]=k;
        return true;
      }
    }
    return false;
  }
  public boolean streicheSchueler(Schueler k){
    for (int i=0; i<30; i++){
      if (k==this.schueler[i]){
        this.schueler[i]=new Schueler();
        return true;
      }
    }
    return false;
  }
  public boolean streicheLehrer(Lehrer k){
    for (int i=0; i<5; i++){
      if (k==this.lehrer[i]){
        this.lehrer[i]=new Lehrer();
        return true;
      }
    }
    return false;
  }
  public String toString(){
    return this.stufe;
  }
  public boolean sucheSchueler(Schueler k){
    for (int i=0; i<30; i++) if (k==this.schueler[i]) return true;
    return false;
  }
  public boolean sucheLehrer(Lehrer k){
    for (int i=0; i<5; i++) if (k==this.lehrer[i]) return true;
    return false;
  }
  public String alleSchueler(){
    String s="";
    for (int i=0; i<30; i++){
      if (!(this.schueler[i].equals(""))) s=s+this.schueler[i]+"\n";
    }
    return s;
  }
  public String alleLehrer(){
    String s="";
    for (int i=0; i<30; i++){
      if (!(this.lehrer[i].equals(""))) s=s+this.lehrer[i]+"\n";
    }
    return s;
  }
  
}