-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyboard.cpp
More file actions
36 lines (29 loc) · 1.24 KB
/
Keyboard.cpp
File metadata and controls
36 lines (29 loc) · 1.24 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
//Student Bshara Haj, 212590186.
//Student Obaeda Khatib, 201278066.
#pragma once
#include "Keyboard.h"
Keyboard::Keyboard(int price, const string& manufacturer, const string& color, bool isWireless, int numberOfKeys)
: Item(price, manufacturer), PeripheralDevice(price, manufacturer, color, isWireless), numberOfKeys(numberOfKeys) //constructor for the Keyboard class
{
}
int Keyboard::getNumberOfKeys() const //to get the number of keys on the Keyboard
{
return numberOfKeys;
}
void Keyboard::setNumberOfKeys(int numberOfKeys) //to set the number of keys on the Keyboard
{
this->numberOfKeys = numberOfKeys;
}
void Keyboard::connect( Computer& computer) //to simulate connecting the Keyboard to a Computer /////////////deleted the two consts and add & before computer in eripheralDevice::connect(&computer);
{
std::cout << "Connecting a keyboard" << std::endl;
PeripheralDevice::connect(&computer);
}
string Keyboard::toString() const //to get a string representation of the Keyboard
{
return PeripheralDevice::toString() + ", Keyboard with " + std::to_string(numberOfKeys) + " Keys";
}
Keyboard::operator string() const //string conversion operator for the Keyboard class
{
return toString();
}