Question & Answer: Please help with the following C++ questions, they are all related:…..

Please help with the following C++ questions, they are all related:
Write the class specification of a class Phone containing: 1. A data member named model of type string (private). 2. A data member named partNumber of type string (private). 3. A data member named retailPrice of type double (private). 4. A default constructor that intializes model and partNumber to empty strings and retailPrice to O 5. getter (accessor) functions that return the value of each of the data members 6. setter (mutator) functions to set each of the data members 7. Overloaded stream insertion operator (<s) that output the data members to an output stream (format: model, part number, retail price) 8. Overloaded stream extraction operator (>) that reads the data members from an input stream (format: model, part number, retail price) Note that youre NOT asked to implement any member functions of the class. Write only the class specification.
media%2Fd74%2Fd7432afa-4f77-4ae7-9133-f8
media%2Fcbe%2Fcbe998bb-357c-4f45-95db-a8
media%2Fa7d%2Fa7d7f991-3766-4d86-8f33-e7
media%2Fbc9%2Fbc97b883-d468-413b-81ce-93

Write the class specification of a class Phone containing: 1. A data member named model of type string (private). 2. A data member named partNumber of type string (private). 3. A data member named retailPrice of type double (private). 4. A default constructor that intializes model and partNumber to empty strings and retailPrice to O 5. getter (accessor) functions that return the value of each of the data members 6. setter (mutator) functions to set each of the data members 7. Overloaded stream insertion operator () that reads the data members from an input stream (format: model, part number, retail price) Note that you’re NOT asked to implement any member functions of the class. Write only the class specification.

Expert Answer

 

class Phone {
private:
string model;
string partNumber;
double retailPrice;
public:
Phone();
string getModel();
string getPartNumber();
double getRetailPrice();
void setPartNumber(string a);
void setModel(string a);
void setRetailPrice(double a);
friend ostream & operator << (ostream &out, const Phone &c);
friend istream & operator >> (istream &in, Phone &c);
};

Phone::Phone(){
model = “”;
partNumber = “”;
retailPrice = 0;
}
string Phone::getModel(){
return model;
}
string Phone::getPartNumber(){
return partNumber;
}
string Phone::getModel(){
return model;
}
void Phone::setModel(string a){
model = a;
}
void Phone::setPartNumber(string a){
partNumber = a;
}
void Phone::setRetailPrice(double a){
retailPrice = a;
}
ostream & operator << (ostream &out, const Phone &c)
{
out << c.model << ” ” << c.partNumber << ” ” << c.retailPrice << endl;
return out;
}

istream & operator >> (istream &in, Phone &c)
{
cout << “Enter Model “;
in >> c.model;
cout << “Enter Part Number “;
in >> c.partNumber;
cout << “Enter Retail Price “;
in >> c.retailPrice;

return in;
}

class CameraPhone : public Phone {
private:
int imageSize;
int memorySize;
public:
CameraPhone(int is, int ms) : Phone();
int numPictures();
};

CameraPhone::CameraPhone(int is, int ms) : Phone(){
imageSize = is;
memorySize = ms;
}
int CameraPhone::numPictures() {
return ( memorySize/imageSize);
}

int main(){

double price;

CameraPhone myPhone(2,64);
myPhone.setModel(“Droid Maxx2”);
myPhone.setPartNumber(“224455”);
cout << “Enter Retail Price:” ;
cin >> price;
myPhone.setRetailPrice(price);
return 0;
}

Still stressed from student homework?
Get quality assistance from academic writers!