Skip to content

Instantly share code, notes, and snippets.

@DuffleOne
Created October 12, 2012 12:50
Show Gist options
  • Save DuffleOne/3879065 to your computer and use it in GitHub Desktop.
Save DuffleOne/3879065 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Windows.Forms;
public class Chorus {
Dog fluffles;
Dog jake;
Dog harry;
Dog kim;
List<Dog> dogs;
public Chorus() {
fluffles = new Dog("Fluffles", "Great Dane", 80, "black");
jake = new Dog("Jake", "American Foxhound", 64, "brown and white");
harry = new Dog("Harry", "American Bulldog", 50, "brown");
kim = new Dog("Kim", "Chihuahua", 12, "brown");
kim.Bark = "Gruff!";
try {
dogs.Add(fluffles);
dogs.Add(jake);
dogs.Add(harry);
dogs.Add(kim);
} catch (Exception ex) {
MessageBox.Show("Sorry, could not create a list of dogs in the class \"Chorus\"...");
}
}
public string getSpeeches() {
string output = "All dogs have " + Dog.legs + " legs.\n\n";
foreach (Dog current in dogs) {
output += current.getSpeech() + "\n";
}
return output;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment