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

In this problem set, you will be creating the Visual Studio solution that is spe

ID: 3628269 • Letter: I

Question

In this problem set, you will be creating the Visual Studio solution that is specified below. Please follow all directions carefully, and be aware that all names are case sensitive.

Your solution must be called ps1 and it must consist of these six projects:

FilterLibrary
FilterTester
ConvertCase
CheckPalindrome
Permutations
Dummy
FilterLibrary should be a class library; the others should be console applications.


FilterTester. The FilterTester project is an interactive test driver for the DLL from the FilterLibrary project. It should contain one source file that contains exactly this code. (The code is at the bottom of the file)

When you have correctly implemented the FilterLibrary project and added a reference from FilterTester to FilterLibrary, this project should behave as specified in the comments. Here are examples of the four test cases in action, with user input in bold.

Case 1:
This is a test
THIS IS A TEST
HeLLO there
HELLO THERE
this is the END
THIS IS THE END

Case 2:
This is a test
this is a test
HeLLO there
hello there
this is the END
this is the end

Case 3:
hello
abba
abba
amanaplanacanalpanama
amanaplanacanalpanama
a ba
a b a
a b a

Case 4:
abc
cba
bca
bac
cab
acb
abc
xy
yx
xy


Filter Library. The FilterLibrary project should be a class library that is implemented so as to make the FilterTester project work as specified. To accomplish this, you will need to have a class called Filters defined inside a namespace called FilterLibrary. The class will need five methods (ConvertCase, CheckPalindrome, Permutations, WriteToConsole, and ReadFromConsole) along with any helpers that you deem necessary. All of these classes and methods should be documented so that Intellisense will work back in the FilterTester project.

To get you started, here are implementations of WriteToConsole and ReadFromConsole:

public static void WriteToConsole(IEnumerable<String> lines)
{
foreach (String s in lines)
{
Console.WriteLine(s);
}
}

public static IEnumerable<String> ReadFromConsole()
{
String line;
while ((line = Console.ReadLine()) != null)
{
yield return line;
}
}


These implementations, along with the code from the FilterTester project, should help you specify and implement ConvertCase, CheckPalindrome, and Permutations.

The most difficult method will probably be Permutations. You can benefit greatly from recursion here. You can generate the permutations of a string s of length n by splitting it into its first n-1 characters (call those r) and its last character (call it c). For each permutation p of r (there's the recursion), you can generate permutations of s by inserting c into every possible position in p.


ConvertCase. You are to implement this project so that when its executable is run from the command line with the command-line parameter "upper", user interactions such as in Case 1 above are possible. When its executable is run any other way, user interactions such as in Case 2 above should be possible. This will require very little code!


CheckPalindrome. You are to implement this project so that when its executable is run from the command line, user interactions such as in Case 3 above are possible. This will require very little code!


Permutations. You are to implement this project so that when its executable is run from the command line, user interactions such as in Case 4 above are possible. This will require very little code!


Dummy. For this, create a project and don't touch the default code you're given. Add references to Permutations, CheckPalindrome, ConvertCase, and FilterLibrary. This will gather three executables as well as one DLL into Dummy's Debug/bin directory. If you visit that directory via a shell window, you'll be able to experiment with pipes. For example, try

ConvertCase upper | CheckPalindrome | Permutations | ConvertCase lower



HERE IS THE CODE FOR THE FILETESTER

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FilterLibrary;

namespace FilterTester
{
/// <summary>
/// Interactive test driver for the FilterLibrary
/// </summary>
public class TestCode
{
/// <summary>
/// Only one of these four test cases should be used per run. The rest should stay
/// commented out.
/// </summary>
public static void Main(string[] args)
{
// (1) This should read lines from the console and write them back with all letters
// converted to upper case.
//Filters.WriteToConsole(Filters.ConvertCase(Filters.ReadFromConsole(), true));

// (2) This should read lines from the console and write them back with all letters
// converted to lower case.
//Filters.WriteToConsole(Filters.ConvertCase(Filters.ReadFromConsole(), false));

// (3) This should read lines from the console but write back only those lines that
// are palindromes (are exactly the same, including case, forwards and backwards).
//Filters.WriteToConsole(Filters.CheckPalindrome(Filters.ReadFromConsole()));

// (4) This should read lines from the console and, for every line read, write back
// all of the permutations of that line.
Filters.WriteToConsole(Filters.Permutations(Filters.ReadFromConsole()));

Console.WriteLine("Press Enter to close");
Console.ReadLine();
}

}

}

Explanation / Answer

public static IEnumerable Permutations(IEnumerable iEnumerable) { List outList = new List(); foreach (String s in iEnumerable) { if (s.Length > 1) { string firstChar = s.Substring(0, 1); string allTheRest = s.Substring(1); List recursivePermutationsIn = new List(); recursivePermutationsIn.Add(allTheRest); IEnumerable recursivePermutationsOut = Permutations(recursivePermutationsIn); foreach( string s2 in recursivePermutationsOut ) { for (int x = 0; x
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