Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views8 pages

Oop Task

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views8 pages

Oop Task

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Name : Saba Imtiaz

Sap Id: 70145093


Section : D
Lab Task 1,2
Task 1
#include <iostream>
using namespace std;
class gadget
{
protected:
string brand;
string model;
float price;
public:
gadget(string b, string m, float p)
{
brand=b;
model=m;
price=p;
}
gadget()
{
brand="unknown";
model="abc";
price=0.0;
}
void set_print()
{
cout<<"enter the brand of gadget : "<<brand<<endl;
cout<<"enter the model of gadget : "<<model<<endl;
cout<<"enter the price of gadget : "<<price<<endl;
}
};
class smartphone : public gadget
{
private:
string cameraResolution;
public:
smartphone(string CR, string b, string m, float p)
{
cameraResolution=CR;
brand=b;
model=m;
price=p;
}
void print()
{
cout<<"enter the camera resolution :
"<<cameraResolution<<endl;
set_print();
}
};
class laptop : public gadget
{
private:
string BatteryLife;
public:
laptop(string BL, string b, string m, float p)
{
BatteryLife=BL;
brand=b;
model=m;
price=p;
}
void display_info()
{
cout<<"enter the battery life : "<<BatteryLife<<endl;
set_print();
}
};
int main()
{
smartphone myPhone("48 MP","Apple","iPhone 15",1200.0);
laptop myLaptop("2 hours","DELL","XPS 13",1500.0);

cout<<"enter the detail of smartphone : "<<endl;


myPhone.print();
cout<<endl;

cout<<"enter the detail of laptop : "<<endl;


myLaptop.display_info();

return 0;

Task 2
#include<iostream>
using namespace std;
class recipe
{
class recipe
{
protected:
string name;
string cuisionType;
string servings;
public:
recipe(string n, string ct ,float s)
{
name=n;
cuisionType=ct;
servings=s;

}
recipe() {
name = "unknown";
cuisionType="unknown";
servings="unknown";
}

void set_print() {
cout << "name of recipe: " << recipe << endl;
cout << "enter cuision type: " << cuisionType<< endl;
cout << "enter servings: " <<servings << endl;
}
};
class bakedrecipe: public recipe
{
protected:
int bakingTemperature;
int bakingTime;
public:
bakedrecipe(int bt, int btime, string n, string ct, string s)
{
bakingTemperature=bt;
bakingTime=btime;
name=n;
cuisionType=ct;
servings=s;
}

void_displayBakingDetails()
{
cout<<"enter the baking temperature:"<<bakingTemperature<<endl;
cout<<"enetr the baking time:"<<bakingTime<<endl;
}
};
class specialBakedRecipe: public bakedrecipe
{
string specialDetails;
string chefName;
public:
specialBakedRecipe( string n ,string c,int s,int bt, int btime,string i,string
ch){
name=n;
cuisionType=c;
servings=s;
bakingTemperature=bt;
bakingTime=btime;
spicalingredient=i;
chefName=ch;
}
void_ displaySpicalDetails()
{
cout<<"the spical ingredient was: "<<spicalingredient<<endl;
cout<<" schef name: "<<chefName<<endl;

};
int main()
{
SpicalBakedRecipe.myspicalbakedrecipe("choclate lava
cake","french",4,180,25 "molten choclate","chef pierre");
myspicalbakedrecipe.displayBasicDetials();
myspicalbakedrecipe.displayBakingDetials();
myspicalbakedrecipe.displaySpicalDetials();

return 0;
}

You might also like