-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathData.cs
More file actions
74 lines (63 loc) · 2.56 KB
/
Data.cs
File metadata and controls
74 lines (63 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Linq;
namespace AnimalShelter_Conditional_branching_and_looping
{
class Data
{
public static List<Animal> Animals { get; private set; }
static Data()
{
Animals = new List<Animal>
{
new Animal(1, Species.Dog, 2, "medium sized cream", "belly rubbed", "lola"),
new Animal(2, Species.Dog, 9, "large reddish-brown", "ears rubbed", "loki"),
new Animal(3, Species.Cat, 1, "small white female", "friendly", "Puss"),
new Animal(4, Species.Cat, 3, "medium sized black", "housebroken", "cattie")
};
}
public static void AddAnimal(Animal animal)
{
Animals.Add(animal);
}
public static void EditAnimal(int id, int age)
{
Animals.FirstOrDefault(animal => animal.Id == id)?.EditAge(age);
}
public static void EditAnimal(int id, string personalityDescription)
{
Animals.FirstOrDefault(animal => animal.Id == id)?.EditPersonalityDescription(personalityDescription);
}
public static void DisplayAnimal(Species species, string characteristic)
{
Console.WriteLine($"Given characteristic: {characteristic}");
Console.WriteLine($"Our current {species} information with the given characteristic is:");
var filteredAnimals = Animals.Where(animal => animal.Species == species && animal.CharacteristicDescription.Contains(characteristic));
foreach (var animal in filteredAnimals)
{
Console.WriteLine(animal);
Console.WriteLine();
}
}
public static void EnsureCompletion(string[] characteristics)
{
foreach (var characteristic in characteristics)
{
bool isCharacterIncomplete = Animals.Any(animal => string.IsNullOrEmpty(animal.CharacteristicDescription) || animal.CharacteristicDescription.Contains(characteristic));
if (isCharacterIncomplete)
{
Console.WriteLine($"Please ensure the characteristic description for '{characteristic}' is complete.");
}
}
}
public static void DisplayAllAnimals()
{
Console.WriteLine("Our current pet information is:");
foreach (var animal in Animals)
{
Console.WriteLine(animal);
Console.WriteLine();
}
}
}
}