Chemical Reactions & ADTs
Extended Response5 MarksShared
Alex is developing a computer simulation to model a chemical reaction. In the simulation, the reactor is initially empty and the reaction starts when one or more chemicals are added. More chemicals may be added while the reaction is in progress. A chemical reaction is characterised by what chemicals are added, how much of them are added and when they are added.
(a).
To store a description of a chemical reaction for simulation, Alex needs the following information about each addition into the reactor:
• the name of the chemical added
• the time the chemical was added, in seconds, after the reaction begins
• the amount of the chemical added, in milligrams
Describe a combination of ADTs that Alex could use to store a description of a chemical reaction. Justify your answer.
[3](b).
Alex intends to use the combination of ADTs described in part a. often and decides to define the combination of ADTs as a new ADT called ChemEvents.
For the ChemEvents ADT, as described in part a., write the signature specification of the following operations:
• Add a new chemical to the reaction.
• Look up what chemical was added to the reaction at a given time.
[2]