wk2/utility classes.zip
ApplicationUtilities.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CIS247A_Employee
{
public class ApplicationUtilities
{
public static void DisplayApplicationInformation()
{
Console.WriteLine("Welcome the Basic Employee Program");
Console.WriteLine("CIS247a, Week 2 Lab");
Console.WriteLine("Name: Tevis Boulware");
Console.WriteLine("This program accepts user input as a string, then makes the \nappropriate data conversion and assigns the value to Employee objects");
Console.WriteLine();
}
public static void DisplayDivider(string outputTitle)
{
Console.WriteLine("\n********* " + outputTitle + " *********\n");
}
public static void TerminateApplication()
{
DisplayDivider("Program Termination");
Console.Write("Thank you. Press any key to terminate the program...");
Console.ReadLine();
}
public static void PauseExecution()
{
Console.Write("\nProgram paused, press any key to continue...");
Console.ReadLine();
Console.WriteLine();
}
}
}
InputUtilities.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CIS247A_Employee
{
public class InputUtilities
{
public static string GetInput(string inputType)
{
string strInput = String.Empty;
Console.Write("Enter the " + inputType + ": ");
strInput = Console.ReadLine();
return strInput;
}
public static string getStringInputValue(string inputType)
{
string value = String.Empty;
bool valid = false;
string inputString = String.Empty;
do
{
inputString = GetInput(inputType);
if (!String.IsNullOrEmpty(inputString))
{
value = inputString;
valid = true;
}
else
{
value = "Invalid input";
valid = false;
}
if (!valid)
Console.WriteLine("Invalid " + inputType + " try again!");
} while (!valid);
return value;
}
public static int getIntegerInputValue(string inputType)
{
bool valid = false;
int value = 0;
string inputString = String.Empty;
do
{
inputString = GetInput(inputType);
if (!(String.IsNullOrEmpty(inputString)))
{
valid = Int32.TryParse(inputString, out value);
}
if (!valid.
1. wk2/utility classes.zip
ApplicationUtilities.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CIS247A_Employee
{
public class ApplicationUtilities
{
public static void DisplayApplicationInformation()
{
Console.WriteLine("Welcome the Basic Employee
Program");
Console.WriteLine("CIS247a, Week 2 Lab");
Console.WriteLine("Name: Tevis Boulware");
Console.WriteLine("This program accepts user input as
2. a string, then makes the nappropriate data conversion and
assigns the value to Employee objects");
Console.WriteLine();
}
public static void DisplayDivider(string outputTitle)
{
Console.WriteLine("n********* " + outputTitle + "
*********n");
}
public static void TerminateApplication()
{
DisplayDivider("Program Termination");
Console.Write("Thank you. Press any key to terminate
the program...");
Console.ReadLine();
}
public static void PauseExecution()
{
Console.Write("nProgram paused, press any key to
continue...");
4. Console.Write("Enter the " + inputType + ": ");
strInput = Console.ReadLine();
return strInput;
}
public static string getStringInputValue(string inputType)
{
string value = String.Empty;
bool valid = false;
string inputString = String.Empty;
do
{
inputString = GetInput(inputType);
if (!String.IsNullOrEmpty(inputString))
{
value = inputString;
valid = true;
}
5. else
{
value = "Invalid input";
valid = false;
}
if (!valid)
Console.WriteLine("Invalid " + inputType + " try
again!");
} while (!valid);
return value;
}
public static int getIntegerInputValue(string inputType)
{
bool valid = false;
int value = 0;
string inputString = String.Empty;
do
6. {
inputString = GetInput(inputType);
if (!(String.IsNullOrEmpty(inputString)))
{
valid = Int32.TryParse(inputString, out value);
}
if (!valid)
Console.WriteLine("Invalid " + inputType + " try
again!");
} while (!valid);
return value;
}
public static double getDoubleInputValue(string
inputType)
{
bool valid = false;
double value = 0;
string inputString = String.Empty;
7. do
{
inputString = GetInput(inputType);
if (!(String.IsNullOrEmpty(inputString)))
{
valid = Double.TryParse(inputString, out value);
}
if (!valid)
Console.WriteLine("Invalid " + inputType + " try
again!");
} while (!valid);
return value;
}
public static char getCharInputValue(string inputType)
{
bool valid = false;
char value = 'u';
string inputString = String.Empty;
8. do
{
inputString = GetInput(inputType);
if (!(String.IsNullOrEmpty(inputString)))
{
valid = Char.TryParse(inputString, out value);
}
if (!valid)
Console.WriteLine("Invalid " + inputType + " try
again!");
} while (!valid);
return value;
}
}
}
9. wk2/wk2.docx
1. Download the Utility Classes file, which is a zip file that
contains two classes (1) ApplicationUtilities.cs and (2)
InputUtilities.cs. Unzip the two files and place the files in a
known location.
2. Create a new project called
"CIS247_WK2_Lab_LASTNAME". An empty project will then
be created.
3. Right click the project name in the
Solution
Explorer, or select the Project Menu, and select "Add Existing
Item"
4. Navigate to the folder where you saved the (1)
ApplicationUtilities.cs and (2) InputUtilities.cs class files,
select the files, and then click add.
5. The files will be added to your project.
6. The final step is to change the name of the Namespace so all
the classes in the project can recognize each other (there are
advanced ways around this, but for this course may be easiest to
change the namespace. In order to make it easier for the follow
on weeks, change the namespace to all the classes to
"Employee". The file list in the