Stage 0: Initial code
Stage 0: Initial code
Highlights:
Cat, dog, and parrot objects created with specific attributes and behaviors
Primary constructor used to assign values to properties, set clause removed to maintain encapsulation
Code repetition identified as a maintenance headache; DRY principle will be introduced in next stage in order to avoid it!
OOP principles highlighted as important for efficient and maintainable applications.
Cat.cs
namespace MyApplication.Animals;
public class Cat(string name)
{
public string Name { get; } = name;
public void Eat()
{
Console.WriteLine($"{Name} is eating...");
}
public void Climb()
{
Console.WriteLine($"{Name} is climbing on a roof!");
}
}Dog.cs
Parrot.cs
Program.cs
Last updated