- The console accepts input for a new animal and adds that animal to the zoo.

public static string GetTypes(Type type)
{
StringBuilder typeList = new StringBuilder();
foreach(string at in Enum.GetNames(type))
{
typeList.Append(at + "|");
}
return "|" + typeList.ToString();
}Then, it checks if the return only contains letters and spaces. It contains the following code:
string result = null;
bool found = false;
while (!found)
{
result = ConsoleUtil.ReadStringValue(prompt);
if (Regex.IsMatch(result, @"^[a-zA-Z ]+$"))
{
found = true;
}
else
{
Console.WriteLine(prompt + " must contain only letters or spaces.");
}
}
return result;It contains the following code:
string result = null;
bool found = false;
while (!found)
{
Console.Write(prompt + "] ");
string stringValue = Console.ReadLine().ToLower().Trim();
if (stringValue != string.Empty)
{
result = stringValue;
found = true;
}
else
{
Console.WriteLine(prompt + " must have a value.");
}
}
return result;It contains the following code:
int result = 0;
string stringValue = result.ToString();
bool found = false;
while (!found)
{
stringValue = ConsoleUtil.ReadStringValue(prompt);
if (int.TryParse(stringValue, out result))
{
found = true;
}
else
{
Console.WriteLine(prompt + " must be a whole number.");
}
}
return result;It contains the following code:
double result = 0.0;
string stringValue = result.ToString();
bool found = false;
while (!found)
{
stringValue = ConsoleUtil.ReadStringValue(prompt);
if (double.TryParse(stringValue, out result))
{
found = true;
}
else
{
Console.WriteLine(prompt + " must be either a whole number or a decimal number.");
}
}
return result;It contains the following code:
Gender result = Gender.Female;
string stringValue = result.ToString();
bool found = false;
while (!found)
{
stringValue = ConsoleUtil.ReadAlphabeticValue("Gender");
stringValue = ConsoleUtil.InitialUpper(stringValue);
if (Enum.TryParse<Gender>(stringValue, out result))
{
found = true;
}
else
{
Console.WriteLine("Invalid gender. Possible gender types: " + GetTypes(typeof(Gender)));
}
}
return result;
The sequence of method calls will end up looking like the diagram below.

Pass in any values you want for the age, name, weight, and gender.
It takes a zoo as a parameter and returns void. Add a case in ProcessAddCommand for "guest" and call the AddGuest method in it.

Create a guest and then prompt the user for the following properties. You will need to create a method to read the wallet color enum.
A Name prompt should appear. Typing the following values for the various properties should result in the guest being added to the zoo and shown to the console.
The console should continuously ask the user to enter a value while the value is invalid.

For example:
comoZoo.AddAnimal(AnimalFactory.CreateAnimal(AnimalType.Chimpanzee, "Bobo", 3, 50.0, Gender.Male));Console.WriteLine("Invalid animal type. Possible animal types: " + GetTypes(typeof(AnimalType)));Pass in the animal type returned from the ReadAnimalType method for the first parameter.
Ensure you get an error message that displays the list of animal types to instantiate.
Enum.GetValues(typeof(AnimalType))(AnimalType)this.animalTypeComboBox.SelectedItemIn the catch, show a MessageBox with a message telling the user an animal must be selected before adding an animal to the zoo.
this.pregnancyStatusLabel.Content = this.animal.IsPregnant ? "Yes" : "No";The default values passed into the CreateAnimal method should appear in the AnimalWindow.
Inside the method it should call the Remove method on the animals list, passing in the animal parameter.



Pass in the zoo and the second and third items in the commandWords array.
You'll need to also add a RemoveGuest method to the ConsoleHelper and a case for "guest" in the ProcessRemoveCommand method.

© 2026 Northcentral Technical College