Lab Task # 10 (Open Ended Lab)
Lab Outcomes:
To develop a Smart Home Automation System in C# that demonstrates the use of enums,
interfaces, abstraction through abstract classes, and exception handling by simulating
real-world smart devices and their behaviors.
Problem Statement:
Design and implement a Smart Home Automation System in C#. The system should manage different smart
devices such as lights, thermostats, and security cameras. Each device must have a type and status, support
basic operations like turning on/off, perform a self-test, and handle potential operational errors gracefully.
Your implementation must incorporate the following object-oriented programming principles:
Use enumerations to manage device types and statuses.
Apply interfaces to define a contract for smart device operations.
Use an abstract base class to provide a common structure for all smart devices.
Implement proper exception handling to manage invalid operations or device errors.
Create at least three types of smart devices with different behaviors and simulate their usage in a main
program, ensuring all design requirements are fulfilled.
Hints for Students:
Requirements:
1. Enum:
o Create an enum called DeviceStatus with values: Offline, Online, Error, Maintenance.
o Use another enum called DeviceType with values: Light, Thermostat, Camera.
2. Interface:
o Define an interface ISmartDevice with the following methods:
void TurnOn();
void TurnOff();
void DisplayStatus();
3. Abstraction:
o Create an abstract class SmartDevice that:
Implements ISmartDevice.
Has properties: string DeviceName, DeviceStatus Status, and DeviceType
Type.
Has an abstract method: void PerformSelfTest();
Includes a constructor that sets device name and type.
Implements a basic exception throw: if device status is Offline, TurnOn() should
throw an exception.
4. Concrete Classes:
o Create at least three classes (SmartLight, SmartThermostat, and SmartCamera) that inherit
from SmartDevice and implement the PerformSelfTest() method with device-specific
logic.
5. Exception Handling:
o Handle any exceptions using try-catch blocks when turning on or performing actions on the
devices.
o Log an appropriate message if an exception is caught, indicating which device caused it and
why.
6. Main Method:
o Create a list of ISmartDevice instances.
o Add at least one object of each type (SmartLight, SmartThermostat, SmartCamera) with
different statuses.
o Loop through the list and attempt to TurnOn() and PerformSelfTest() for each device,
catching and handling any exceptions gracefully.
Lab Assessment Criteria:
Open Ended Lab Marks distribution
ER1 ER6 ER8
Task 3 points 3 points 4 points
Open Ended Lab Rubric Evaluation Guideline:
# Qualities & 0 < Poor <=0.5 0.5 < Satisfactory <= 1.5 1.5 < Excellent <=2
Criteria
ER Task Minimal or no Some tasks were All tasks were completed,
1 Completion program functionality completed, but the and the program runs
was achieved. program has errors or without errors.
incomplete
functionalities.
# Qualities & 0 < Poor <=0.5 0.5 < Satisfactory <= 1.5 1.5 < Excellent <=2
Criteria
ER Program Output is inaccurate Output is mostly Output is clear, accurate,
6 Output or poorly presented. accurate but may lack and well presented with
labels, captions, or labels, captions, and
formatting. proper formatting.
# Qualities & 0 < Poor <= 1.5 1.5< Satisfactory <= 3 3< Excellent <= 4
Criteria
ER Question & Answers some Answers most questions Answers all questions
8 Answer questions but not confidently and based on confidently and
confidently or based lab task knowledge. demonstrates a deep
on lab task understanding of the
knowledge. given lab task.