Exemplo n.º 1
0
 public String toString() {
   StringBuffer buf = new StringBuffer();
   BauernhofIterator it = new BauernhofIterator(this.keys);
   Bauernhof b = null;
   buf.append("Map enthaelt: \n");
   while (it.hasNext()) {
     b = it.getNext();
     buf.append("KEY: " + b.getName());
     buf.append('\n');
     buf.append("VALUES:\n" + b.getTraktorList().toString());
     buf.append('\n');
   }
   return buf.toString();
 }
Exemplo n.º 2
0
 public Bauernhof getKey(Traktor t) {
   BauernhofIterator it = new BauernhofIterator(this.keys);
   Bauernhof b = null;
   TraktorList list = null;
   Traktor elem = null;
   while (it.hasNext()) { // first iterate through farms
     b = it.getNext();
     list = b.getTraktorList();
     TraktorIterator traktoren = new TraktorIterator(list);
     while (traktoren.hasNext()) { // next iterate through corresponding lists of tractors
       elem = traktoren.getNext();
       if (elem.getID() == t.getID()) return b;
     }
   }
   return null;
   // returns: if tractor t is in map: corresponding farm b
   //         else: null
 }
Exemplo n.º 3
0
 public TraktorList getTraktorList(Bauernhof b) {
   if (!containsKey(b)) return null;
   return b.getTraktorList();
   // returns: if farm b is in map: corresponding tractor list
   //         else: null
 }