I am looking for some help in class structure. Suppose I have a class called "Dog" that contains information about the dog (name, weight, type), but because there can be several dogs, I would also like the class to keep all these dogs for use throughout my project. What is the best way to do this?
Just to have a DogList class that stores information about the Dog class in a public list? Let me get it on my own?
Or should the list be static in the original dog class? maybe in the constructor, when someone creates a new dog, the dog gets on the static list?
Edit: Sorry, the question was a little missed. Here is the structure that I still have, wondering if there is a better way to implement it.
public class Dog
{
public string name{get;set;}
public int weight { get; set; }
}
public class DogFactory
{
public List<dog> lstDogs = new List<dog>();
public void setDogs()
{
Animal.Retrieve("Dog");
foreach(Animal.Dog pet in Animal._Dogs)
{
Dog doggie = new doggie();
doggie.Name = pet.Name;
...etc
lstDog.add(doggie);
}
}
}
source
share