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

Wednesday, September 4, 2019

Codecademy Public vs. Private 6/12


// Sample Solution
using System;
///////////////////////////////////////////////////
// Forest.cs code
namespace BasicClasses
{
  class Forest
  {
    public int age;
   
    public string Name
    { get; set; }
   
    public int Trees
    { get; set; }
   
    private string Biome
    {
      get { return biome; }
      set
      {
        if (value == "Tropical" ||
            value == "Temperate" ||
            value == "Boreal")
        {
          biome = value;
        }
        else
        {
          biome = "Unknown";
        }
      }
    }
  }
}
///////////////////////////////////////////////////
// Program.cs code
using System;

namespace BasicClasses
{
  class Program
  {
    static void Main(string[] args)
    {
      Forest f = new Forest();
      f.Name = "Congo";
      f.Trees = 0;
      f.age = 0;
      f.Biome = "Desert";
     
      Console.WriteLine(f.Name);
      Console.WriteLine(f.Biome);
    }
  }
}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts