Difference between revisions of "Composition - 2017"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "Composition is where if you delete the main class the subclasses are deleted along with it, or they no longer work. <syntaxhighlight lang="c#"> class Location { publi...")
 
Line 1: Line 1:
 
Composition is where if you delete the main class the subclasses are deleted along with it, or they no longer work.
 
Composition is where if you delete the main class the subclasses are deleted along with it, or they no longer work.
<syntaxhighlight lang="c#">
+
<syntaxhighlight lang="csharp">
  
 
   class Location
 
   class Location

Revision as of 14:44, 6 February 2017

Composition is where if you delete the main class the subclasses are deleted along with it, or they no longer work.

  class Location
  {
    public Fox Fox;
    public Warren Warren;

    public Location()
    {
      Fox = null;
      Warren = null;
    }
  }

  class Simulation
  {
    private Location[,] Landscape;
    private int TimePeriod = 0;
    private int WarrenCount = 0;
    private int FoxCount = 0;
    private bool ShowDetail = false;
    private int LandscapeSize;
    private int Variability;
    private static Random Rnd = new Random();