Back to marketplace

Skeleton program

No description yet. This curated deck is ready for daily study.

Total cards: 24•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (24)

#1
Front (Question)

How does the simulation work ,

Back (Answer)

You insert the parameters of one of the simulations and it gives the information of the parameters by displaying a menu. It consists of nests , ants , pheromones and food . Worker ants randomly search the grid for food and can move adjacent cells between each time , once food has been found a pheromone is then laid and the ants makes its way to the nests , other ants then move towards the pheromone to get food . If there is very little food ants are culled and if there is plenty of food new ants are born.

#2
Front (Question)

Explain the procedure Main

Back (Answer)

Main : The user requests which of the 4 simulations that they would like run , once they have selected the simulation , a simulation object is created. Then the menu is displayed and has 6 options to choose from . The menu keeps on displaying until the user chooses to quit simulation DisplayMenu: This procedure outputs the menu display GetChoice: This function requests input from the menu for the choice of menu GetCellReference: This function requests input from the user for the row and column number

#3
Front (Question)

How many subroutines are there in the skeleton code that have two parameters as input?

Back (Answer)

13

#4
Front (Question)

What is the difference between a function and procedure?

Back (Answer)

A function returns a value while Procedures change the state of a system e.g change values of global variables or complete a task like printing

#5
Front (Question)

State the name of the identifier for the user-defined procedures in the skeleton code;

Back (Answer)

Main and Display Menu

#6
Front (Question)

State the name of the identifier for the user-defined functions in the skeleton code

Back (Answer)

Get choice , Getcellreference

#7
Front (Question)

Explain how data are shared between the subroutines

Back (Answer)

Data are passed into subroutines through parameters and are returned from functions

#8
Front (Question)

What is the difference between a QueenAnt and WorkerAnt in terms of attributes and behaviour:

Back (Answer)

A queen stays in the nest and does not move around or carry food , it has no specific food capacity and the type of ant is set to ”queen” while a worker ant has a specific food capacity of “30” , goes around to look for food by moving randomly or following the pheromone dropped by other ants and its type of ant has been set to “worker”

#9
Front (Question)

What happens in the simulation when a worker ant carrying food reaches its nest.

Back (Answer)

The ant is detected as being at its nest. Food is added to the nest and the ants carried food is set to zero.

#10
Front (Question)

Discuss the advantages and disadvantages of using randomisation in this type of simulation:

Back (Answer)

Advantage: Adds unpredictability, making ant behaviour more realistic. Disadvantage: Results vary between runs, making testing and debugging harder

#11
Front (Question)

In simulation find an example of a private method:

Back (Answer)

__GetIndex __GetIndicesofNeighbours __GetIndexOfNeighboursWithStrongestPheromone

#12
Front (Question)

In simulation find an example of a protected attribute :

Back (Answer)

Self.grid [ ]

#13
Front (Question)

In Class Ant find an example of a protected method.

Back (Answer)

_changeCell _ChooseRandomNeigbours

#14
Front (Question)

In OOP what is meant by overriding

Back (Answer)

This is changing the use of a method in the child’s class that was inherited from the parents class to perform something different

#15
Front (Question)

In cell find an example of a public method

Back (Answer)

GetDetails GetAmountFood

#16
Front (Question)

Explain the class in cell:

Back (Answer)

__init__: specifies the start row and column and sets the amount of food to 0. GetAmountOfFood: It return the amount of food , after fining how much food is in the cell GetDetails: This returns the amount of food present uses overriding from entity UpdateFoodInCell: Updates the food in a cell by adding in increments to the previous food

#17
Front (Question)

Explain the class in Pheromone :

Back (Answer)

__init__: specifies the row, column, the ants with the pheromone and the initial strength decay of pheromone AdvanceStage: Strength of pheromone decays each time step and the decay the amount the value decay is set to UpdateStrength: Update strength of Pheromone for that cell GetStrength,: GetBelongsTo Getters for Strength of Pheromone

#18
Front (Question)

What is the purpose of the Entity class in this program :

Back (Answer)

It acts as a base class providing common attributes (row, column, ID) and shared methods such as InSameLocation. Other classes inherit from it to reduce code duplication.

#19
Front (Question)

What is meant by the method overriding in the context of GetDetails():

Back (Answer)

Subclasses replace the inherited GetDetails method with their own version. For example, Cell.GetDetails() describes food in a cell, while Ant.GetDetails() describes ant type and state.

#20
Front (Question)

Why is inheritance preferable to writing separate, independent classes for ants, nests, and pheromones?

Back (Answer)

Inheritance avoids duplicating shared attributes like position. It also allows polymorphism so that different objects can be handled in a in a similar way.

#21
Front (Question)

How does polymorphism appear in this program?

Back (Answer)

Different entities implement AdvanceStage differently. The simulation can call AdvanceStage on all objects without needing to know whether it’s an ant, nest, or pheromone.

#22
Front (Question)

Explain how this code demonstrates the principle of encapsulation.

Back (Answer)

Attributes are prefixed with underscores to indicate private use. Access is controlled by getter and setter methods like GetRow and UpdateFoodCarried.

#23
Front (Question)

Explain the algorithm for moving a worker ant carrying food back to its nest.

Back (Answer)

The worker ant compares its current row/column with the nest’s row/column and steps one unit closer each stage until reaching it.

#24
Front (Question)

Describe two differences between a virtual method and an abstract method.

Back (Answer)

Virtual method has implementation, can be overridden but do not have to be, abstract methods have no implementation, and must be overridden