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,73 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
int current;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts), current(0){
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
}
void addItem(Product product, int qty){
products[current] = product;
qtys[current] = qty;
current++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,86 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
Customer(string name, string address) : name(name), address(address){}
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
Product(string name, double price) : name(name), price(price){}
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,95 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
Product *tmpP = new Product[noOfProducts+1];
int *tmpQ = new int[noOfProducts+1];
for(int i=0;i<noOfProducts;i++){
}
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,65 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts){
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
}
void addItem(Product product, int qty){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,94 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
Customer(string name, string address) : name(name), address(address){}
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
Product(){}
Product(string name, double price) : name(name), price(price){}
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer, Product product, int qty) : customer(customer), noOfProducts(0){
items = new OrderItem[1]{product, qty};
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
Order order(Customer("ammar", "1233"), Product("milk", 50), 10);
order.addItem(Product("eggs", 40), 10);
order.displayOrder();
return 0;
}

View file

@ -0,0 +1,76 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts){
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
}
~Order(){
delete[] products;
delete[] qtys;
}
void addItem(Product product, int qty){
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,85 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
noOfProducts++;
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,84 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,98 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){
products = new Product[1];
qtys = new int[1];
}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
Product *tmpP = new Product[noOfProducts+1];
int *tmpQ = new int[noOfProducts+1];
for(int i=0;i<noOfProducts;i++){
}
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,73 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){}
~Order(){
delete[] products;
delete[] qtys;
}
void addItem(Product product, int qty){
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,65 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts){
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
}
void addItem(Product product, int qty){
products[i] = product;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,88 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,93 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){}
items = new OrderItem[1];
}
~Order(){
}
void addItem(Product product, int qty){
Product *tmpP = new Product[noOfProducts+1];
int *tmpQ = new int[noOfProducts+1];
for(int i=0;i<noOfProducts;i++){
tmpP[i] = products[i];
tmpQ[i] = qtys[i];
}
tmpP[noOfProducts] = product;
tmpQ[noOfProducts] = qty;
delete[] products;
delete[] qtys;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,82 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,86 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
Customer(string name, string address) : name(name), address(address){}
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
Product(string name, double price) : name(name), price(price){}
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer, Product product, int qty) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,83 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,84 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
Customer(string name, string address) : name(name), address(address){}
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,79 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,89 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<endl;
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,98 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){
products = new Product[1];
qtys = new int[1];
}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
Product *tmpP = new Product[noOfProducts+1];
int *tmpQ = new int[noOfProducts+1];
for(int i=0;i<noOfProducts;i++){
tmpP[i] = products[i];
tmpQ[i] = qtys[i];
}
tmpP[noOfProducts] = product;
tmpQ[noOfProducts] = qty;
delete[] products;
delete[] qtys;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,80 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,100 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){
products = new Product[1];
qtys = new int[1];
}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
Product *tmpP = new Product[noOfProducts+1];
int *tmpQ = new int[noOfProducts+1];
for(int i=0;i<noOfProducts;i++){
tmpP[i] = products[i];
tmpQ[i] = qtys[i];
}
tmpP[noOfProducts] = product;
tmpQ[noOfProducts] = qty;
delete[] products;
delete[] qtys;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,76 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
delete[] qtys;
}
void addItem(Product product, int qty){
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,84 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,84 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
noOfProducts++;
products = new Product[noOfProducts];
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,63 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int noOfProducts;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts){
products = new Product[noOfProducts];
}
void addItem(Product product, int index){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,81 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,101 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){
products = new Product[1];
qtys = new int[1];
}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
Product *tmpP = new Product[noOfProducts+1];
int *tmpQ = new int[noOfProducts+1];
for(int i=0;i<noOfProducts;i++){
tmpP[i] = products[i];
tmpQ[i] = qtys[i];
}
tmpP[noOfProducts] = product;
tmpQ[noOfProducts] = qty;
delete[] products;
delete[] qtys;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,93 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
Product *tmpP = new Product[noOfProducts+1];
int *tmpQ = new int[noOfProducts+1];
for(int i=0;i<noOfProducts;i++){
tmpP[i] = products[i];
tmpQ[i] = qtys[i];
}
tmpP[noOfProducts] = product;
tmpQ[noOfProducts] = qty;
delete[] products;
delete[] qtys;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,83 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1 @@
{"version":1,"resource":"file:///home/rafayahmad/Stuff/OOP/lab13/q1.cpp","entries":[{"id":"yiIp.cpp","timestamp":1714363481585},{"id":"YdSd.cpp","timestamp":1714363494136},{"id":"lgF5.cpp","timestamp":1714363557532},{"id":"mDlY.cpp","timestamp":1714363768205},{"id":"vaGp.cpp","timestamp":1714363788619},{"id":"7TeD.cpp","timestamp":1714363858651},{"id":"EaKs.cpp","timestamp":1714363872255},{"id":"g2p6.cpp","timestamp":1714363930287},{"id":"s2J7.cpp","timestamp":1714363970514},{"id":"4OoA.cpp","timestamp":1714363985372},{"id":"esBL.cpp","timestamp":1714364023456},{"id":"92Ow.cpp","timestamp":1714364080189},{"id":"m3T5.cpp","timestamp":1714364155720},{"id":"CetG.cpp","timestamp":1714364168248},{"id":"lfqp.cpp","timestamp":1714364457499},{"id":"rzJv.cpp","timestamp":1714364564531},{"id":"TCkE.cpp","timestamp":1714364847268},{"id":"vuEV.cpp","timestamp":1714364879166},{"id":"LwrL.cpp","timestamp":1714364889523},{"id":"BUxj.cpp","timestamp":1714365008865},{"id":"X6Nm.cpp","timestamp":1714365033356},{"id":"9c83.cpp","timestamp":1714365047299},{"id":"6eLi.cpp","timestamp":1714365130230},{"id":"CJ0X.cpp","timestamp":1714365196655},{"id":"mINX.cpp","timestamp":1714365226621},{"id":"mRXn.cpp","timestamp":1714365259444},{"id":"RMOk.cpp","timestamp":1714365288137},{"id":"T5di.cpp","timestamp":1714365323874},{"id":"bOXt.cpp","timestamp":1714365339890},{"id":"Ij1v.cpp","timestamp":1714365369987},{"id":"cK0b.cpp","timestamp":1714365407483},{"id":"OXdh.cpp","timestamp":1714365422273},{"id":"S4oV.cpp","timestamp":1714365443327},{"id":"aI9v.cpp","timestamp":1714365480137},{"id":"xKrY.cpp","timestamp":1714365505860},{"id":"e96Y.cpp","timestamp":1714365534337},{"id":"UfKX.cpp","timestamp":1714365603291},{"id":"PSIA.cpp","timestamp":1714365686921},{"id":"EunK.cpp","timestamp":1714365699708},{"id":"IjfU.cpp","timestamp":1714365741906},{"id":"NwoT.cpp","timestamp":1714365797023},{"id":"5QV7.cpp","timestamp":1714365822360},{"id":"JyOk.cpp","timestamp":1714365888928},{"id":"i4Dd.cpp","timestamp":1714365924192},{"id":"wx2H.cpp","timestamp":1714365947992},{"id":"ujCO.cpp","timestamp":1714365976276},{"id":"wiKf.cpp","timestamp":1714366121802},{"id":"7pBt.cpp","timestamp":1714366194077},{"id":"tbi3.cpp","timestamp":1714366342481},{"id":"wAgl.cpp","timestamp":1714366361398}]}

View file

@ -0,0 +1,79 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
int current;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts), current(0){
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
}
~Order(){
delete[] products;
delete[] qtys;
}
void addItem(Product product, int qty){
products[current] = product;
qtys[current] = qty;
current++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,67 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
int current;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts), current(0){
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
}
void addItem(Product product, int qty){
products[i] = product;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,86 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
Customer(string name, string address) : name(name), address(address){}
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
Product(string name, double price) : name(name), price(price){}
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer, Product product, int qty) : customer(customer), noOfProducts(0){
items = new OrderItem[1]{product, qty};
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,73 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){}
~Order(){
delete[] products;
delete[] qtys;
}
void addItem(Product product, int qty){
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,63 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int noOfProducts;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts){
products = new Product[noOfProducts];
}
void addItem(Product product, int qty){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,76 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
}
~Order(){
delete[] products;
delete[] qtys;
}
void addItem(Product product, int qty){
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,64 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts){
products = new Product[noOfProducts];
}
void addItem(Product product, int qty){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,99 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){
products = new Product[1];
qtys = new int[1];
}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
Product *tmpP = new Product[noOfProducts+1];
int *tmpQ = new int[noOfProducts+1];
for(int i=0;i<noOfProducts;i++){
tmpP[i] = products[i];
tmpQ[i] = qtys[i];
}
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,102 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){
products = new Product[1];
qtys = new int[1];
}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
Product *tmpP = new Product[noOfProducts+1];
int *tmpQ = new int[noOfProducts+1];
for(int i=0;i<noOfProducts;i++){
tmpP[i] = products[i];
tmpQ[i] = qtys[i];
}
tmpP[noOfProducts] = product;
tmpQ[noOfProducts] = qty;
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,73 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){}
~Order(){
delete[] products;
delete[] qtys;
}
void addItem(Product product, int qty){
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,69 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
int current;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts), current(0){
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
}
void addItem(Product product, int qty){
products[current] = product;
qtys[current] = qty;
current++;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,94 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
Customer(string name, string address) : name(name), address(address){}
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
Product(){}
Product(string name, double price) : name(name), price(price){}
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer, Product product, int qty) : customer(customer), noOfProducts(1){
items = new OrderItem[1]{product, qty};
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
Order order(Customer("ammar", "1233"), Product("milk", 50), 10);
order.addItem(Product("eggs", 40), 10);
order.displayOrder();
return 0;
}

View file

@ -0,0 +1,87 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
Customer(string name, string address) : name(name), address(address){}
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
Product(){}
Product(string name, double price) : name(name), price(price){}
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer, Product product, int qty) : customer(customer), noOfProducts(0){
items = new OrderItem[1]{product, qty};
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,65 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts){
products = new Product[noOfProducts];
qtys = new int[noOfProducts];
}
void addItem(Product product, int qty){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,79 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int *qtys;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0), products(nullptr), qtys(nullptr){}
~Order(){
if(products != nullptr){
delete[] products;
products = nullptr;
}
if(qtys != nullptr){
delete[] qtys;
qtys = nullptr;
}
}
void addItem(Product product, int qty){
products[noOfProducts] = product;
qtys[noOfProducts] = qty;
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,89 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
Customer(string name, string address) : name(name), address(address){}
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
Product(){}
Product(string name, double price) : name(name), price(price){}
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer, Product product, int qty) : customer(customer), noOfProducts(1){
items = new OrderItem[1]{product, qty};
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
Order order(Customer("ammar", "1233"), Product("milk", 50), 10);
order.addItem(Product("eggs", 40), 10);
order.displayOrder();
return 0;
}

View file

@ -0,0 +1,91 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
Customer(string name, string address) : name(name), address(address){}
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
Product(){}
Product(string name, double price) : name(name), price(price){}
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer, Product product, int qty) : customer(customer), noOfProducts(0){
items = new OrderItem[1]{product, qty};
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
Order order(Customer("ammar", "1233"), Product("milk", 50), 10);
return 0;
}

View file

@ -0,0 +1,86 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
Customer(string name, string address) : name(name), address(address){}
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
Product(string name, double price) : name(name), price(price){}
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
delete[] items;
items = tmp;
noOfProducts++;
}
void displayOrder(){
cout<<"Name: "<<customer.getName()<<endl;
cout<<"Address: "<<customer.getAddress()<<endl;
for(int i=0;i<noOfProducts;i++){
cout<<"product name: "<<items[i].product.getName()<<"\t";
cout<<"product price: "<<items[i].product.getPrice()<<endl;
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,82 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
struct OrderItem{
Product product;
int qty;
};
OrderItem *items;
int noOfProducts;
public:
Order(Customer customer) : customer(customer), noOfProducts(0){
items = new OrderItem[1];
}
~Order(){
delete[] items;
}
void addItem(Product product, int qty){
OrderItem *tmp = new OrderItem[noOfProducts+1];
for(int i=0;i<noOfProducts;i++) tmp[i] = items[i];
tmp[noOfProducts] = {product, qty};
noOfProducts++;
}
void displayOrder(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,63 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Customer{
string name;
string address;
public:
string getName(){
return name;
}
string getAddress(){
return address;
}
};
class Product{
string name;
double price;
public:
string getName(){
return name;
}
double getPrice(){
return price;
}
};
class Order{
Customer customer;
Product *products;
int noOfProducts;
public:
Order(Customer customer, int noOfProducts) : customer(customer), noOfProducts(noOfProducts){
products = new Product[noOfProducts];
}
void addItem(Product product, int index){
}
};
int main(){
return 0;
}