Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuinny committed Feb 2, 2024
1 parent a08395c commit 12cbd7b
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 333 deletions.
7 changes: 1 addition & 6 deletions Oligopoly.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33530.505
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{E1685C41-EF1E-45FD-9FD5-1C3E769BCA35}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Oligopoly.Game", "Source\Oligopoly.Game\Oligopoly.Game.csproj", "{61F60199-937A-4B87-B5B7-E70318482D95}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Oligopoly.Game", "Source\Oligopoly.Game\Oligopoly.Game.csproj", "{61F60199-937A-4B87-B5B7-E70318482D95}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,9 +19,6 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{61F60199-937A-4B87-B5B7-E70318482D95} = {E1685C41-EF1E-45FD-9FD5-1C3E769BCA35}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DE654BE1-60EF-4C2A-B4E7-783D35FCF7FC}
EndGlobalSection
Expand Down
File renamed without changes.
68 changes: 22 additions & 46 deletions Source/Oligopoly.Game/Code/Company.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,17 @@ public class Company
private decimal sharePrice;
private int numberOfShares;

/// <summary>
/// Gets or sets the name of the company.
/// The name cannot be null or whitespace.
/// </summary>
/// <summary>Gets or sets the name of the company.</summary>
/// <remarks>Name of the company must not be null or whitespace.</remarks>
[XmlElement("Name")]
public string Name
{
get
{
return name;
}
get => name;
set
{
if (string.IsNullOrEmpty(value))
{
throw new Exception("Name cannot be null or whitespace!");
throw new Exception("Name of the company must not be null or whitespace!");
}
else
{
Expand All @@ -32,22 +27,17 @@ public string Name
}
}

/// <summary>
/// Gets or sets the industry of the company.
/// The industry cannot be null or whitespace.
/// </summary>
/// <summary>Gets or sets the industry of the company.</summary>
/// <remarks>Industry of the company must not be null or whitespace.</remarks>
[XmlElement("Industry")]
public string Industry
{
get
{
return industry;
}
get => industry;
set
{
if (string.IsNullOrEmpty(value))
{
throw new Exception("Industry cannot be null or whitespace!");
throw new Exception("Industry of the company must not be null or whitespace!");
}
else
{
Expand All @@ -56,22 +46,17 @@ public string Industry
}
}

/// <summary>
/// Gets or sets the description of the company.
/// The description cannot be null or whitespace.
/// </summary>
/// <summary>Gets or sets the description of the company.</summary>
/// <remarks>Description of the company must not be null or whitespace.</remarks>
[XmlElement("Description")]
public string Description
{
get
{
return description;
}
get => description;
set
{
if (string.IsNullOrEmpty(value))
{
throw new Exception("Description cannot be null or whitespace!");
throw new Exception("Description of the company must not be null or whitespace!");
}
else
{
Expand All @@ -80,22 +65,17 @@ public string Description
}
}

/// <summary>
/// Gets or sets the share price of the company.
/// The share price cannot less than or equal to zero.
/// </summary>
/// <summary>Gets or sets the share price of the company.</summary>
/// <remarks>Share price of the company must be greater than zero.</remarks>
[XmlElement("SharePrice")]
public decimal SharePrice
{
get
{
return sharePrice;
}
get => sharePrice;
set
{
if (value <= 0)
if (value <= 0)
{
throw new Exception("Share Price cannot be less than or equal to zero!");
throw new Exception("Share price of the company must be greater than zero!");
}
else
{
Expand All @@ -104,21 +84,17 @@ public decimal SharePrice
}
}

/// <summary>
/// Gets or sets the number of shares of the company.
/// The number of share cannot be less than or equal to zero.
/// </summary>
/// <summary>Gets or sets the number of shares of the company.</summary>
/// <remarks>Number of shares of the company must not be less than zero.</remarks>
[XmlElement("NumberOfShares")]
public int NumberOfShares
{
get
{
return numberOfShares;
}
get => numberOfShares;
set
{
if (value < 0)
{
throw new Exception("Number of Shares cannot be less than zero!");
throw new Exception("Number of shares of the company must not be less than zero!");
}
else
{
Expand Down
56 changes: 17 additions & 39 deletions Source/Oligopoly.Game/Code/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,17 @@ public class Event
private string title;
private string content;

/// <summary>
/// Gets or sets the effect of the event.
/// That is, the value by which the price of the <see cref="Company.SharePrice"/> should change.
/// The effect cannot be equal to zero.
/// </summary>
/// <summary>Gets or sets the effect of the event, represented as a percentage.</summary>
/// <remarks>Effect of the event must be a non-zero integer.</remarks>
[XmlElement("Effect")]
public int Effect
{
get
{
return effect;
}
get => effect;
set
{
if (value == 0)
{
throw new Exception("Effect cannot be equal to zero!");
throw new Exception("Effect of the event must be a non-zero integer!");
}
else
{
Expand All @@ -32,23 +26,17 @@ public int Effect
}
}

/// <summary>
/// Gets or sets the target of the event.
/// That is, the company to which the <see cref="Event.Effect"/> will be applied.
/// The target cannot be null or whitespace.
/// </summary>
/// <summary>Gets or sets the target company of the event.</summary>
/// <remarks>Target company of the event must not be null or whitespace.</remarks>
[XmlElement("Target")]
public string Target
{
get
{
return target;
}
get => target;
set
{
if (string.IsNullOrWhiteSpace(value))
{
throw new Exception("Target cannot be null or whitespace!");
throw new Exception("Target company of the event must not be null or whitespace!");
}
else
{
Expand All @@ -57,22 +45,17 @@ public string Target
}
}

/// <summary>
/// Gets or sets the title of the event.
/// The title cannot be null or whitespace.
/// </summary>
/// <summary>Gets or sets the title of the event.</summary>
/// <remarks>Title of the event must not be null or whitespace.</remarks>
[XmlElement("Title")]
public string Title
{
get
{
return title;
}
get => title;
set
{
if (string.IsNullOrEmpty(value))
if (string.IsNullOrWhiteSpace(value))
{
throw new Exception("Title cannot be null or whitespace!");
throw new Exception("Title of the event must not be null or whitespace!");
}
else
{
Expand All @@ -81,22 +64,17 @@ public string Title
}
}

/// <summary>
/// Gets or sets the content of the event.
/// The content cannot be null or whitespace.
/// </summary>
/// <summary>Gets or sets the content of the event.</summary>
/// <remarks>Content of the event must not be null or whitespace.</remarks>
[XmlElement("Content")]
public string Content
{
get
{
return content;
}
get => content;
set
{
if (string.IsNullOrWhiteSpace(value))
{
throw new Exception("Content cannot be null or whitespace!");
throw new Exception("Content of the event must not be null or whitespace!");
}
else
{
Expand Down
Loading

0 comments on commit 12cbd7b

Please sign in to comment.