Warning! It seems that you are using Dodona within another webpage, so not everything may work properly. Let your teacher know so that he can solve the problem by adjusting a setting in the learning environment. In the meantime, you can click this link to open Dodona in a new window.
Gesloten addressering
Sign in to test your solution.
import java.util.ArrayList;
public class HashTabel<Sleutel, Waarde> {
public class Paar {
private Sleutel sleutel;
private Waarde waarde;
public Paar(Sleutel sleutel, Waarde waarde) {
this.sleutel = sleutel;
this.waarde = waarde;
}
}
private int aantalWaarden;
private static final int AANTAL_POSITIES = 10;
private ArrayList<Paar> paren;
public HashTabel() {
aantalWaarden = 0;
// TODO
}
public void voegToe(Sleutel sleutel, Waarde waarde) {
// TODO
}
public Waarde zoekOp(Sleutel sleutel) {
// TODO
}
public int getAantalWaarden() {
return aantalWaarden;
}
public static int getAantalPosities() {
return AANTAL_POSITIES;
}
@Override
public String toString() {
StringBuilder output = new StringBuilder();
for (Paar paar : paren) {
if (paar != null) {
output.append("{").append(paar.sleutel).append(", ").append(paar.waarde).append("}");
} else {
output.append("null");
}
output.append(", ");
}
return output.toString();
}
}
You can submit as many times as you like. Only your latest submission will be taken into account.
Sign in to test your solution.