#include <iostream>
using namespace std;
/*
Select exactly ONE hardware board at build time.
*/
// #define BOARD_TYPE_A
#define BOARD_TYPE_B
// --- BUILD CONFIGURATION VALIDATION ---
#if defined(BOARD_TYPE_A) && defined(BOARD_TYPE_B)
#error "Invalid Configuration: Multiple boards selected. Select only ONE."
#endif
#if !defined(BOARD_TYPE_A) && !defined(BOARD_TYPE_B)
#error "Invalid Configuration: No board selected. Define BOARD_TYPE_A or BOARD_TYPE_B."
#endif
// Abstract interface used by application code
class StatusIndicator {
public:
virtual void toggle() = 0;
virtual bool isOn() const = 0;
virtual ~StatusIndicator() = default;
};
// --- BOARD SPECIFIC IMPLEMENTATIONS ---
#ifdef BOARD_TYPE_A
class BoardAIndicator : public StatusIndicator {
private:
bool state = false; // Initial state OFF
public:
void toggle() override { state = !state; }
bool isOn() const override { return state; }
};
#endif
#ifdef BOARD_TYPE_B
class BoardBIndicator : public StatusIndicator {
private:
bool state = false; // Initial state OFF
public:
void toggle() override { state = !state; }
bool isOn() const override { return state; }
};
#endif
// --- FACTORY IMPLEMENTATION ---
StatusIndicator& getStatusIndicator() {
#ifdef BOARD_TYPE_A
static BoardAIndicator instance;
return instance;
#else // BOARD_TYPE_B
static BoardBIndicator instance;
return instance;
#endif
}
// DO NOT modify main()
int main() {
int n;
if (!(cin >> n)) return 0;
StatusIndicator& indicator = getStatusIndicator();
for (int i = 0; i < n; ++i) {
int evt;
cin >> evt;
if (evt == 1) {
indicator.toggle();
}
cout << (indicator.isOn() ? "STATUS=ON\n" : "STATUS=OFF\n");
}
return 0;
}
Input
5 1 1 0 1 1
Expected Output
STATUS=ON STATUS=OFF STATUS=OFF STATUS=ON STATUS=OFF