Quotes help make search much faster. Example: "Practice Makes Perfect"

Wednesday, September 4, 2019

Codecademy Methods 8/12


// Sample Solution
///////////////////////////////////////////////////
// Forest.cs code
using System;

namespace BasicClasses
{
  class Forest
  {
    public int age;
    private string biome;
   
    public string Name
    { get; set; }
   
    public int Trees
    { get; set; }
   
    public string Biome
    {
      get { return biome; }
      set
      {
        if (value == "Tropical" ||
            value == "Temperate" ||
            value == "Boreal")
        {
          biome = value;
        }
        else
        {
          biome = "Unknown";
        }
      }
    }
   
    public int Age
    {
      get { return age; }
      private set { age = value; }
    }
   
    public int Grow()
    {
      Trees = Trees + 30;
      Age = Age + 1;
      return Trees;
    }
   
    public int Burn()
    {
      Trees = Trees - 20;
      Age = Age + 1;
      return Trees;
    }
   
  }

}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts