ExampleAttribute.ToString() now ignores ExampleAttribute.Difficulty if it is zero. Simplified ExampleAttribute constructors.

This commit is contained in:
the_fiddler 2008-01-18 13:59:26 +00:00
parent 3930dce721
commit 65019c5c53

View file

@ -19,12 +19,11 @@ namespace Examples
public readonly int Difficulty; public readonly int Difficulty;
public readonly bool Visible = true; public readonly bool Visible = true;
public ExampleAttribute(string title, ExampleCategory category)
: this(title, category, 0, true) { }
public ExampleAttribute(string title, ExampleCategory category, int difficulty) public ExampleAttribute(string title, ExampleCategory category, int difficulty)
{ : this(title, category, difficulty, true) { }
this.Title = title;
this.Category = category;
this.Difficulty = difficulty;
}
public ExampleAttribute(string title, ExampleCategory category, int difficulty, bool visible) public ExampleAttribute(string title, ExampleCategory category, int difficulty, bool visible)
{ {
@ -36,17 +35,20 @@ namespace Examples
public override string ToString() public override string ToString()
{ {
return String.Format("{0} {1}: {2}", Category, Difficulty, Title); if (Difficulty != 0)
return String.Format("{0} {1}: {2}", Category, Difficulty, Title);
return String.Format("{0}: {1}", Category, Title);
} }
} }
public enum ExampleCategory public enum ExampleCategory
{ {
OpenGL, OpenGL = 0,
OpenAL, OpenAL,
Tutorial, Tutorial,
GLSL, GLSL,
WinForms, WinForms,
Test, Test,
Last
} }
} }