Difference between revisions of "2020 - LargeSettlement"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "This is just like Creating 2020 - Settlement")
 
Line 1: Line 1:
This is just like [[Creating 2020 - Settlement]]
+
This is will inherit 'Settlement' so is a subclass of Settlement.
 +
 
 +
The details for Settlement can be found here [[2020 - Settlement]].
 +
 
 +
==Constructor==
 +
The only method defined is a new constructor
 +
<syntaxhighlight lang=csharp>
 +
        public LargeSettlement(int extraXSize, int extraYSize, int extraHouseholds)
 +
            : base()
 +
        {
 +
            xSize += extraXSize;
 +
            ySize += extraYSize;
 +
            startNoOfHouseholds += extraHouseholds;
 +
            for (int count = 1; count < extraHouseholds + 1; count++)
 +
            {
 +
                AddHousehold();
 +
            }
 +
        }
 +
</syntaxhighlight>
 +
 
 +
The line:
 +
<syntaxhighlight lang=csharp>
 +
        public LargeSettlement(int extraXSize, int extraYSize, int extraHouseholds)
 +
            : base()
 +
</syntaxhighlight>
 +
 
 +
will also run the constructor from the 'base' class.

Revision as of 12:16, 27 January 2020

This is will inherit 'Settlement' so is a subclass of Settlement.

The details for Settlement can be found here 2020 - Settlement.

Constructor

The only method defined is a new constructor

        public LargeSettlement(int extraXSize, int extraYSize, int extraHouseholds)
            : base()
        {
            xSize += extraXSize;
            ySize += extraYSize;
            startNoOfHouseholds += extraHouseholds;
            for (int count = 1; count < extraHouseholds + 1; count++)
            {
                AddHousehold();
            }
        }

The line:

        public LargeSettlement(int extraXSize, int extraYSize, int extraHouseholds)
            : base()

will also run the constructor from the 'base' class.