2020 - LargeSettlement

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

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.

The values for 'xSize' and 'ySize' are increased by the parameters passed ('extraXSize' and 'extraYSize').

The starting number of households ('startNoOfHouseholds') is also increased by the parameter passed ('extraHouseholds').

The for loop in this method will create the extra households required. Interestingly the 'base' constructor will create the other households.