From 70b004edab722c94e0dd304e279bf1f6f08d6d59 Mon Sep 17 00:00:00 2001 From: Jaculabilis Date: Tue, 15 Mar 2022 17:36:47 -0700 Subject: [PATCH] Define ToString methods on the main models --- MultiversalDiplomacy/Model/Location.cs | 7 +++++++ MultiversalDiplomacy/Model/Power.cs | 5 +++++ MultiversalDiplomacy/Model/Province.cs | 5 +++++ MultiversalDiplomacy/Model/Season.cs | 5 +++++ MultiversalDiplomacy/Model/Unit.cs | 5 +++++ 5 files changed, 27 insertions(+) diff --git a/MultiversalDiplomacy/Model/Location.cs b/MultiversalDiplomacy/Model/Location.cs index a0ecbf9..fe0aae9 100644 --- a/MultiversalDiplomacy/Model/Location.cs +++ b/MultiversalDiplomacy/Model/Location.cs @@ -41,6 +41,13 @@ public class Location this.AdjacentList = new List(); } + public override string ToString() + { + return this.Name == null + ? $"{this.Province.Name} ({this.Type})" + : $"{this.Province.Name} ({this.Type}:{this.Name}]"; + } + /// /// Set another location as bordering this location. /// diff --git a/MultiversalDiplomacy/Model/Power.cs b/MultiversalDiplomacy/Model/Power.cs index ebcb555..ca49120 100644 --- a/MultiversalDiplomacy/Model/Power.cs +++ b/MultiversalDiplomacy/Model/Power.cs @@ -14,4 +14,9 @@ public class Power { this.Name = name; } + + public override string ToString() + { + return this.Name; + } } diff --git a/MultiversalDiplomacy/Model/Province.cs b/MultiversalDiplomacy/Model/Province.cs index eb08ef5..b53d7ae 100644 --- a/MultiversalDiplomacy/Model/Province.cs +++ b/MultiversalDiplomacy/Model/Province.cs @@ -40,6 +40,11 @@ public class Province this.LocationList = new List(); } + public override string ToString() + { + return this.Name; + } + /// /// Create a new province with no supply center. /// diff --git a/MultiversalDiplomacy/Model/Season.cs b/MultiversalDiplomacy/Model/Season.cs index 2c2132a..33b6208 100644 --- a/MultiversalDiplomacy/Model/Season.cs +++ b/MultiversalDiplomacy/Model/Season.cs @@ -64,6 +64,11 @@ public class Season } } + public override string ToString() + { + return $"{this.Turn}:{this.Timeline}"; + } + /// /// Create a root season at the beginning of time. /// diff --git a/MultiversalDiplomacy/Model/Unit.cs b/MultiversalDiplomacy/Model/Unit.cs index 4b89ad6..3a59560 100644 --- a/MultiversalDiplomacy/Model/Unit.cs +++ b/MultiversalDiplomacy/Model/Unit.cs @@ -39,6 +39,11 @@ public class Unit this.Type = type; } + public override string ToString() + { + return $"{this.Power} {this.Type} {this.Location.Province} {this.Season}"; + } + /// /// Create a new unit. No validation is performed; the adjudicator should only call this /// method after accepting a build order.