Answered step by step
Verified Expert Solution
Question
1 Approved Answer
hi question 5 please .. thank you in the pictures there is an output example and i think there is some thing wrong in my
hi
question 5 please .. thank you
in the pictures there is an output example and i think there is some thing wrong in my code can you correct my code please
task 5
Define a class with name Notebook derived from class Device. This class shall have following members:
a private string attribute with name drive.
a private Boolean attribute with name convertible for a convertible one.
a public constructor with six parameters for the article name, the net price, the main memory size, the drive, the operating system with default parameter OperatingSystem::linux as well as whether it is a convertible with default parameter false; the tax rate shall be initialised automatically by the constructor of the upper class.
a virtual public destructor producing an output "~Notebook()" at its call (see examples at the bottom).
a public method with name is_a_convertible without parameters returning a Boolean function value whether the notebook is a convertible.
a virtual public method with name print without parameters, calling method print of the direct upper class, in case of a convertible outputs string "(convertible)" and afterwards the drive.
the code is :
#include
#include
#include
using namespace std;
//task 1
class Article{
private:
string model;
double netPrice;
double taxRate;
double b;
public:
Article(string a, double b,double c= 19)
{
model .assign(a);
netPrice=b;
textRate=c;
}
virtual ~Article()
{
cout
void set_model(string a)
{
model .assign(a);
}
void set_netPrice(double b)
{
netPrice = b;
}
string get_model()
{
return model;
}
double get_ netPrice()
{
return netPrice;
}
double get_grossprice()
{
double grossPrice=(netPrice+(netPrice*taxRate/100.0);
return grossPrice;
}
};
class Accessory : public Article
{
private:
string Model ;
double netPrice;
bool original;
public:
Accessory(string m, float double c ,bool 1 = true):Article(string m,double c)
{
model.assign(m);
netPrice *c;
original =1;
}
virtual ~Accessory()
{
cout
virtual void print()
{
cout
cout
}
};
enum class OperatingSystem ;
string{
unknown,android,iOS,macOS,linux,proprietary,
unix,windows
};
//Overloading
ostream& operator
{
string osString;
//Assign the string depends on the input
switch(os)
{
case OperatingSystem::unknown:
{
osString = "unkown OS";
break;
}
case OperatingSystem::android:
{
osString = "Android OS";
break;
}
case OperatingSystem::iOS:
{
osString = "iOS";
break;
}
case OperatingSystem::macOS:
{
osString = "MacOS";
break;
}
case OperatingSystem::linux:
{
osString = "Linux OS";
break;
}
case OperatingSystem::proprietary:
{
osString = "proprietary OS";
break;
}
case OperatingSystem::unix:
{
osString = "Unix OS";
break;
}
case OperatingSystem::windows:
{
osString = "MS Windows OS";
break;
}
}
//Assign it to stream and return
out
return out;
}
int main()
{
//Print enum OperatingSystem using operator Overload
cout
cout
cout
cout
cout
cout
cout task 5 Define a class with name Notebook derived from class Device. This class shall have following members: a private string attribute with name drive. a private Boolean attribute with name convertible for a convertible one. a public constructor with six parameters for the article name, the net price, the main memory size, the drive, a virtual public destructor producing an output "-Notebook()" at its call (see examples at the bottom). a public method with name is_a_convertible without parameters returning a Boolean function value whether the no a virtual public method with name print without parameters, calling method print of the direct upper class, in - Plugins DoxyBlocks Settings Help 15+ 0X Debug - Artide:: #include #include #includecostream> Artides using namespace std; task 1 class Article private: string model: double netPrice: double taxRate: double b: NNNNNONPAR E coonWN public: Article (stringa, double b, double - model .assign(a): netPrice: textRate-c: virtual - Article() cout #include #includecostream> Artides using namespace std; task 1 class Article private: string model: double netPrice: double taxRate: double b: NNNNNONPAR E coonWN public: Article (stringa, double b, double - model .assign(a): netPrice: textRate-c: virtual - Article() cout
}
//task 4
class Device : public Article{
private:
int memorySize;
OperatingSystem os;
public:
Device(string article_name,int net_price,int _memorySize, OperatingSystem _os = OperatingSystem::unknown)
:Article(article_name, net_price)
{
memorySize = _memorySize;
os = _os;
}
virtual ~Device(){
cout
}
int get_memory_size(){
return memorySize;
}
void set_memory_size(int _memorySize){
memorySize = _memorySize;
}
OperatingSystem get_os(){
return os;
}
void set_os(OperatingSystem _os){
os = _os;
}
virtual void print(){
cout
};
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started