You are to write a class named PC to represent features of personal computers. The data members of the class and default values will be: Data member Description Default value name name of the computer (string) "No Name" speed processor speed in gigahertz (double) 100.0 memory memory size in megabytes (double) 512.0 disk disk drive size in gigabytes (double) 80.0 price price in riyals (double) 0.0 The class should include the following: A default constructor that sets default values for all variables. An overloaded constructor with parameters. One get function for each data member that returns the current value. One set function that sets new values for all data members. An overloaded operator -= which decreases a PC object’s price by a given double value. An overloaded operator >> that reads in the values of the data members. An overloaded operator << that will display the values of the data members. Using the PC class as the base class, you need to derive class Laptop for laptop computers that has additional data members screen and weight, both of type double. screen will hold the diagonal dimension of the laptop's screen in inches and weight will be the weight of the laptop in pounds. The derived class should include the following: A default constructor that sets default values for all variables. An overloaded constructor with parameters. One get function for each data member that returns the current value. One set function that sets new values for all data members. An overloaded operator >> that reads in the values of the data members. An overloaded operator << that will display the values of the data members. Write a driver program that declares a dynamic array of laptops, inputs laptops’ information and finally provides the following two options: Display the data of all laptops. Display the data for laptops with a price that lies within a specific range, thus with this option, you will ask the user to input the range. Notes: You are not going to use all member functions in the driver program. However, you should test them all (you do not need to submit the test). You should read the size of the dynamic array and the laptops’ information from a file. You should use separate files for the interface and implementation so that the implementation can be compiled separately from the application program.
#ifndef PC_H
#define PC_H
#include<string>
class PC
{
public:
PC();
PC(string the_name,double the_speed,double the_memory,double the_disk,double the_price);
void set_name(string the_name, double the_speed, double the_memory, double the_disk, double the_price);
double get_name();
friend void operator*=( PC&first,const PC&second);
private:
string name;
double speed, memory, disk, price;
};
#endif#include"PC.h"
#include<iostream>
using namespace std;
PC::PC()
{
name="no name":
speed=100.0;
memory=512.0;
disk=50.0;
price=0.0;
}
PC::PC(string the_name,double the_speed,double the_memory,double the_disk,double the_price)
{
name=the_name;
speed=the_speed;
memory=the_memory;
disk=the_disk;
price=the_price;
}
void PC::set-name(string the_name,double the_speed,double the_memory,double the_disk,double the_price)
{
name=the_name;
speed=the_speed;
memory=the_memory;
disk=the_disk;
price=the_price;
}
}
double PC::get_name()
{
return name;
return speed;
return memory;
return disk;
return price;
}
void PC::operator *=( PC first,const PC second)
{
return PC first *= PC second;
}#include"PC.h"
int main()
{
PC p1,p2;
p1.get();
p2.get();
p1.set();
p2.set();
return 0;
}#include"PC.h"
int main()
{
PC p1,p2;
p1.get();
p2.get();
p1.set();
p2.set();
return 0;
}#include<iostream>
using namespace std;
#include"PDAs.h"
PDAs::PDAs():PC(),color("no nmae yet"),weight(0)
{
}
PDAs::PDAs(string the_color,string the_name,double the_speed,double the_memory,double the_disk,double the_price):PC(string the_name,double the_speed,double the_memory,double the_disk, double the_price),color( the_color),weight( the_weight)
{
}
friend istream&operator>>(istream&ins,PDAs the_PDAs)
{
ins>>the_PDAs.color;
ins>>the_PDAs.weight;
return(ins);
}
friend ostream&operator<<(ostream&outs,const PDAs the_PDAs)
{
outs<<the_PDAs.color;
outs<<the_PDAs.weight;
return(outs);
}#ifndef PDAs_H
#define PDAs_h
#include"PC.h"
class PDAs:public PC
{
public:
PDAs();
PDAs(string the_color,string the_name,double the_speed,double the_memory,double the_disk,double the_price);
friend istream&operator>>(istream&ins,PDAs the_PDAs);
friend ostream&operator<<(ostream&outs,const PDAs the_PDAs);
private:
string color;
double weight;
};
#endif#include"PDAc.h"
#include<iostream>
using namespace std;
int main()
{
PDAs *c;
int maxx;
string color;
double weight,max;
cout<<"Enter the maxx\n":
cin>>maxx;
c=new PDAs[max];
for(i-0;i<maxx;i++)
cout<<"enter the color";
cin>>color;
(*PDAS).set_color[color];
cout<<"Enter the weight":
cin>>weight;
(*PDAs).set_weight[weight];
}
max=(*PDAs[0]).get_color[color];
count=i;
for(i=0;i<max;i++)
{cout<<"enter"<<max<<(count+1)<<(*PDAs[count]).get_weight[weight]<<endl;
cout<<"this"<<(*PDAs).get_color[color]<<(*PDAs).get_weight[weight];
}هذا سؤال حاولات احلها بس شكا في حلي ومحتاجته الي يعرف الله يسعده يساعدني