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;
}