Advertisement
Kwintendr

Untitled

Jan 19th, 2013
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 3.34 KB | None | 0 0
  1. // PronostiekTest.java
  2. import java.util.*;
  3.  
  4.  
  5.  
  6. class Ploeg {
  7.     private String naam;
  8.     protected int nummer=0;
  9.     static int nummer1 = 0;
  10.  
  11.     public Ploeg(String n) {
  12.         naam = n;
  13.         nummer1 = nummer1 + 1;
  14.         this.nummer = nummer1;
  15.     }
  16.  
  17.     public String toString() {
  18.         return "<" + nummer + "> " + naam;
  19.     }
  20.    
  21.     public boolean isGelijk(Ploeg a){
  22.         boolean vlag = false;
  23.         if (a.nummer==this.nummer) vlag = true;
  24.        
  25.         return vlag;
  26.     }
  27. }
  28.  
  29. class Koppel {
  30.     private Ploeg thuis;
  31.     private Ploeg bezoek;
  32.  
  33.     public Koppel(Ploeg t, Ploeg b) {
  34.         thuis = t;
  35.         bezoek = b;
  36.     }
  37.  
  38.     public Ploeg geefThuis() {
  39.         return thuis;
  40.     }
  41.  
  42.     public Ploeg geefBezoek() {
  43.         return bezoek;
  44.     }
  45.  
  46.     public String toString() {
  47.         return "\n" + thuis + " <-> " + bezoek;
  48.     }
  49.    
  50.     public boolean isGelijk(){
  51.         boolean vlag = false;
  52.         if (thuis.isGelijk(bezoek)==true) vlag = true;
  53.         return vlag;
  54.        
  55.     }
  56. }
  57.  
  58. class Match {
  59.     protected Koppel ploegen;
  60.     protected int resThuis = -2;
  61.     protected int resBezoek = -2;
  62.  
  63.     public Match(Ploeg t, Ploeg b) {
  64.         ploegen = new Koppel(t, b);
  65.     }
  66.    
  67.     public Match(Ploeg t, Ploeg b, int rT, int rB){
  68.         ploegen = new Koppel(t, b);
  69.         resThuis = rT;
  70.         resBezoek = rB;
  71.     }
  72.    
  73.     public boolean isGelijk(Match a){
  74.         boolean vlag = false;
  75.        
  76.         if (a.ploegen.geefThuis() == this.ploegen.geefThuis()){
  77.             if (a.ploegen.geefBezoek() == this.ploegen.geefBezoek()) vlag = true;
  78.         }
  79.        
  80.         return vlag;
  81.     }
  82.    
  83.     public int getResult (){
  84.         int a = -2;
  85.         if (this.resThuis==this.resBezoek) a = 0;
  86.         else if (this.resThuis<this.resBezoek) a = -1;
  87.         else if (this.resThuis>this.resBezoek) a = 1;
  88.        
  89.         return a;
  90.     }
  91.    
  92.     public void setResult(int rT, int rB) {
  93.         resThuis = rT;
  94.         resBezoek = rB;
  95.     }
  96.  
  97.     public String toString() {
  98.         return ploegen.toString() + "\t\t-----Res : " + resThuis + " - "
  99.                 + resBezoek;
  100.     }
  101.  
  102.     public Koppel getKoppel() {
  103.         return ploegen;
  104.     }
  105. }
  106.  
  107. class Pronostiek {
  108.     private Koppel ploegen;
  109.     private int prognose; // -1, 0, of 1;
  110.  
  111.     public Pronostiek(Ploeg t, Ploeg b, int r) {
  112.         ploegen = new Koppel(t, b);
  113.         prognose = r;
  114.     }
  115.  
  116.     public Koppel getKoppel() {
  117.         return ploegen;
  118.     }
  119.  
  120.     public int geefPrognose() {
  121.         return prognose;
  122.     }
  123. }
  124.  
  125. class Competitie{
  126.     private ArrayList<Ploeg> Ploegen = new ArrayList<Ploeg>();
  127.     private ArrayList<Match> Matchen = new ArrayList<Match>();
  128.     private int jaartal;
  129.    
  130.     public Competitie (int jaartal){
  131.         this.jaartal = jaartal;
  132.     }
  133.    
  134.     public void voegToe(Ploeg P){
  135.        
  136.         for (int i = 0; i<Ploegen.size(); i++){
  137.             Matchen.add(new Match(P, Ploegen.get(i)));
  138.             Matchen.add(new Match(Ploegen.get(i), P));
  139.         }
  140.        
  141.         Ploegen.add(P);
  142.     }
  143.    
  144.     public void setResult(Match m, int thuis, int bezoek){
  145.         for (int i =0; i<Matchen.size(); i++) {
  146.             if (m.isGelijk(Matchen.get(i))) {
  147.             Matchen.get(i).setResult(thuis, bezoek);
  148.             }
  149.             }
  150.    
  151.     }
  152.    
  153.     public boolean correcteGok(Pronostiek P){
  154.         Ploeg A = P.getKoppel().geefBezoek();
  155.         Ploeg B = P.getKoppel().geefThuis();
  156.         Match C= new Match(B,A);
  157.         boolean vlag = false;
  158.         for (int i = 0; i<Matchen.size(); i++){
  159.             if(C.isGelijk(Matchen.get(i))){
  160.         if(P.geefPrognose()==Matchen.get(i).getResult()) vlag = true;
  161.         }
  162.         }
  163.         return vlag;
  164.     }
  165.    
  166.     public String toString(){
  167.        
  168.         String A = "";
  169.         for (int i = 0; i<Matchen.size(); i++){
  170.             A = A+"\n"+Matchen.get(i).toString();
  171.         }
  172.     return A;
  173.    
  174. }
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement