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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
52
Online Gokkantoor/Globals/Globals.csproj
Normal file
52
Online Gokkantoor/Globals/Globals.csproj
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{3643BC50-8412-4C17-99E0-9D4BF7EDEB78}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Globals</RootNamespace>
|
||||
<AssemblyName>Globals</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MyClass.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Classes\Bet.cs" />
|
||||
<Compile Include="Classes\Game.cs" />
|
||||
<Compile Include="Classes\Person.cs" />
|
||||
<Compile Include="Classes\Ploeg.cs" />
|
||||
<Compile Include="Interfaces\IBet.cs" />
|
||||
<Compile Include="Interfaces\IData.cs" />
|
||||
<Compile Include="Interfaces\IGame.cs" />
|
||||
<Compile Include="Interfaces\ILogic.cs" />
|
||||
<Compile Include="Interfaces\IPerson.cs" />
|
||||
<Compile Include="Interfaces\IPloeg.cs" />
|
||||
<Compile Include="main.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Classes\" />
|
||||
<Folder Include="Interfaces\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
18
Online Gokkantoor/Globals/Interfaces/IBet.cs
Normal file
18
Online Gokkantoor/Globals/Interfaces/IBet.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using Globals.classes;
|
||||
using static Globals.main;
|
||||
|
||||
namespace Globals.Interfaces
|
||||
{
|
||||
public interface IBet
|
||||
{
|
||||
int Id { get; set; }
|
||||
Game game { get; set; }
|
||||
Person person { get; set; }
|
||||
double cash { get; set; }
|
||||
bool succes { get; }
|
||||
state ploeg { get; set; }
|
||||
bool finished { get; set; }
|
||||
double getProfit();
|
||||
}
|
||||
}
|
18
Online Gokkantoor/Globals/Interfaces/IData.cs
Normal file
18
Online Gokkantoor/Globals/Interfaces/IData.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Globals.classes;
|
||||
|
||||
namespace Globals.Interfaces
|
||||
{
|
||||
public interface IData
|
||||
{
|
||||
List<Person> getPersons();
|
||||
List<Game> getGames();
|
||||
List<Ploeg> getPloegen();
|
||||
List<Bet> getBets();
|
||||
void saveBets(List<Bet> b);
|
||||
void saveGames(List<Game> g);
|
||||
void savePloegen(List<Ploeg> p);
|
||||
void savePersons(List<Person> p);
|
||||
}
|
||||
}
|
15
Online Gokkantoor/Globals/Interfaces/IGame.cs
Normal file
15
Online Gokkantoor/Globals/Interfaces/IGame.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using Globals.classes;
|
||||
using static Globals.main;
|
||||
|
||||
namespace Globals.Interfaces
|
||||
{
|
||||
public interface IGame
|
||||
{
|
||||
int Id { get; set; }
|
||||
Ploeg home { get; set; }
|
||||
Ploeg away { get; set; }
|
||||
DateTime date { get; set; }
|
||||
state getWinner();
|
||||
}
|
||||
}
|
25
Online Gokkantoor/Globals/Interfaces/ILogic.cs
Normal file
25
Online Gokkantoor/Globals/Interfaces/ILogic.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Globals.classes;
|
||||
|
||||
namespace Globals.Interfaces
|
||||
{
|
||||
public interface ILogic
|
||||
{
|
||||
List<Person> persons { get; set; }
|
||||
List<Bet> bets { get; set; }
|
||||
List<Ploeg> ploegen { get; set; }
|
||||
List<Game> games { get; set; }
|
||||
Person getPerson(int id);
|
||||
Bet getBet(int id);
|
||||
Ploeg getPloeg(int id);
|
||||
Game getGame(int id);
|
||||
void addPloeg(Ploeg p);
|
||||
void addGame(Game g);
|
||||
void addBet(Bet b);
|
||||
void addPerson(Person p);
|
||||
void save();
|
||||
void updateGame(Game g);
|
||||
void updatePerson(Person p);
|
||||
}
|
||||
}
|
14
Online Gokkantoor/Globals/Interfaces/IPerson.cs
Normal file
14
Online Gokkantoor/Globals/Interfaces/IPerson.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
namespace Globals.Interfaces
|
||||
{
|
||||
public interface IPerson
|
||||
{
|
||||
int Id { get; set; }
|
||||
string name { get; set; }
|
||||
string lastname { get; set; }
|
||||
string adress { get; set; }
|
||||
string gsm { get; set; }
|
||||
double balance { get; set; }
|
||||
|
||||
}
|
||||
}
|
11
Online Gokkantoor/Globals/Interfaces/IPloeg.cs
Normal file
11
Online Gokkantoor/Globals/Interfaces/IPloeg.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
namespace Globals.Interfaces
|
||||
{
|
||||
public interface IPloeg
|
||||
{
|
||||
int Id { get; set; }
|
||||
string naam { get; set; }
|
||||
int score { get; set; }
|
||||
bool scoreSet { get; }
|
||||
}
|
||||
}
|
10
Online Gokkantoor/Globals/MyClass.cs
Normal file
10
Online Gokkantoor/Globals/MyClass.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
namespace Globals
|
||||
{
|
||||
public class MyClass
|
||||
{
|
||||
public MyClass()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
26
Online Gokkantoor/Globals/Properties/AssemblyInfo.cs
Normal file
26
Online Gokkantoor/Globals/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("Globals")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("${AuthorCopyright}")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
9
Online Gokkantoor/Globals/main.cs
Normal file
9
Online Gokkantoor/Globals/main.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
using System;
|
||||
namespace Globals
|
||||
{
|
||||
public class main
|
||||
{
|
||||
public enum state { draw, home, away };
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user