ELEN3009 - Test 2019
ELEN3009 - Test 2019
ELEN3009 - Test 2019
Instructions
Question 1
Sun Microsystems, who created the Java language, used the slogan “Write once, run every-
where” to promote the language. Explain what is meant by this slogan, and how this slogan
could be used to highlight the differences between Java and languages like C++.
[Total Marks 5]
Question 2
a) Read the description of the unique algorithm that is given in your reference sheets and
write a set of unit tests to verify the behaviour of unique.
(12 marks)
b) Provide an implementation of the unique algorithm. Your algorithm must have the
following signature:
Iterator unique(Iterator first, Iterator last)
Page 1 of 2
Question 3
You are required to develop software for a solar inverter, which converters DC power from
a solar panel to AC which can be used by most existing appliances. The product brief is as
follows:
Your task is to create an Inverter class and implement the following public member func-
tions in order to model the above behaviour:
// starts the inverter with user defined settings
void start(OutputMode output_mode, DutyCycle duty_cycle);
// starts the inverter with predefined settings
void quickStart();
Add additional functions and/or data members to your Inverter class, as required. Make
use of the existing classes supplied in Listing 1. You are not required to provide the imple-
mentation details for these existing classes.
class Ammeter
{
public:
Ammeter();
// returns the measured current in amps
float MeasuredAmps() const;
};
class SwitchModeTransformer
{
public:
SwitchModeTransformer();
void setVoltage(unsigned int voltage);
void setFrequency(unsigned int frequency);
void setDutyCycle(float duty_cycle_percentage);
void startSwitching();
void stopSwitching();
};
[Total Marks 9]
Page 2 of 2