Create the following class
Pet Class |
---|
Properties |
|
Methods |
|
There are no fields.
- The properties are self-explanatory. The getter is public and the setter is mostly absent.
- public Pet(string name, int age, string description) – This constructor takes three arguments and assigns them to the appropriate properties. It also initializes the fields owner to “no one” and isHousedTrained to false
Remember the ToString() method is needed to produce a sensible output on the screen
-
public override string ToString() – This method returns a string fully describing this object.
-
public void SetOwner(string owner) – This method simply assigns the argument to the appropriate field.
-
public void Train() – This method sets the property IsHouseTrained to true.
In your main method write the code to do the following:
-
Create four objects. You decide on the arguments
-
Create a List to store all the above objects.
-
Use some of the methods on some of the objects.
-
Using a suitable looping statement, display all the objects in the collection.
-
Prompt the user for an owner’s name and then display only the pets belonging to a particular person.