Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You will create a solution containing two projects: the first project will be a

ID: 3822575 • Letter: Y

Question

You will create a solution containing two projects: the first project will be a class library (DLL), the other will be a console app.

The DLL you create must contain the following extension methods:

void Print() – Targets IEnumerable. Prints out the objects in any collection, separating each value with a comma (,) while making sure there is NO dangling tail symbol.

int ToPower(int exponent) – Targets int. Returns the value of the target int raised to the power of the exponent parameter.

bool IsPalindrome() – Targets string. Returns a bool signifying whether the string is a palindrome (reads backward the same as forward; Bob, racecar, tacocat), ignoring both casing and any whitespace. For example, “tacocat”, “tAcoCaT” and “taco cat” are all the same palindrome.

In addition, you must come up with 3 more extension methods that operate against any of C#’s “baked-in” types.

Your extension methods must be NEW functionality and cannot mimic existing methods or extension methods for the targeted type.

For all of the extension methods, use C# documentation comments (aka the triple-slash comments) to explain what each function does.

The console project must import your DLL and demonstrate all 6 extension methods. Use meaningful console output to prove your methods work.

In the case of IsPalindrome, demonstrate both results (false and true).

Explanation / Answer

public static IEnumerable<string> Permutations(IEnumerable<string> iEnumerable)
{
List<string> outList = new List<string>();
foreach (String s in iEnumerable)
{
if (s.Length > 1)
{
string firstChar = s.Substring(0, 1);
string allTheRest = s.Substring(1);
List<string> recursivePermutationsIn = new List<string>();
recursivePermutationsIn.Add(allTheRest);
IEnumerable<string> recursivePermutationsOut = Permutations(recursivePermutationsIn);
foreach( string s2 in recursivePermutationsOut )
{
for (int x = 0; x <= s2.Length; x++)
{
outList.Add(s2.Insert(x, firstChar));
}
}
}
else
{
outList.Add(s);
}
}
return outList;
}

public static IEnumerable<string> CheckPalindrome(IEnumerable<string> iEnumerable)
{
char[] cArr;
List<string> outList = new List<string>();
foreach (string s in iEnumerable)
{
bool isPalindrome = true;
cArr = s.ToCharArray();
for (int x = 0; x <= (s.Length / 2); x++)
{
if (cArr[x] != cArr[s.Length - (x + 1)])
{
isPalindrome = false;
break;
}
}
if (isPalindrome)
{
outList.Add(s);
}
}
return outList;
}

public static IEnumerable<String> ConvertCase(IEnumerable<string> iEnumerable, bool p)
{
List<string> outList = new List<string>();
foreach (String s in iEnumerable)
{
outList.Add(p ? s.ToUpper() : s.ToLower() );
}
return outList;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote