Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package oefening_zwembad.domein;
- import java.util.Random;
- // VUL DE KLASSE VERDER AAN
- public class Kind implements Runnable {
- private Tafel tafel;
- private Zwembad zwembad;
- private String naam;
- private Random generator = new Random();
- public Kind(Tafel tafel, Zwembad zwembad, String naam) {
- this.tafel = tafel;
- this.zwembad = zwembad;
- this.naam = naam;
- }
- public void run() {
- while(!zwembad.vol() && tafel.pakEmmer()){
- try{
- Thread.sleep(generator.nextInt(1000)+2000);
- System.out.printf("%s heeft een emmer genomen\n", naam);
- }catch(InterruptedException e){
- e.printStackTrace();
- zwembad.gietEmmer();
- }
- System.out.printf("%s : "
- + (zwembad.vol() ? "zwembad vol" : "reeds "
- + zwembad.getInhoud() + " emmers") + "\n", naam);
- }
- }
- }
Add Comment
Please, Sign In to add comment