Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: stevenroose on May 7th, 2012  |  syntax: Java  |  size: 1.68 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class TestenPuntenBlad {
  2.  
  3.    
  4.  
  5.  
  6.     public static void main(String[] args) {
  7.         PuntenBlad puntenLijst = new PuntenBlad();
  8.         puntenLijst.voegPuntToe("vak1", 8);
  9.         puntenLijst.voegPuntToe("vak2", 7);
  10.         puntenLijst.voegPuntToe("vak3", 5);
  11.  
  12.         puntenLijst.toonPuntenblad();
  13.         puntenLijst.verwijderPunt(2);
  14.     }
  15. }
  16.  
  17.  
  18. public class PuntenBlad {
  19.     Punt last;
  20.     int number = 0;
  21.     public void voegPuntToe(String vakIn, int aantalPunten) {
  22.             last = new Punt(last, vakIn, aantalPunten);
  23.             number++;
  24.         }
  25.    
  26.    public void toonPuntenblad(){
  27.         Punt startIn = last;
  28.         for (int i=0; startIn != null; i++){
  29.             System.out.println(startIn.getNaam());
  30.             System.out.println(startIn.getResultaat());
  31.             startIn= startIn.getVorige();
  32.         }
  33.    }
  34.    
  35.    public void remove(int index) {
  36.                 Punt toPoint = last;
  37.                 Punt toPointTo = last;
  38.                 for(int i = 1 ; index - 1 < aantalPunten - i ; i++) {
  39.                         toPoint = toPoint.getVorige();
  40.                 }
  41.                 for(int i = 1 ; index + 1 < aantalPunten - i ; i++) {
  42.                         toPointTo = toPointTo.getVorige();
  43.                 }
  44.                 toPoint.setVorig(toPointTo);
  45.    }
  46. }
  47.  
  48. public class Punt {
  49.     int resultaat;
  50.     Punt vorig;
  51.     String naam;
  52.     public Punt(Punt startIn, String naamIn, int resultaatIn) {
  53.         start = startIn;
  54.         resultaat = resultaatIn;
  55.         naam= naamIn;
  56.  
  57.     }
  58.     public int getResultaat(){
  59.         return resultaat;
  60.     }
  61.      public String getNaam(){
  62.         return naam;
  63.     }
  64.       public Punt getVorige(){
  65.         return vorig;
  66.     }
  67.     public void setVorige(Punt vorig) {
  68.         this.vorig = vorig;
  69.     }
  70. }