mirror of
https://github.com/bvanroll/cs-oo-project.git
synced 2025-08-29 20:12:40 +00:00
yup
This commit is contained in:
57
Online Gokkantoor/Globals/Classes/Bet.cs
Normal file
57
Online Gokkantoor/Globals/Classes/Bet.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using Globals.Interfaces;
|
||||
|
||||
namespace Globals.classes
|
||||
{
|
||||
public class Bet : IBet
|
||||
{
|
||||
public Bet(Game game, Person person, double cash, main.state ploeg)
|
||||
{
|
||||
this.game = game;
|
||||
this.person = person;
|
||||
this.cash = cash;
|
||||
this.ploeg = ploeg;
|
||||
this.finished = false;
|
||||
}
|
||||
public int Id { get; set; }
|
||||
public Game game { get; set; }
|
||||
public Person person { get; set; }
|
||||
public double cash { get; set; }
|
||||
public bool succes { get { return (ploeg == game.getWinner());}}
|
||||
public main.state ploeg { get; set; }
|
||||
public bool finished { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
Bet b = (Bet)obj;
|
||||
return b.game == this.game && this.person == b.person && b.cash == this.cash && this.ploeg == b.ploeg;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public double getProfit()
|
||||
{
|
||||
double tmp = 0;
|
||||
if (finished)
|
||||
{
|
||||
if (succes)
|
||||
{
|
||||
tmp += cash * 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("GAME NOT FINISHED DUH");
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return person.ToString() + ":" + this.cash + "$ on " + this.game.ToString();
|
||||
}
|
||||
}
|
||||
}
|
89
Online Gokkantoor/Globals/Classes/Game.cs
Normal file
89
Online Gokkantoor/Globals/Classes/Game.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using Globals.Interfaces;
|
||||
using static Globals.main;
|
||||
|
||||
namespace Globals.classes
|
||||
{
|
||||
public class Game : IGame
|
||||
{
|
||||
public DateTime date { get; set; } //y m d
|
||||
public Game(Ploeg home, Ploeg away, DateTime d)
|
||||
{
|
||||
this.home = home;
|
||||
this.away = away;
|
||||
this.date = d;
|
||||
}
|
||||
public Game(Ploeg home, Ploeg away, DateTime d, int scoreHome, int scoreAway)
|
||||
{
|
||||
this.home = home;
|
||||
this.away = away;
|
||||
this.home.score = scoreHome;
|
||||
this.away.score = scoreAway;
|
||||
this.date = d;
|
||||
}
|
||||
public Game(int id, Ploeg home, Ploeg away)
|
||||
{
|
||||
Id = id;
|
||||
this.home = home ?? throw new ArgumentNullException(nameof(home));
|
||||
this.away = away ?? throw new ArgumentNullException(nameof(away));
|
||||
}
|
||||
|
||||
public Game(int id, Ploeg home, Ploeg away, int scoreHome, int scoreAway)
|
||||
{
|
||||
Id = id;
|
||||
this.home = home ?? throw new ArgumentNullException(nameof(home));
|
||||
this.away = away ?? throw new ArgumentNullException(nameof(away));
|
||||
this.home.score = scoreHome;
|
||||
this.away.score = scoreAway;
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public Ploeg home { get; set; }
|
||||
public Ploeg away { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public state getWinner()
|
||||
{
|
||||
if (!this.home.scoreSet || !this.away.scoreSet)
|
||||
{
|
||||
if (this.home.score > this.away.score) return state.home;
|
||||
else if (this.away.score > this.home.score) return state.away;
|
||||
else return state.draw;
|
||||
} else
|
||||
{
|
||||
throw new Exception("No scores were set yet. Please set scores for the game first.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
Game g = (Game)obj;
|
||||
return this.home == g.away;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.home.ToString() + " / " + this.away.ToString();
|
||||
}
|
||||
}
|
||||
}
|
40
Online Gokkantoor/Globals/Classes/Person.cs
Normal file
40
Online Gokkantoor/Globals/Classes/Person.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using Globals.Interfaces;
|
||||
|
||||
namespace Globals.classes
|
||||
{
|
||||
public class Person : IPerson
|
||||
{
|
||||
public Person( string name, string lastname, string adress, string gsm, double balance)
|
||||
{
|
||||
this.name = name;
|
||||
this.lastname = lastname;
|
||||
this.adress = adress;
|
||||
this.gsm = gsm;
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public string name { get; set; }
|
||||
public string lastname { get; set; }
|
||||
public string adress { get; set; }
|
||||
public string gsm { get; set; }
|
||||
public double balance { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
Person p = (Person)obj;
|
||||
return this.Id == p.Id;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.name + " " + this.lastname;
|
||||
}
|
||||
}
|
||||
}
|
47
Online Gokkantoor/Globals/Classes/Ploeg.cs
Normal file
47
Online Gokkantoor/Globals/Classes/Ploeg.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using Globals.Interfaces;
|
||||
|
||||
namespace Globals.classes
|
||||
{
|
||||
public class Ploeg : IPloeg
|
||||
{
|
||||
public Ploeg(string naam)
|
||||
{
|
||||
this.naam = naam;
|
||||
this.score = int.MinValue;
|
||||
|
||||
}
|
||||
|
||||
public Ploeg(string naam, int score) : this(naam)
|
||||
{
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public string naam { get; set; }
|
||||
public int score { get; set; }
|
||||
public bool scoreSet { get => this.score != int.MinValue; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
Ploeg t = (Ploeg)obj;
|
||||
return this.Id == t.Id;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string score = "";
|
||||
if (this.score != int.MinValue)
|
||||
{
|
||||
score = ":" + this.score;
|
||||
}
|
||||
return this.naam + score;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user