mirror of
https://github.com/bvanroll/cs-oo-project.git
synced 2025-08-30 12:32:43 +00:00
euh
This commit is contained in:
@@ -1,10 +1,23 @@
|
|||||||
using System;
|
using System;
|
||||||
using Globals.Interfaces;
|
using Globals.Interfaces;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using static Globals.main;
|
||||||
|
|
||||||
namespace Globals.classes
|
namespace Globals.classes
|
||||||
{
|
{
|
||||||
public class Bet : IBet
|
public class Bet : IBet
|
||||||
{
|
{
|
||||||
|
[JsonConstructor]
|
||||||
|
public Bet(int Id, Game g, Person p, double cash, state ploeg, bool finished)
|
||||||
|
{
|
||||||
|
this.Id = Id;
|
||||||
|
this.game = g;
|
||||||
|
this.person = p;
|
||||||
|
this.cash = cash;
|
||||||
|
this.ploeg = ploeg;
|
||||||
|
this.finished = finished;
|
||||||
|
|
||||||
|
}
|
||||||
public Bet(Game game, Person person, double cash, main.state ploeg)
|
public Bet(Game game, Person person, double cash, main.state ploeg)
|
||||||
{
|
{
|
||||||
this.game = game;
|
this.game = game;
|
||||||
@@ -17,12 +30,25 @@ namespace Globals.classes
|
|||||||
public Game game { get; set; }
|
public Game game { get; set; }
|
||||||
public Person person { get; set; }
|
public Person person { get; set; }
|
||||||
public double cash { get; set; }
|
public double cash { get; set; }
|
||||||
public bool succes { get { return (ploeg == game.getWinner());}}
|
|
||||||
public main.state ploeg { get; set; }
|
public main.state ploeg { get; set; }
|
||||||
public bool finished { get; set; }
|
public bool finished { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public bool succes()
|
||||||
|
{
|
||||||
|
return (ploeg == game.getWinner());
|
||||||
|
}
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Bet be = (Bet)obj;
|
||||||
|
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Bet b = (Bet)obj;
|
Bet b = (Bet)obj;
|
||||||
return this.Id == b.Id;
|
return this.Id == b.Id;
|
||||||
}
|
}
|
||||||
@@ -37,7 +63,7 @@ namespace Globals.classes
|
|||||||
double tmp = 0;
|
double tmp = 0;
|
||||||
if (finished)
|
if (finished)
|
||||||
{
|
{
|
||||||
if (succes)
|
if (succes())
|
||||||
{
|
{
|
||||||
tmp += cash * 2;
|
tmp += cash * 2;
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,21 @@
|
|||||||
using System;
|
using System;
|
||||||
using Globals.Interfaces;
|
using Globals.Interfaces;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using static Globals.main;
|
using static Globals.main;
|
||||||
|
|
||||||
namespace Globals.classes
|
namespace Globals.classes
|
||||||
{
|
{
|
||||||
public class Game : IGame
|
public class Game : IGame
|
||||||
{
|
{
|
||||||
public DateTime date { get; set; } //y m d
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public Game(int Id, Ploeg home, Ploeg away, DateTime date)
|
||||||
|
{
|
||||||
|
this.Id = Id;
|
||||||
|
this.home = home;
|
||||||
|
this.away = away;
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
public Game(Ploeg home, Ploeg away, DateTime d)
|
public Game(Ploeg home, Ploeg away, DateTime d)
|
||||||
{
|
{
|
||||||
this.home = home;
|
this.home = home;
|
||||||
@@ -27,7 +36,6 @@ namespace Globals.classes
|
|||||||
this.home = home ?? throw new ArgumentNullException(nameof(home));
|
this.home = home ?? throw new ArgumentNullException(nameof(home));
|
||||||
this.away = away ?? throw new ArgumentNullException(nameof(away));
|
this.away = away ?? throw new ArgumentNullException(nameof(away));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game(int id, Ploeg home, Ploeg away, int scoreHome, int scoreAway)
|
public Game(int id, Ploeg home, Ploeg away, int scoreHome, int scoreAway)
|
||||||
{
|
{
|
||||||
Id = id;
|
Id = id;
|
||||||
@@ -36,17 +44,14 @@ namespace Globals.classes
|
|||||||
this.home.score = scoreHome;
|
this.home.score = scoreHome;
|
||||||
this.away.score = scoreAway;
|
this.away.score = scoreAway;
|
||||||
}
|
}
|
||||||
|
[JsonProperty("id")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
[JsonProperty("home")]
|
||||||
public Ploeg home { get; set; }
|
public Ploeg home { get; set; }
|
||||||
|
[JsonProperty("away")]
|
||||||
public Ploeg away { get; set; }
|
public Ploeg away { get; set; }
|
||||||
|
[JsonProperty("Date")]
|
||||||
|
public DateTime date { get; set; } //y m d
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public state getWinner()
|
public state getWinner()
|
||||||
{
|
{
|
||||||
@@ -61,27 +66,25 @@ namespace Globals.classes
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Game gam = (Game)obj;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Game ga = (Game)obj;
|
Game ga = (Game)obj;
|
||||||
|
|
||||||
return this.Id == ga.Id;
|
return this.Id == ga.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return base.GetHashCode();
|
return base.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return this.Id + ": " + this.home.ToString() + " / " + this.away.ToString();
|
return this.Id + ": " + this.home.ToString() + " / " + this.away.ToString();
|
||||||
|
@@ -1,10 +1,22 @@
|
|||||||
using System;
|
using System;
|
||||||
using Globals.Interfaces;
|
using Globals.Interfaces;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Globals.classes
|
namespace Globals.classes
|
||||||
{
|
{
|
||||||
public class Person : IPerson
|
public class Person : IPerson
|
||||||
{
|
{
|
||||||
|
[JsonConstructor]
|
||||||
|
public Person (int Id, string name, string lastname, string adress, string gsm, double balance)
|
||||||
|
{
|
||||||
|
this.Id = Id;
|
||||||
|
this.name = name;
|
||||||
|
this.lastname = lastname;
|
||||||
|
this.adress = adress;
|
||||||
|
this.gsm = gsm;
|
||||||
|
this.balance = balance;
|
||||||
|
}
|
||||||
|
|
||||||
public Person( string name, string lastname, string adress, string gsm, double balance)
|
public Person( string name, string lastname, string adress, string gsm, double balance)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@@ -1,10 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
using Globals.Interfaces;
|
using Globals.Interfaces;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Globals.classes
|
namespace Globals.classes
|
||||||
{
|
{
|
||||||
public class Ploeg : IPloeg
|
public class Ploeg : IPloeg
|
||||||
{
|
{
|
||||||
|
[JsonConstructor]
|
||||||
|
public Ploeg(int Id, string naam, int score)
|
||||||
|
{
|
||||||
|
this.Id = Id;
|
||||||
|
this.naam = naam;
|
||||||
|
this.score = score;
|
||||||
|
}
|
||||||
|
|
||||||
public Ploeg(string naam)
|
public Ploeg(string naam)
|
||||||
{
|
{
|
||||||
this.naam = naam;
|
this.naam = naam;
|
||||||
|
@@ -28,6 +28,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="Newtonsoft.Json">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="MyClass.cs" />
|
<Compile Include="MyClass.cs" />
|
||||||
@@ -48,5 +51,8 @@
|
|||||||
<Folder Include="Classes\" />
|
<Folder Include="Classes\" />
|
||||||
<Folder Include="Interfaces\" />
|
<Folder Include="Interfaces\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
@@ -10,7 +10,6 @@ namespace Globals.Interfaces
|
|||||||
Game game { get; set; }
|
Game game { get; set; }
|
||||||
Person person { get; set; }
|
Person person { get; set; }
|
||||||
double cash { get; set; }
|
double cash { get; set; }
|
||||||
bool succes { get; }
|
|
||||||
state ploeg { get; set; }
|
state ploeg { get; set; }
|
||||||
bool finished { get; set; }
|
bool finished { get; set; }
|
||||||
double getProfit();
|
double getProfit();
|
||||||
|
4
Online Gokkantoor/Globals/packages.config
Normal file
4
Online Gokkantoor/Globals/packages.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net47" />
|
||||||
|
</packages>
|
@@ -1 +1 @@
|
|||||||
[{"date":"2015-01-01T00:00:00","Id":0
|
[{"id":0,"home":{"Id":0,"naam":"jfkldjslkfj","score":-2147483648,"scoreSet":false},"away":{"Id":1,"naam":"vdvdvd","score":-2147483648,"scoreSet":false},"Date":"2015-01-01T00:00:00"}]
|
@@ -18,6 +18,10 @@ namespace Logic
|
|||||||
bets = d.getBets();
|
bets = d.getBets();
|
||||||
ploegen = d.getPloegen();
|
ploegen = d.getPloegen();
|
||||||
games = d.getGames();
|
games = d.getGames();
|
||||||
|
if (games == null) games = new List<Game>();
|
||||||
|
if (ploegen == null) ploegen = new List<Ploeg>();
|
||||||
|
if (persons == null) persons = new List<Person>();
|
||||||
|
if (bets == null) bets = new List<Bet>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LogicLayer(bool testMode)
|
public LogicLayer(bool testMode)
|
||||||
@@ -72,6 +76,10 @@ namespace Logic
|
|||||||
public void addGame(Game g)
|
public void addGame(Game g)
|
||||||
{
|
{
|
||||||
games.Add(g);
|
games.Add(g);
|
||||||
|
if (true)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
}
|
||||||
fixIds();
|
fixIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,10 +133,10 @@ namespace Logic
|
|||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
fixIds();
|
fixIds();
|
||||||
d.saveBets(bets);
|
|
||||||
d.saveGames(games);
|
|
||||||
d.savePersons(persons);
|
d.savePersons(persons);
|
||||||
d.savePloegen(ploegen);
|
d.savePloegen(ploegen);
|
||||||
|
d.saveGames(games);
|
||||||
|
d.saveBets(bets);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateGame(Game g)
|
public void updateGame(Game g)
|
||||||
|
Reference in New Issue
Block a user