This commit is contained in:
RafayAhmad7548 2024-06-16 18:53:25 +05:00
parent 37776af5db
commit ab03d5f10c
4045 changed files with 286212 additions and 3 deletions

View file

@ -0,0 +1,130 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
IceCream iceCream1("Vanilla", "Chocolate", "Cone", 100);
IceCream iceCream2("Strawberry", 50);
IceCream iceCream3(iceCream1);
cout<<"Ice Cream 1: "<<iceCream1.getFlavor()<< " " <<iceCream1.getTopping()<< " " <<iceCream1.getServingType()<< " " <<iceCream1.getPrice()<<endl;
cout<<"Ice Cream 2: "<<iceCream2.getTopping()<< " " <<iceCream2.getPrice()<<endl;
cout<<"Ice Cream 3: "<<iceCream3.getFlavor()<< " " <<iceCream3.getTopping()<< " " <<iceCream3.getServingType()<< " " <<iceCream3.getPrice()<<endl;
iceCream1.makeIceCream();
iceCream2.makeIceCream();
iceCream3.makeIceCream();
cout<<"Ice Cream 1 Status: "<<iceCream1.checkStatus()<<endl;
cout<<"Ice Cream 2 Status: "<<iceCream2.checkStatus()<<endl;
cout<<"Ice Cream 3 Status: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,60 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : flavor(flavor), topping(topping), servingType(servingType), price(price), isReady(false){
int length = 0;
while(flavor[length] != '\0') length++;
this->flavor = new char[length];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
flavor[length] = '\0';
length = 0;
while(iceCream.topping[length] != '\0') length++;
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = 0;
while(iceCream.servingType[length] != '\0') length++;
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), topping(topping), servingType(nullptr), isReady(false), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = 0;
while(iceCream.flavor[length] != '\0') length++;
flavor = new char[length];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = 0;
while(iceCream.topping[length] != '\0') length++;
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = 0;
while(iceCream.servingType[length] != '\0') length++;
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,144 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,150 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
double price;
cout<<"Enter details for Ice Cream 1:\n";
cout<<"Flavor: ";
getline(cin, flavor);
cout<<"Topping: ";
getline(cin, topping);
cout<<"Serving Type: ";
getline(cin, servingType);
cout<<"Price: ";
cin>>price;
cin.ignore(); // To consume the newline character left by cin
IceCream iceCream1(flavor, topping.c_str(), servingType.c_str(), price);
cout<<"\nEnter details for Ice Cream 2:\n";
cout<<"Topping: ";
getline(cin, topping);
cout<<"Price: ";
cin>>price;
cin.ignore(); // To consume the newline character left by cin
IceCream iceCream2(topping, price);
IceCream iceCream3(iceCream1);
cout<<"\nIce Cream 1: "<<iceCream1.getFlavor()<< " " <<iceCream1.getTopping()<< " " <<iceCream1.getServingType()<< " " <<iceCream1.getPrice()<<endl;
cout<<"Ice Cream 2: "<<iceCream2.getTopping()<< " " <<iceCream2.getPrice()<<endl;
cout<<"Ice Cream 3: "<<iceCream3.getFlavor()<< " " <<iceCream3.getTopping()<< " " <<iceCream3.getServingType()<< " " <<iceCream3.getPrice()<<endl;
iceCream1.makeIceCream();
iceCream2.makeIceCream();
iceCream3.makeIceCream();
cout<<"\nIce Cream 1 is ready: "<<(iceCream1.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 2 is ready: "<<(iceCream2.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 3 is ready: "<<(iceCream3.checkStatus() ? "Yes" : "No")<<endl;
return 0;
}

View file

@ -0,0 +1,63 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), topping(topping), servingType(nullptr), isReady(false), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = 0;
while(iceCream.flavor[length] != '\0') length++;
flavor = new char[length];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = 0;
while(iceCream.topping[length] != '\0') length++;
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = 0;
while(iceCream.servingType[length] != '\0') length++;
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,108 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,74 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,130 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
#include <cstring>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
// use str copy function to copy the strings and lenstr function to get the length of the string
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
// use strcopy to deep copy and lenstr
int length = lenstr(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,114 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
// generate getter and setters
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
bool getIsReady(){
return isReady;
}
double getPrice(){
return price;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setIsReady(bool isReady){
this->isReady = isReady;
}
void setPrice(double price){
this->price = price;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,132 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
#include <cstring>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strlen(iceCream.flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, iceCream.flavor);
length = strlen(iceCream.topping);
this->topping = new char[length+1];
strcpy(this->topping, iceCream.topping);
length = strlen(iceCream.servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, iceCream.servingType);
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,129 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
#include <cstring>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strlen(iceCream.flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, iceCream.flavor);
length = strlen(iceCream.topping);
this->topping = new char[length+1];
strcpy(this->topping, iceCream.topping);
length = strlen(iceCream.servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, iceCream.servingType);
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
}
void setTopping(char *topping){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
void setServingType(char *servingType){
int length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,129 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
#include <cstring>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strlen(iceCream.flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, iceCream.flavor);
length = strlen(iceCream.topping);
this->topping = new char[length+1];
strcpy(this->topping, iceCream.topping);
length = strlen(iceCream.servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, iceCream.servingType);
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
}
void setTopping(char *topping){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
void setServingType(char *servingType){
int length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1(flavor, (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,112 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,129 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
#include <cstring>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strlen(iceCream.flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, iceCream.flavor);
length = strlen(iceCream.topping);
this->topping = new char[length+1];
strcpy(this->topping, iceCream.topping);
length = strlen(iceCream.servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, iceCream.servingType);
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
}
void setTopping(char *topping){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
void setServingType(char *servingType){
int length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,130 @@
/*
Rafay Ahmad
23I-2526
Assignment 3
*/
#include <iostream>
#include <cstring>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strlen(iceCream.flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, iceCream.flavor);
length = strlen(iceCream.topping);
this->topping = new char[length+1];
strcpy(this->topping, iceCream.topping);
length = strlen(iceCream.servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, iceCream.servingType);
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
}
void setTopping(char *topping){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
void setServingType(char *servingType){
int length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,144 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,66 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int length(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = 0;
while(flavor[length] != '\0') length++;
this->flavor = new char[length];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = 0;
while(topping[length] != '\0') length++;
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = 0;
while(servingType[length] != '\0') length++;
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), topping(topping), servingType(nullptr), isReady(false), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = 0;
while(iceCream.flavor[length] != '\0') length++;
flavor = new char[length];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = 0;
while(iceCream.topping[length] != '\0') length++;
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = 0;
while(iceCream.servingType[length] != '\0') length++;
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,138 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,150 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
double price;
cout<<"Enter details for Ice Cream 1:\n";
cout<<"Flavor: ";
getline(cin, flavor);
cout<<"Topping: ";
getline(cin, topping);
cout<<"Serving Type: ";
getline(cin, servingType);
cout<<"Price: ";
cin>>price;
IceCream iceCream1(flavor, topping, servingType, price);
cout<<"\nEnter details for Ice Cream 2:\n";
cout<<"Topping: ";
getline(cin, topping);
cout<<"Price: ";
cin>>price;
IceCream iceCream2(topping, price);
IceCream iceCream3(iceCream1);
cout<<"\nIce Cream 1: "<<iceCream1.getFlavor()<< " " <<iceCream1.getTopping()<< " " <<iceCream1.getServingType()<< " " <<iceCream1.getPrice()<<endl;
cout<<"Ice Cream 2: "<<iceCream2.getTopping()<< " " <<iceCream2.getPrice()<<endl;
cout<<"Ice Cream 3: "<<iceCream3.getFlavor()<< " " <<iceCream3.getTopping()<< " " <<iceCream3.getServingType()<< " " <<iceCream3.getPrice()<<endl;
iceCream1.makeIceCream();
iceCream2.makeIceCream();
iceCream3.makeIceCream();
cout<<"\nIce Cream 1 is ready: "<<(iceCream1.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 2 is ready: "<<(iceCream2.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 3 is ready: "<<(iceCream3.checkStatus() ? "Yes" : "No")<<endl;
return 0;
}

View file

@ -0,0 +1,129 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
#include <cstring>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strlen(iceCream.flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, iceCream.flavor);
length = strlen(iceCream.topping);
this->topping = new char[length+1];
strcpy(this->topping, iceCream.topping);
length = strlen(iceCream.servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, iceCream.servingType);
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
}
void setTopping(char *topping){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
void setServingType(char *servingType){
int length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,136 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
#include <cstring>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,60 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), topping(topping), servingType(nullptr), isReady(false), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,60 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : flavor(flavor), topping(topping), servingType(servingType), price(price), isReady(false){
int length = 0;
while(flavor[length] != '\0') length++;
this->flavor = new char[length];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = 0;
while(topping[length] != '\0') length++;
for(int i=0;i<length;i++) this->topping[i] = topping[i];
topping[length] = '\0';
length = 0;
while(iceCream.servingType[length] != '\0') length++;
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), topping(topping), servingType(nullptr), isReady(false), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = 0;
while(iceCream.flavor[length] != '\0') length++;
flavor = new char[length];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = 0;
while(iceCream.topping[length] != '\0') length++;
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = 0;
while(iceCream.servingType[length] != '\0') length++;
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,150 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
double price;
cout<<"Enter details for Ice Cream 1:\n";
cout<<"Flavor: ";
getline(cin, flavor);
cout<<"Topping: ";
getline(cin, topping);
cout<<"Serving Type: ";
getline(cin, servingType);
cout<<"Price: ";
cin>>price;
cin.ignore(); // To consume the newline character left by cin
IceCream iceCream1(flavor, topping, servingType, price);
cout<<"\nEnter details for Ice Cream 2:\n";
cout<<"Topping: ";
getline(cin, topping);
cout<<"Price: ";
cin>>price;
cin.ignore(); // To consume the newline character left by cin
IceCream iceCream2(topping, price);
IceCream iceCream3(iceCream1);
cout<<"\nIce Cream 1: "<<iceCream1.getFlavor()<< " " <<iceCream1.getTopping()<< " " <<iceCream1.getServingType()<< " " <<iceCream1.getPrice()<<endl;
cout<<"Ice Cream 2: "<<iceCream2.getTopping()<< " " <<iceCream2.getPrice()<<endl;
cout<<"Ice Cream 3: "<<iceCream3.getFlavor()<< " " <<iceCream3.getTopping()<< " " <<iceCream3.getServingType()<< " " <<iceCream3.getPrice()<<endl;
iceCream1.makeIceCream();
iceCream2.makeIceCream();
iceCream3.makeIceCream();
cout<<"\nIce Cream 1 is ready: "<<(iceCream1.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 2 is ready: "<<(iceCream2.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 3 is ready: "<<(iceCream3.checkStatus() ? "Yes" : "No")<<endl;
return 0;
}

View file

@ -0,0 +1,115 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,126 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
// use str copy function to copy the strings and lenstr function to get the length of the string
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,69 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), topping(topping), servingType(nullptr), isReady(false), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,62 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), topping(topping), servingType(nullptr), isReady(false), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,75 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,114 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setIsReady(bool isReady){
this->isReady = isReady;
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
bool getIsReady(){
return isReady;
}
double getPrice(){
return price;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,152 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
// take input in way not using cstring
string flavor, topping, servingType;
double price;
cout<<"Enter details for Ice Cream 1:\n";
cout<<"Flavor: ";
getline(cin, flavor);
cout<<"Topping: ";
getline(cin, topping);
cout<<"Serving Type: ";
getline(cin, servingType);
cout<<"Price: ";
cin>>price;
IceCream iceCream1(flavor, topping, servingType, price);
cout<<"\nEnter details for Ice Cream 2:\n";
cout<<"Topping: ";
getline(cin, topping);
cout<<"Price: ";
cin>>price;
flavor
IceCream iceCream2(topping, price);
IceCream iceCream3(iceCream1);
cout<<"\nIce Cream 1: "<<iceCream1.getFlavor()<< " " <<iceCream1.getTopping()<< " " <<iceCream1.getServingType()<< " " <<iceCream1.getPrice()<<endl;
cout<<"Ice Cream 2: "<<iceCream2.getTopping()<< " " <<iceCream2.getPrice()<<endl;
cout<<"Ice Cream 3: "<<iceCream3.getFlavor()<< " " <<iceCream3.getTopping()<< " " <<iceCream3.getServingType()<< " " <<iceCream3.getPrice()<<endl;
iceCream1.makeIceCream();
iceCream2.makeIceCream();
iceCream3.makeIceCream();
cout<<"\nIce Cream 1 is ready: "<<(iceCream1.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 2 is ready: "<<(iceCream2.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 3 is ready: "<<(iceCream3.checkStatus() ? "Yes" : "No")<<endl;
return 0;
}

View file

@ -0,0 +1 @@
{"version":1,"resource":"file:///home/rafayahmad/Stuff/a3/q1.cpp","entries":[{"id":"yIPb.cpp","timestamp":1711106138442},{"id":"haDZ.cpp","timestamp":1711106200300},{"id":"zZe8.cpp","timestamp":1711106317868},{"id":"3JF8.cpp","timestamp":1711106557155},{"id":"QGgH.cpp","timestamp":1711106578568},{"id":"gPSh.cpp","timestamp":1711106605648},{"id":"mpWg.cpp","timestamp":1711106633704},{"id":"FT8U.cpp","timestamp":1711106703324},{"id":"6qRB.cpp","timestamp":1711106780780},{"id":"OoT5.cpp","timestamp":1711106842760},{"id":"WRNf.cpp","timestamp":1711106884587},{"id":"yfh3.cpp","timestamp":1711106904790},{"id":"VRCR.cpp","timestamp":1711106969640},{"id":"7Xvr.cpp","timestamp":1711107012257},{"id":"WoIJ.cpp","timestamp":1711107029017},{"id":"mmTJ.cpp","timestamp":1711107077970},{"id":"8vAe.cpp","timestamp":1711107198667},{"id":"YtVV.cpp","timestamp":1711107216224},{"id":"7Nul.cpp","timestamp":1711107248744},{"id":"APbo.cpp","timestamp":1711107300014},{"id":"rZAp.cpp","timestamp":1711107313824},{"id":"g9me.cpp","timestamp":1711107393005},{"id":"mQgt.cpp","timestamp":1711107510465},{"id":"z8uD.cpp","timestamp":1711107587379},{"id":"twka.cpp","timestamp":1711107623766},{"id":"2439.cpp","timestamp":1711107653463},{"id":"flsA.cpp","timestamp":1711107811921},{"id":"6TOs.cpp","timestamp":1711107834727},{"id":"RiSL.cpp","timestamp":1711107878924},{"id":"KxwG.cpp","timestamp":1711107898411},{"id":"xkJO.cpp","timestamp":1711108029145},{"id":"njug.cpp","timestamp":1711108079299},{"id":"b7rd.cpp","timestamp":1711108131736},{"id":"TWLp.cpp","timestamp":1711108169323},{"id":"y0Ht.cpp","timestamp":1711175389208},{"id":"gE4g.cpp","timestamp":1711175481352},{"id":"IHb8.cpp","timestamp":1711175491409},{"id":"p8vo.cpp","timestamp":1711175510981},{"id":"5Dqr.cpp","timestamp":1711175805934},{"id":"EVju.cpp","timestamp":1711175817514},{"id":"Twsl.cpp","timestamp":1711176102394},{"id":"8aaQ.cpp","timestamp":1711176167355},{"id":"OZGD.cpp","timestamp":1711176203690},{"id":"j1l1.cpp","timestamp":1711176219802},{"id":"9Ya5.cpp","timestamp":1711176244357},{"id":"9xv4.cpp","timestamp":1711176290120},{"id":"AE0b.cpp","timestamp":1711607032676},{"id":"LhPp.cpp","timestamp":1711607185237},{"id":"AaQ6.cpp","timestamp":1711792442784},{"id":"DpWJ.cpp","timestamp":1711869508630}]}

View file

@ -0,0 +1,150 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
double price;
cout<<"Enter details for Ice Cream 1:\n";
cout<<"Flavor: ";
getline(cin, flavor);
cout<<"Topping: ";
getline(cin, topping);
cout<<"Serving Type: ";
getline(cin, servingType);
cout<<"Price: ";
cin>>price;
cin.ignore(); // To consume the newline character left by cin
IceCream iceCream1(flavor.c_str(), topping.c_str(), servingType.c_str(), price);
cout<<"\nEnter details for Ice Cream 2:\n";
cout<<"Topping: ";
getline(cin, topping);
cout<<"Price: ";
cin>>price;
cin.ignore(); // To consume the newline character left by cin
IceCream iceCream2(topping.c_str(), price);
IceCream iceCream3(iceCream1);
cout<<"\nIce Cream 1: "<<iceCream1.getFlavor()<< " " <<iceCream1.getTopping()<< " " <<iceCream1.getServingType()<< " " <<iceCream1.getPrice()<<endl;
cout<<"Ice Cream 2: "<<iceCream2.getTopping()<< " " <<iceCream2.getPrice()<<endl;
cout<<"Ice Cream 3: "<<iceCream3.getFlavor()<< " " <<iceCream3.getTopping()<< " " <<iceCream3.getServingType()<< " " <<iceCream3.getPrice()<<endl;
iceCream1.makeIceCream();
iceCream2.makeIceCream();
iceCream3.makeIceCream();
cout<<"\nIce Cream 1 is ready: "<<(iceCream1.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 2 is ready: "<<(iceCream2.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 3 is ready: "<<(iceCream3.checkStatus() ? "Yes" : "No")<<endl;
return 0;
}

View file

@ -0,0 +1,120 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
// write code to check all capabaluty of icecream class
IceCream iceCream1("Vanilla", "Chocolate", "Cone", 100);
IceCream iceCream2("Strawberry", 50);
return 0;
}

View file

@ -0,0 +1,137 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
// take input for icecreams
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,60 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : flavor(flavor), topping(topping), servingType(servingType), price(price), isReady(false){
int length = 0;
while(flavor[length] != '\0') length++;
this->flavor = new char[length];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = 0;
while(topping[length] != '\0') length++;
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = 0;
while(servingType[length] != '\0') length++;
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), topping(topping), servingType(nullptr), isReady(false), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = 0;
while(iceCream.flavor[length] != '\0') length++;
flavor = new char[length];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = 0;
while(iceCream.topping[length] != '\0') length++;
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = 0;
while(iceCream.servingType[length] != '\0') length++;
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,44 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : flavor(flavor), topping(topping), servingType(servingType), price(price), isReady(false){}
IceCream(char *topping, double price) : topping(topping), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = 0;
while(iceCream.flavor[length] != '\0') length++;
flavor = new char[length];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = 0;
while(iceCream.topping[length] != '\0') length++;
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = 0;
while(iceCream.servingType[length] != '\0') length++;
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,135 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
#include <cstring>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){
flavor = nullptr;
topping = nullptr;
servingType = nullptr;
isReady = false;
price = 0;
}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strlen(flavor);
this->flavor = new char[length+1];
strcpy(this->flavor, flavor);
length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
length = strlen(servingType);
this->servingType = new char[length+1];
strcpy(this->servingType, servingType);
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strlen(topping);
this->topping = new char[length+1];
strcpy(this->topping, topping);
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,117 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
// write code to check all capabaluty of icecream class
return 0;
}

View file

@ -0,0 +1,75 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,60 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = 0;
while(flavor[length] != '\0') length++;
this->flavor = new char[length];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = 0;
while(topping[length] != '\0') length++;
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = 0;
while(servingType[length] != '\0') length++;
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), topping(topping), servingType(nullptr), isReady(false), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = 0;
while(iceCream.flavor[length] != '\0') length++;
flavor = new char[length];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = 0;
while(iceCream.topping[length] != '\0') length++;
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = 0;
while(iceCream.servingType[length] != '\0') length++;
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,151 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
double price;
cout<<"Enter details for Ice Cream 1:\n";
cout<<"Flavor: ";
getline(cin, flavor);
cout<<"Topping: ";
getline(cin, topping);
cout<<"Serving Type: ";
getline(cin, servingType);
cout<<"Price: ";
cin>>price;
IceCream iceCream1(flavor, topping, servingType, price);
cout<<"\nEnter details for Ice Cream 2:\n";
cout<<"Topping: ";
getline(cin, topping);
cout<<"Price: ";
cin>>price;
IceCream iceCream2(topping, price);
IceCream iceCream3(iceCream1);
cout<<"\nIce Cream 1: "<<iceCream1.getFlavor()<< " " <<iceCream1.getTopping()<< " " <<iceCream1.getServingType()<< " " <<iceCream1.getPrice()<<endl;
cout<<"Ice Cream 2: "<<iceCream2.getTopping()<< " " <<iceCream2.getPrice()<<endl;
cout<<"Ice Cream 3: "<<iceCream3.getFlavor()<< " " <<iceCream3.getTopping()<< " " <<iceCream3.getServingType()<< " " <<iceCream3.getPrice()<<endl;
iceCream1.makeIceCream();
iceCream2.makeIceCream();
iceCream3.makeIceCream();
cout<<"\nIce Cream 1 is ready: "<<(iceCream1.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 2 is ready: "<<(iceCream2.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 3 is ready: "<<(iceCream3.checkStatus() ? "Yes" : "No")<<endl;
return 0;
}

View file

@ -0,0 +1,138 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
cout<<"Enter the flavor of ice cream: ";
getline(cin, flavor);
cout<<"Enter the topping of ice cream: ";
getline(cin, topping);
cout<<"Enter the serving type of ice cream: ";
getline(cin, servingType);
double price;
cout<<"Enter the price of ice cream: ";
cin>>price;
IceCream iceCream1((char*)flavor.c_str(), (char*)topping.c_str(), (char*)servingType.c_str(), price);
iceCream1.makeIceCream();
cout<<"Ice Cream 1 is ready: "<<iceCream1.checkStatus()<<endl;
IceCream iceCream2((char*)topping.c_str(), price);
iceCream2.makeIceCream();
cout<<"Ice Cream 2 is ready: "<<iceCream2.checkStatus()<<endl;
IceCream iceCream3 = iceCream1;
cout<<"Ice Cream 3 is ready: "<<iceCream3.checkStatus()<<endl;
return 0;
}

View file

@ -0,0 +1,115 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,121 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
// write code to check all capabaluty of icecream class
IceCream iceCream1("Vanilla", "Chocolate", "Cone", 100);
IceCream iceCream2("Strawberry", 50);
IceCream iceCream3(iceCream1);
cout<<"Ice Cream 1: "<<iceCream1.getFlavor()<< " " <<iceCream1.getTopping()<< " " <<iceCream1.getServingType()<< " " <<iceCream1.getPrice()<<endl;
return 0;
}

View file

@ -0,0 +1,151 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
string flavor, topping, servingType;
double price;
cout<<"Enter details for Ice Cream 1:\n";
cout<<"Flavor: ";
getline(cin, flavor);
cout<<"Topping: ";
getline(cin, topping);
cout<<"Serving Type: ";
getline(cin, servingType);
cout<<"Price: ";
cin>>price;
IceCream iceCream1("aafa", topping, servingType, price);
cout<<"\nEnter details for Ice Cream 2:\n";
cout<<"Topping: ";
getline(cin, topping);
cout<<"Price: ";
cin>>price;
IceCream iceCream2(topping, price);
IceCream iceCream3(iceCream1);
cout<<"\nIce Cream 1: "<<iceCream1.getFlavor()<< " " <<iceCream1.getTopping()<< " " <<iceCream1.getServingType()<< " " <<iceCream1.getPrice()<<endl;
cout<<"Ice Cream 2: "<<iceCream2.getTopping()<< " " <<iceCream2.getPrice()<<endl;
cout<<"Ice Cream 3: "<<iceCream3.getFlavor()<< " " <<iceCream3.getTopping()<< " " <<iceCream3.getServingType()<< " " <<iceCream3.getPrice()<<endl;
iceCream1.makeIceCream();
iceCream2.makeIceCream();
iceCream3.makeIceCream();
cout<<"\nIce Cream 1 is ready: "<<(iceCream1.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 2 is ready: "<<(iceCream2.checkStatus() ? "Yes" : "No")<<endl;
cout<<"Ice Cream 3 is ready: "<<(iceCream3.checkStatus() ? "Yes" : "No")<<endl;
return 0;
}

View file

@ -0,0 +1,117 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,44 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : flavor(flavor), topping(topping), servingType(servingType), price(price), isReady(false){}
IceCream(char *topping, double price) : topping(topping), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = 0;
while(iceCream.flavor[length+1] != '\0') length++;
flavor = new char[length];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = 0;
while(iceCream.topping[length+1] != '\0') length++;
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = 0;
while(iceCream.servingType[length+1] != '\0') length++;
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,64 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[i] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), topping(topping), servingType(nullptr), isReady(false), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,117 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int strL(char *s){
int length = 0;
while(s[length] != '\0') length++;
return length;
}
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : price(price), isReady(false){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
IceCream(char *topping, double price) : flavor(nullptr), servingType(nullptr), isReady(false), price(price){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = strL(flavor);
flavor = new char[length+1];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = strL(topping);
topping = new char[length+1];
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = strL(servingType);
servingType = new char[length+1];
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
~IceCream(){
delete[] flavor;
delete[] topping;
delete[] servingType;
}
void setFlavor(char *flavor){
int length = strL(flavor);
this->flavor = new char[length+1];
for(int i=0;i<length;i++) this->flavor[i] = flavor[i];
this->flavor[length] = '\0';
}
void setTopping(char *topping){
int length = strL(topping);
this->topping = new char[length+1];
for(int i=0;i<length;i++) this->topping[i] = topping[i];
this->topping[length] = '\0';
}
void setServingType(char *servingType){
int length = strL(servingType);
this->servingType = new char[length+1];
for(int i=0;i<length;i++) this->servingType[i] = servingType[i];
this->servingType[length] = '\0';
}
void setPrice(double price){
this->price = price;
}
char* getFlavor(){
return flavor;
}
char* getTopping(){
return topping;
}
char* getServingType(){
return servingType;
}
double getPrice(){
return price;
}
void makeIceCream(){
if(topping != nullptr) isReady = true;
}
bool checkStatus(){
return isReady;
}
};
int main(){
// write code to check all capabaluty of icecream class
IceCream iceCream1("Vanilla", "Chocolate", "Cone", 100);
return 0;
}

View file

@ -0,0 +1,44 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class IceCream{
char *flavor;
char *topping;
char *servingType;
bool isReady;
double price;
public:
IceCream(){}
IceCream(char *flavor, char *topping, char *servingType, double price) : flavor(flavor), topping(topping), servingType(servingType), price(price), isReady(false){}
IceCream(char *topping, double price) : flavor(nullptr), topping(topping), servingType(nullptr), price(price){}
IceCream(const IceCream &iceCream) : isReady(iceCream.isReady), price(iceCream.price){
int length = 0;
while(iceCream.flavor[length] != '\0') length++;
flavor = new char[length];
for(int i=0;i<length;i++) flavor[i] = iceCream.flavor[i];
flavor[length] = '\0';
length = 0;
while(iceCream.topping[length] != '\0') length++;
for(int i=0;i<length;i++) topping[i] = iceCream.topping[i];
topping[length] = '\0';
length = 0;
while(iceCream.servingType[length] != '\0') length++;
for(int i=0;i<length;i++) servingType[i] = iceCream.servingType[i];
servingType[length] = '\0';
}
};
int main(){
return 0;
}