Lab 6: Inheritance and Polymorphism | CMSC 240 Software Systems Development - Fall 2024

Lab 6: Inheritance and Polymorphism

Instructions

Objective

Design and implement an inventory system to manage different types of wearable tech products using inheritance and polymorphism.

Wearable Tech Inventory System

Problem Statement:

A tech store sells various wearable devices such as smartwatches, fitness trackers, and augmented reality (AR) glasses. These devices have some common attributes, but each also has unique features.

Base Class - WearableDevice:

Derived Classes

Review the code in testdevices.cpp, WearableDevice.h, and WearableDevice.cpp. Then write the code for the classes ARGlasses, FitnessTracker, and SmartWatch using the problem statement description above. Your new classes should extend the WearableDevice class to inherit the functionality. I have created the .cpp and .h files in the lab repository, and you should write your code where it says // Write your code here...

When you finish and test your code by running the main function in the testdevices.cpp file.

$ g++ ARGlasses.cpp FitnessTracker.cpp SmartWatch.cpp WearableDevice.cpp testdevices.cpp -o testdevices

$ ./testdevices 

Here is a sample of what the output should look like

Brand: Apple
Price: $399.99
Quantity: 10
Screen Size: 1.7 inches
GPS: Yes
-------------------------------
Brand: Fitbit
Price: $149.99
Quantity: 15
Heart Rate Monitor: Yes
Battery Life: 24 hours
-------------------------------
Brand: MagicLeap
Price: $2295
Quantity: 5
Field of View: 50 degrees
Interactive Surface: Yes
-------------------------------
Selling 3 Apple smartwatches...
Remaining stock for Apple smartwatch: 7
Restocking 5 Fitbit trackers...
New stock for Fitbit tracker: 20

+

When you finish writing and testing the code. In your README.md file write a brief description of how the testdevices.cpp file is using polymorphism.

+

Draw a UML diagram of the completed inventory system. Include a picture of your diagram in the repository. Put the name of your diagram file in the README.md so we know what to look for when grading.

Grading Rubric

Total Points: 100

Pair programming

Pair programming is a software development technique in which two programmers work together at one computer. One, the driver, writes code while the other, the navigator, reviews each line of code as it is typed in. The two programmers switch roles frequently.