Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PronostiekTest.java
- import java.util.*;
- class Ploeg {
- private String naam;
- protected int nummer=0;
- static int nummer1 = 0;
- public Ploeg(String n) {
- naam = n;
- nummer1 = nummer1 + 1;
- this.nummer = nummer1;
- }
- public String toString() {
- return "<" + nummer + "> " + naam;
- }
- public boolean isGelijk(Ploeg a){
- boolean vlag = false;
- if (a.nummer==this.nummer) vlag = true;
- return vlag;
- }
- }
- class Koppel {
- private Ploeg thuis;
- private Ploeg bezoek;
- public Koppel(Ploeg t, Ploeg b) {
- thuis = t;
- bezoek = b;
- }
- public Ploeg geefThuis() {
- return thuis;
- }
- public Ploeg geefBezoek() {
- return bezoek;
- }
- public String toString() {
- return "\n" + thuis + " <-> " + bezoek;
- }
- public boolean isGelijk(){
- boolean vlag = false;
- if (thuis.isGelijk(bezoek)==true) vlag = true;
- return vlag;
- }
- }
- class Match {
- protected Koppel ploegen;
- protected int resThuis = -2;
- protected int resBezoek = -2;
- public Match(Ploeg t, Ploeg b) {
- ploegen = new Koppel(t, b);
- }
- public Match(Ploeg t, Ploeg b, int rT, int rB){
- ploegen = new Koppel(t, b);
- resThuis = rT;
- resBezoek = rB;
- }
- public boolean isGelijk(Match a){
- boolean vlag = false;
- if (a.ploegen.geefThuis() == this.ploegen.geefThuis()){
- if (a.ploegen.geefBezoek() == this.ploegen.geefBezoek()) vlag = true;
- }
- return vlag;
- }
- public int getResult (){
- int a = -2;
- if (this.resThuis==this.resBezoek) a = 0;
- else if (this.resThuis<this.resBezoek) a = -1;
- else if (this.resThuis>this.resBezoek) a = 1;
- return a;
- }
- public void setResult(int rT, int rB) {
- resThuis = rT;
- resBezoek = rB;
- }
- public String toString() {
- return ploegen.toString() + "\t\t-----Res : " + resThuis + " - "
- + resBezoek;
- }
- public Koppel getKoppel() {
- return ploegen;
- }
- }
- class Pronostiek {
- private Koppel ploegen;
- private int prognose; // -1, 0, of 1;
- public Pronostiek(Ploeg t, Ploeg b, int r) {
- ploegen = new Koppel(t, b);
- prognose = r;
- }
- public Koppel getKoppel() {
- return ploegen;
- }
- public int geefPrognose() {
- return prognose;
- }
- }
- class Competitie{
- private ArrayList<Ploeg> Ploegen = new ArrayList<Ploeg>();
- private ArrayList<Match> Matchen = new ArrayList<Match>();
- private int jaartal;
- public Competitie (int jaartal){
- this.jaartal = jaartal;
- }
- public void voegToe(Ploeg P){
- for (int i = 0; i<Ploegen.size(); i++){
- Matchen.add(new Match(P, Ploegen.get(i)));
- Matchen.add(new Match(Ploegen.get(i), P));
- }
- Ploegen.add(P);
- }
- public void setResult(Match m, int thuis, int bezoek){
- for (int i =0; i<Matchen.size(); i++) {
- if (m.isGelijk(Matchen.get(i))) {
- Matchen.get(i).setResult(thuis, bezoek);
- }
- }
- }
- public boolean correcteGok(Pronostiek P){
- Ploeg A = P.getKoppel().geefBezoek();
- Ploeg B = P.getKoppel().geefThuis();
- Match C= new Match(B,A);
- boolean vlag = false;
- for (int i = 0; i<Matchen.size(); i++){
- if(C.isGelijk(Matchen.get(i))){
- if(P.geefPrognose()==Matchen.get(i).getResult()) vlag = true;
- }
- }
- return vlag;
- }
- public String toString(){
- String A = "";
- for (int i = 0; i<Matchen.size(); i++){
- A = A+"\n"+Matchen.get(i).toString();
- }
- return A;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement