mirror of
https://github.com/bvanroll/cs-oo-project.git
synced 2025-08-29 20:12:40 +00:00
Deep Shallow copy moe nog gebeuren
This commit is contained in:
@@ -9,7 +9,7 @@ namespace Globals.classes
|
||||
{
|
||||
|
||||
[JsonConstructor]
|
||||
public Game(int Id, Ploeg home, Ploeg away, DateTime date)
|
||||
public Game(int Id, PloegInMatch home, PloegInMatch away, DateTime date)
|
||||
{
|
||||
homeSetBool = false;
|
||||
awaySetBool = false;
|
||||
@@ -21,7 +21,7 @@ namespace Globals.classes
|
||||
this.away.scoreChanged += awaySet;
|
||||
this.date = date;
|
||||
}
|
||||
public Game(Ploeg home, Ploeg away, DateTime d)
|
||||
public Game(PloegInMatch home, PloegInMatch away, DateTime d)
|
||||
{
|
||||
homeSetBool = false;
|
||||
awaySetBool = false;
|
||||
@@ -38,15 +38,15 @@ namespace Globals.classes
|
||||
homeSetBool = false;
|
||||
awaySetBool = false;
|
||||
|
||||
this.home = home;
|
||||
this.away = away;
|
||||
this.home = (PloegInMatch) home; //cast de oorspronkelijke klasse naar deze subklasse
|
||||
this.away = (PloegInMatch) away;
|
||||
this.home.scoreChanged += homeSet;
|
||||
this.away.scoreChanged += awaySet;
|
||||
this.home.setScore(scoreHome);
|
||||
this.away.setScore(scoreAway);
|
||||
this.date = d;
|
||||
}
|
||||
public Game(int id, Ploeg home, Ploeg away)
|
||||
public Game(int id, PloegInMatch home, PloegInMatch away)
|
||||
{
|
||||
homeSetBool = false;
|
||||
awaySetBool = false;
|
||||
@@ -71,9 +71,9 @@ namespace Globals.classes
|
||||
[JsonProperty("id")]
|
||||
public int Id { get; set; }
|
||||
[JsonProperty("home")]
|
||||
public Ploeg home { get; set; }
|
||||
public PloegInMatch home { get; set; }
|
||||
[JsonProperty("away")]
|
||||
public Ploeg away { get; set; }
|
||||
public PloegInMatch away { get; set; }
|
||||
[JsonProperty("Date")]
|
||||
public DateTime date { get; set; } //y m d
|
||||
|
||||
|
@@ -6,77 +6,28 @@ namespace Globals.classes
|
||||
{
|
||||
public class Ploeg : IPloeg
|
||||
{
|
||||
[JsonConstructor]
|
||||
public Ploeg(int Id, string naam, int score)
|
||||
public Ploeg(int id, string naam)
|
||||
{
|
||||
this.Id = Id;
|
||||
Id = id;
|
||||
this.naam = naam;
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public Ploeg(string naam)
|
||||
public Ploeg(Ploeg p)
|
||||
{
|
||||
this.naam = naam;
|
||||
this.score = int.MinValue;
|
||||
|
||||
this.Id = p.Id;
|
||||
this.naam = p.naam;
|
||||
}
|
||||
|
||||
public Ploeg(string naam, int score) : this(naam)
|
||||
{
|
||||
this.score = score;
|
||||
}
|
||||
public Ploeg(string naam, int score, int Id)
|
||||
{
|
||||
this.score = score;
|
||||
this.naam = naam;
|
||||
this.Id = Id;
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public string naam { get; set; }
|
||||
public int score { get; private set; }
|
||||
public bool scoreSet { get; }
|
||||
|
||||
public event EventHandler scoreChanged;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Ploeg te = (Ploeg)obj;
|
||||
|
||||
} catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Ploeg t = (Ploeg)obj;
|
||||
return this.Id == t.Id;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string score = "";
|
||||
if (this.score != int.MinValue)
|
||||
{
|
||||
score = ":" + this.score;
|
||||
}
|
||||
return this.Id + ": " + this.naam + score;
|
||||
}
|
||||
|
||||
public void setScore(int i)
|
||||
{
|
||||
EventHandler h = scoreChanged;
|
||||
if (null != h) h(this, EventArgs.Empty);
|
||||
this.score = i;
|
||||
}
|
||||
public int getScore()
|
||||
{
|
||||
return this.score;
|
||||
return this.naam;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,37 +5,47 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Globals.Classes
|
||||
namespace Globals.classes
|
||||
{
|
||||
public class PloegInMatch : Ploeg
|
||||
{
|
||||
|
||||
|
||||
public int score;
|
||||
|
||||
public PloegInMatch(int score)
|
||||
public PloegInMatch(int id, string naam) : base(id, naam)
|
||||
{
|
||||
}
|
||||
|
||||
public PloegInMatch(int id, string naam, int score) : base(id, naam)
|
||||
{
|
||||
setScore(score);
|
||||
}
|
||||
|
||||
public PloegInMatch(Ploeg p) : base(p)
|
||||
{
|
||||
this.Id = p.Id;
|
||||
this.naam = p.naam;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public PloegInMatch(Ploeg p, int score) : base(p)
|
||||
{
|
||||
this.Id = p.Id;
|
||||
this.naam = p.naam;
|
||||
setScore(score);
|
||||
|
||||
}
|
||||
|
||||
public int score { get; private set; }
|
||||
public bool scoreSet { get; private set; }
|
||||
public event EventHandler scoreChanged;
|
||||
|
||||
public void setScore(int score)
|
||||
{
|
||||
EventHandler h = scoreChanged;
|
||||
if (null != h) h(this, EventArgs.Empty);
|
||||
this.score = score;
|
||||
this.scoreSet = true;
|
||||
}
|
||||
|
||||
public override zegMijnNaam(string naam)
|
||||
{
|
||||
return "blabla " + naam;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return base.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user