Ejemplo n.º 1
0
        // get a vitamin with a given "name"
        // The vitmain's name is passed in as a parameter
        public void GetVitamin(string name)
        {
            // Use the square bracket notation to get the bike from the dictionary
            Disease aDisease = Inventory[name];

            // We want to record the vitamin def associated with a disease, so we create new "Vitamin" object and set it's properties
            Vitamin aVitamin = new Vitamin();

            aVitamin.VitaminName    = aVitamin.Name;
            aVitamin.VitaminHistory = aDisease.History;
            aVitamin.DiseaseName    = aDisease.Name;

            // "Record" the vitamin, by adding it to our VitaninHistory list
            VitaminHistory.Add(aVitamin);

            // We've sold the bike so it's no longer in our inventory
            Inventory.Add(name);
        }
Ejemplo n.º 2
0
 // A public "method" can be called from outside the class and can access either public or private properties and methods
 // This method accepts a "parameter" of type "Bike" and adds it to the private Inventory dictionary
 public void AddDisease(Disease aDisease)
 {
     Inventory.Add(aDisease.Name, aDisease);
 }