Question 8
AQA Computer Science June 2017 Paper 1A level14 marks
On the specification
- 8.1
- 4.1 Fundamentals of programming
- 8.2
- 4.1 Fundamentals of programming
- 8.3
- 4.1 Fundamentals of programming
- 8.4
- 4.1 Fundamentals of programming
- 8.5
- 4.2 Fundamentals of data structures
- 8.6
- 4.1 Fundamentals of programming
Question text
8 The class diagram in Figure 11 is a partial representation of the relationships between some of the classes in the Skeleton Program. Note: In Figure 11 a + sign denotes a public attribute/method. Figure 11 Simulation -Landscape: Location -TimePeriod: Integer -WarrenCount: Integer -FoxCount: Integer -CreateNewWarren() -CreateNewFox() ♦ Location +Fox: Fox +Warren: Warren ♦ ♦ Fox Warren -FoodUnitsNeeded: Integer -Rabbits: Rabbit -RabbitCount: Integer +AdvanceGeneration() +Inspect() -CalculateRandomValue() +GetRabbitCount() -KillByOtherFactors() A class diagram can show a variety of features used in object-oriented programming. 8.1 Write Yes or No in the unshaded cells in Table 5 to identify if the given feature is present in the class diagram shown in Figure 11. [3 marks] Table 5 Feature Is present in Figure 11? (Yes/No) Inheritance Protected method Private attribute Copy the contents of the unshaded cells in Table 5 into the table in your Electronic Answer Document. 8.2 State the name of an identifier for a subclass in the Skeleton Program. [1 mark] 8.3 Explain the difference between a protected attribute and a private attribute. [2 marks] 8.4 In the Warren class there is an attribute RabbitCount and a method GetRabbitCount. Explain the need for the GetRabbitCount method and explain why this approach is favoured in object-oriented programming. [2 marks] 8.5 During the simulation rabbits will die for a variety of reasons. One of these reasons is old age and at the end of the KillByOtherFactors method there is a call to CompressRabbitList. Explain the need for the CompressRabbitList method. [2 marks] Part of the class definition for Rabbit has been represented in Figure 12. Figure 12 Rabbit = Class(Animal) Private: ReproductionRate: Real Gender: Genders Public: Procedure Inspect() Function IsFemale() Function GetReproductionRate() End Class A new animal is to be introduced into the simulation. This animal is the HDRabbit, which represents a rabbit with haemorrhagic disease. The class HDRabbit is to be a subclass of the Rabbit class. When an HDRabbit is inspected it should display all the information shown for a normal rabbit plus the additional information stored about an HDRabbit. An HDRabbit has the following additional attributes: • InfectionRate: stores a value that represents the probability of a rabbit that is bred from an HDRabbit being infected • Generation: stores a value that represents how many generations have had this disease in this rabbit’s family. An HDRabbit has additional methods including: • IsInfertile(): returns True if the haemorrhagic disease has been in this rabbit’s family for three generations. 8.6 Write the class definition for HDRabbit, using similar notation to that used in Figure 12. You are not expected to make any changes to the Skeleton Program. [4 marks] Turn to page 20 for Section D You are advised to spend no more than 70 minutes on this section. Type your answers to Section D in your Electronic Answer Document. You must save this document at regular intervals. These questions require you to load the Skeleton Program and to make programming changes to it.