8using System.Collections.Generic;
53 return String.Format(
"{0,6} {1,3} {2,3}\"",
Name,
Age,
Height);
146 List<EntryInformation> localEntries =
new List<EntryInformation>(
entries);
151 Console.WriteLine(
" {0,6} {1,3} {2,3}",
"Name",
"Age",
"Height");
152 Console.WriteLine(
" {0,6} {1,3} {2,3}",
"------",
"---",
"------");
155 Console.WriteLine(
" {0}", entry);
static EntryInformation entries[]
List of individuals to play around with in the Strategy exercise.
Represents an individual with a Name, Age, and Height.
int Age
Age of this individual, in years.
string Name
Name of this individual.
override string ToString()
Convert the entry into a string. In this case, a formatted string where name, age,...
int Height
Height of this individual, in inches.
EntryInformation(string name, int age, int height)
Constructor.
Represents a way of displaying a list of EntryInformation objects in a particular order....
Strategy_ShowEntries_Class(SortOptions sortOption, bool reversedSort)
Constructor.
bool _reversedSort
Whether to reverse the normal order of the sort.
SortOptions
Identifies the different sorting strategies available.
@ ByAge
Sort numerically by age in ascending order.
@ ByName
Sort alphabetically name in ascending order.
@ ByHeight
Sort numerically by height in ascending order.
void ShowEntries(EntryInformation[] entries)
Display the specified entries in sorted order. The order of the sort was established when the Strateg...
ISortEntries _sortEntries
The sorting strategy to use.
Class constructor for the sorting strategies.
static ISortEntries Create(Strategy_ShowEntries_Class.SortOptions sortOption, bool reversedSort)
Generate an instance of a sorting strategy based on the given sorting option and reversed sort flag....
Represents a sorting strategy.
void Sort(List< EntryInformation > entries)
Sort the specified list of entries in place. A list is used here so we can leverage the List's sortin...
The namespace containing all Design Pattern Examples implemented in C#.