Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //In Forest.cs file
- using System;
- namespace BasicClasses
- {
- class Forest
- {
- //No need the field for name and trees since using automatic property
- public int age;
- public string biome;
- public string Name
- {
- get; set; //No need to define as a hidden field is defined in the background for us
- }
- public int Trees
- {
- get; set;
- }
- public string Biome
- {
- get { return biome; }
- set
- {
- if (value == "Tropical" || value == "Temperate" || value == "Boreal")
- {
- biome = value;
- }
- else
- {
- biome = "Unknown";
- }
- }
- }
- }
- }
- //Program.cs file remains the same
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement