-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUSBHub.cpp
More file actions
42 lines (35 loc) · 1.22 KB
/
USBHub.cpp
File metadata and controls
42 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Tyeon Ford
#include "USBHub.h"
#include <iostream>
#include <iomanip>
using namespace std;
// USB constructor
USBHub::USBHub(string name, double price, int stock, string desc, int ports, bool hasPD, int pdWatts, string version)
: Product(name, price, stock, desc), numPorts(ports), hasPowerDelivery(hasPD), powerDeliveryWatts(pdWatts), usbVersion(version) {}
// methods
void USBHub::displayDetails() const {
cout << "\n===== USB HUB DETAILS =====\n";
cout << "Name: " << name << "\n";
cout << "Price: $" << fixed << setprecision(2) << price << "\n";
cout << "Stock: " << stock << " units\n";
cout << "Description: " << description << "\n";
cout << "Number of Ports: " << numPorts << "\n";
cout << "USB Version: " << usbVersion << "\n";
cout << "Power Delivery: " << (hasPowerDelivery ? "Yes" : "No");
if (hasPowerDelivery) {
cout << " (" << powerDeliveryWatts << "W)";
}
cout << "\n===========================\n";
}
int USBHub::getNumPorts() const {
return numPorts;
}
bool USBHub::getHasPowerDelivery() const {
return hasPowerDelivery;
}
int USBHub::getPowerDeliveryWatts() const {
return powerDeliveryWatts;
}
string USBHub::getUSBVersion() const {
return usbVersion;
}