test
This commit is contained in:
parent
37776af5db
commit
ab03d5f10c
4045 changed files with 286212 additions and 3 deletions
180
.config/Code/User/History/55b0855c/1T61.cpp
Normal file
180
.config/Code/User/History/55b0855c/1T61.cpp
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByPrice(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getPrice()>books[j].getPrice()){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTitle(Library books[], char* titlename){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(strcmp(books[i].getBookTitle(), titlename) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[]){
|
||||
Library max(books[0]);
|
||||
for(int i=1;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getPrice()>max.getPrice()) max = Library(books[i]);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
// take input and test all fucntions
|
||||
Library::setTotalBooks(0);
|
||||
Library books[100];
|
||||
char title[100], author[100];
|
||||
int id, quantity;
|
||||
float price;
|
||||
cout<<"Enter number of books: ";
|
||||
int n;
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++){
|
||||
cout<<"Enter book title: ";
|
||||
cin>>title;
|
||||
cout<<"Enter author name: ";
|
||||
cin>>author;
|
||||
cout<<"Enter book ID: ";
|
||||
cin>>id;
|
||||
cout<<"Enter quantity: ";
|
||||
cin>>quantity;
|
||||
cout<<"Enter price: ";
|
||||
cin>>price;
|
||||
Library book;
|
||||
book.setBookTitle(title);
|
||||
book.setAuthor(author);
|
||||
book.setBookID(id);
|
||||
book.setQuantity(quantity);
|
||||
book.setPrice(price);
|
||||
addBook(books, book);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
13
.config/Code/User/History/55b0855c/2d1E.cpp
Normal file
13
.config/Code/User/History/55b0855c/2d1E.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
75
.config/Code/User/History/55b0855c/3x3y.cpp
Normal file
75
.config/Code/User/History/55b0855c/3x3y.cpp
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
109
.config/Code/User/History/55b0855c/639d.cpp
Normal file
109
.config/Code/User/History/55b0855c/639d.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(bookID), quantity(quantity), price(price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
bookTitle = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
111
.config/Code/User/History/55b0855c/6P5N.cpp
Normal file
111
.config/Code/User/History/55b0855c/6P5N.cpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
69
.config/Code/User/History/55b0855c/8IJn.cpp
Normal file
69
.config/Code/User/History/55b0855c/8IJn.cpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
13
.config/Code/User/History/55b0855c/96gC.cpp
Normal file
13
.config/Code/User/History/55b0855c/96gC.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
111
.config/Code/User/History/55b0855c/AE3D.cpp
Normal file
111
.config/Code/User/History/55b0855c/AE3D.cpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
109
.config/Code/User/History/55b0855c/BQHj.cpp
Normal file
109
.config/Code/User/History/55b0855c/BQHj.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(bookID), quantity(quantity), price(price){
|
||||
bookTitle = new char[strlen(library.bookTitle)+1];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
bookTitle = new char[strlen(library.author)+1];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
45
.config/Code/User/History/55b0855c/Cc0R.cpp
Normal file
45
.config/Code/User/History/55b0855c/Cc0R.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
111
.config/Code/User/History/55b0855c/CndL.cpp
Normal file
111
.config/Code/User/History/55b0855c/CndL.cpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
71
.config/Code/User/History/55b0855c/De1l.cpp
Normal file
71
.config/Code/User/History/55b0855c/De1l.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<price * quantity<<endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
102
.config/Code/User/History/55b0855c/DqjM.cpp
Normal file
102
.config/Code/User/History/55b0855c/DqjM.cpp
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
140
.config/Code/User/History/55b0855c/F1Tj.cpp
Normal file
140
.config/Code/User/History/55b0855c/F1Tj.cpp
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByPrice(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getPrice()>books[j].getPrice()){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTitle(Library books[], char* titlename){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
108
.config/Code/User/History/55b0855c/J9Wh.cpp
Normal file
108
.config/Code/User/History/55b0855c/J9Wh.cpp
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(bookID), quantity(quantity), price(price){
|
||||
bookTitle = new char[strlen(library.bookTitle)]
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
106
.config/Code/User/History/55b0855c/JGJM.cpp
Normal file
106
.config/Code/User/History/55b0855c/JGJM.cpp
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(bookID), quantity(quantity), price(price){
|
||||
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
98
.config/Code/User/History/55b0855c/Jnqa.cpp
Normal file
98
.config/Code/User/History/55b0855c/Jnqa.cpp
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
109
.config/Code/User/History/55b0855c/K8bv.cpp
Normal file
109
.config/Code/User/History/55b0855c/K8bv.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
64
.config/Code/User/History/55b0855c/LF2F.cpp
Normal file
64
.config/Code/User/History/55b0855c/LF2F.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
13
.config/Code/User/History/55b0855c/Lmua.cpp
Normal file
13
.config/Code/User/History/55b0855c/Lmua.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
121
.config/Code/User/History/55b0855c/RdsY.cpp
Normal file
121
.config/Code/User/History/55b0855c/RdsY.cpp
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
228
.config/Code/User/History/55b0855c/V3Z5.cpp
Normal file
228
.config/Code/User/History/55b0855c/V3Z5.cpp
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(){
|
||||
bookTitle = new char[100];
|
||||
author = new char[100];
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0;
|
||||
}
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
int Library::totalBooks = 0;
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByPrice(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getPrice()>books[j].getPrice()){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTitle(Library books[], char* titlename){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(strcmp(books[i].getBookTitle(), titlename) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[]){
|
||||
Library max(books[0]);
|
||||
for(int i=1;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getPrice()>max.getPrice()) max = Library(books[i]);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
Library::setTotalBooks(0);
|
||||
Library books[100];
|
||||
char title[100], author[100];
|
||||
int id, quantity;
|
||||
float price;
|
||||
cout<<"Enter number of books: ";
|
||||
int n;
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++){
|
||||
cout<<"Enter book title: ";
|
||||
cin>>title;
|
||||
cout<<"Enter author name: ";
|
||||
cin>>author;
|
||||
cout<<"Enter book ID: ";
|
||||
cin>>id;
|
||||
cout<<"Enter quantity: ";
|
||||
cin>>quantity;
|
||||
cout<<"Enter price: ";
|
||||
cin>>price;
|
||||
Library book;
|
||||
book.setBookTitle(title);
|
||||
book.setAuthor(author);
|
||||
book.setBookID(id);
|
||||
book.setQuantity(quantity);
|
||||
book.setPrice(price);
|
||||
addBook(books, book);
|
||||
}
|
||||
|
||||
|
||||
cout<<"Total Books: "<<Library::getTotalBooks()<<endl;
|
||||
cout<<"Enter book ID to remove: ";
|
||||
int removeID;
|
||||
cin>>removeID;
|
||||
removeBook(books, removeID);
|
||||
cout<<"Total Books: "<<Library::getTotalBooks()<<endl;
|
||||
|
||||
cout<<"Enter book ID to get: ";
|
||||
int getID;
|
||||
cin>>getID;
|
||||
Library getBook = getBookAt(books, getID);
|
||||
cout<<"Book Title: "<<getBook.getBookTitle()<<endl;
|
||||
cout<<"Author: "<<getBook.getAuthor()<<endl;
|
||||
cout<<"Book ID: "<<getBook.getBookID()<<endl;
|
||||
cout<<"Quantity: "<<getBook.getQuantity()<<endl;
|
||||
cout<<"Price: "<<getBook.getPrice()<<endl;
|
||||
|
||||
cout<<"Enter book title to search: ";
|
||||
char searchTitle[100];
|
||||
cin>>searchTitle;
|
||||
if(searchByTitle(books, searchTitle)) cout<<"Book found!"<<endl;
|
||||
else cout<<"Book not found!"<<endl;
|
||||
|
||||
cout<<"Most expensive book: "<<mostExpensiveBook(books).getBookTitle()<<endl;
|
||||
|
||||
sortByTitle(books);
|
||||
cout<<"Books sorted by title: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getBookTitle()<<endl;
|
||||
}
|
||||
|
||||
sortByAuthor(books);
|
||||
cout<<"Books sorted by author: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getAuthor()<<endl;
|
||||
}
|
||||
|
||||
sortByPrice(books);
|
||||
cout<<"Books sorted by price: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getPrice()<<endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
109
.config/Code/User/History/55b0855c/VW5D.cpp
Normal file
109
.config/Code/User/History/55b0855c/VW5D.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(bookID), quantity(quantity), price(price){
|
||||
bookTitle = new char[strlen(library.bookTitle)+1];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)+1];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
109
.config/Code/User/History/55b0855c/W5F4.cpp
Normal file
109
.config/Code/User/History/55b0855c/W5F4.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(bookID), quantity(quantity), price(price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
96
.config/Code/User/History/55b0855c/X5c1.cpp
Normal file
96
.config/Code/User/History/55b0855c/X5c1.cpp
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
143
.config/Code/User/History/55b0855c/a8OG.cpp
Normal file
143
.config/Code/User/History/55b0855c/a8OG.cpp
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByPrice(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getPrice()>books[j].getPrice()){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTitle(Library books[], char* titlename){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(strcmp(books[i].getBookTitle(), titlename) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
228
.config/Code/User/History/55b0855c/cYgx.cpp
Normal file
228
.config/Code/User/History/55b0855c/cYgx.cpp
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(){
|
||||
bookTitle = new char[100];
|
||||
author = new char[100];
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0;
|
||||
}
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
int Library::totalBooks = 0;
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByPrice(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getPrice()>books[j].getPrice()){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTitle(Library books[], char* titlename){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(strcmp(books[i].getBookTitle(), titlename) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[]){
|
||||
Library max(books[0]);
|
||||
for(int i=1;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getPrice()>max.getPrice()) max = Library(books[i]);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
Library::setTotalBooks(0);
|
||||
Library books[100];
|
||||
char title[100], author[100];
|
||||
int id, quantity;
|
||||
float price;
|
||||
cout<<"Enter number of books: ";
|
||||
int n;
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++){
|
||||
cout<<"Enter book title: ";
|
||||
cin>>title;
|
||||
cout<<"Enter author name: ";
|
||||
cin>>author;
|
||||
cout<<"Enter book ID: ";
|
||||
cin>>id;
|
||||
cout<<"Enter quantity: ";
|
||||
cin>>quantity;
|
||||
cout<<"Enter price: ";
|
||||
cin>>price;
|
||||
Library book;
|
||||
book.setBookTitle(title);
|
||||
book.setAuthor(author);
|
||||
book.setBookID(id);
|
||||
book.setQuantity(quantity);
|
||||
book.setPrice(price);
|
||||
addBook(books, book);
|
||||
}
|
||||
|
||||
|
||||
cout<<"Total Books: "<<Library::getTotalBooks()<<endl;
|
||||
cout<<"Enter book ID to remove: ";
|
||||
int removeID;
|
||||
cin>>removeID;
|
||||
removeBook(books, removeID);
|
||||
cout<<"Total Books: "<<Library::getTotalBooks()<<endl;
|
||||
|
||||
cout<<"Enter book ID to get: ";
|
||||
int getID;
|
||||
cin>>getID;
|
||||
Library getBook = getBookAt(books, getID);
|
||||
cout<<"Book Title: "<<getBook.getBookTitle()<<endl;
|
||||
cout<<"Author: "<<getBook.getAuthor()<<endl;
|
||||
cout<<"Book ID: "<<getBook.getBookID()<<endl;
|
||||
cout<<"Quantity: "<<getBook.getQuantity()<<endl;
|
||||
cout<<"Price: "<<getBook.getPrice()<<endl;
|
||||
|
||||
cout<<"Enter book title to search: ";
|
||||
char searchTitle[100];
|
||||
cin>>searchTitle;
|
||||
if(searchByTitle(books, searchTitle)) cout<<"Book found!"<<endl;
|
||||
else cout<<"Book not found!"<<endl;
|
||||
|
||||
cout<<"Most expensive book: "<<mostExpensiveBook(books).getBookTitle()<<endl;
|
||||
|
||||
sortByTitle(books);
|
||||
cout<<"Books sorted by title: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getBookTitle()<<endl;
|
||||
}
|
||||
|
||||
sortByAuthor(books);
|
||||
cout<<"Books sorted by author: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getAuthor()<<endl;
|
||||
}
|
||||
|
||||
sortByPrice(books);
|
||||
cout<<"Books sorted by price: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getPrice()<<endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
134
.config/Code/User/History/55b0855c/daRB.cpp
Normal file
134
.config/Code/User/History/55b0855c/daRB.cpp
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByPrice(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getPrice()>books[j].getPrice()){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
1
.config/Code/User/History/55b0855c/entries.json
Normal file
1
.config/Code/User/History/55b0855c/entries.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Stuff/a3/q5.cpp","entries":[{"id":"2d1E.cpp","timestamp":1711177902972},{"id":"Lmua.cpp","timestamp":1711177919845},{"id":"96gC.cpp","timestamp":1711177931915},{"id":"Cc0R.cpp","timestamp":1711178013882},{"id":"xIFB.cpp","timestamp":1711178042116},{"id":"oQTk.cpp","timestamp":1711178057186},{"id":"LF2F.cpp","timestamp":1711178072619},{"id":"sEwS.cpp","timestamp":1711178086026},{"id":"kjjA.cpp","timestamp":1711178110896},{"id":"De1l.cpp","timestamp":1711178183479},{"id":"8IJn.cpp","timestamp":1711178199699},{"id":"3x3y.cpp","timestamp":1711178251122},{"id":"tKuF.cpp","timestamp":1711178283682},{"id":"tEYH.cpp","timestamp":1711178345568},{"id":"mLSd.cpp","timestamp":1711178372808},{"id":"X5c1.cpp","timestamp":1711178449343},{"id":"Jnqa.cpp","timestamp":1711178482770},{"id":"DqjM.cpp","timestamp":1711178554369},{"id":"iZuB.cpp","timestamp":1711178587709},{"id":"ra6C.cpp","timestamp":1711178614298},{"id":"JGJM.cpp","timestamp":1711178691644},{"id":"lmhx.cpp","timestamp":1711178740943},{"id":"J9Wh.cpp","timestamp":1711178831845},{"id":"639d.cpp","timestamp":1711178847448},{"id":"sZJM.cpp","timestamp":1711178869205},{"id":"BQHj.cpp","timestamp":1711178915267},{"id":"VW5D.cpp","timestamp":1711178934987},{"id":"W5F4.cpp","timestamp":1711178958333},{"id":"K8bv.cpp","timestamp":1711179022806},{"id":"vVEH.cpp","timestamp":1711179084888},{"id":"fGPJ.cpp","timestamp":1711179114074},{"id":"6P5N.cpp","timestamp":1711179132514},{"id":"CndL.cpp","timestamp":1711179185820},{"id":"AE3D.cpp","timestamp":1711179298618},{"id":"RdsY.cpp","timestamp":1711179330080},{"id":"daRB.cpp","timestamp":1711179374306},{"id":"F1Tj.cpp","timestamp":1711179418845},{"id":"a8OG.cpp","timestamp":1711179489342},{"id":"jEyj.cpp","timestamp":1711179615090},{"id":"o3JX.cpp","timestamp":1711179627404},{"id":"1T61.cpp","timestamp":1711179709476},{"id":"v1np.cpp","timestamp":1711179766688},{"id":"rlXQ.cpp","timestamp":1711179847853},{"id":"cYgx.cpp","timestamp":1711179926324},{"id":"V3Z5.cpp","timestamp":1711793833562},{"id":"l0Um.cpp","timestamp":1711869527872}]}
|
||||
111
.config/Code/User/History/55b0855c/fGPJ.cpp
Normal file
111
.config/Code/User/History/55b0855c/fGPJ.cpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
102
.config/Code/User/History/55b0855c/iZuB.cpp
Normal file
102
.config/Code/User/History/55b0855c/iZuB.cpp
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
150
.config/Code/User/History/55b0855c/jEyj.cpp
Normal file
150
.config/Code/User/History/55b0855c/jEyj.cpp
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByPrice(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getPrice()>books[j].getPrice()){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTitle(Library books[], char* titlename){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(strcmp(books[i].getBookTitle(), titlename) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[]){
|
||||
Library max = books[0];
|
||||
for(int i=1;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getPrice()>max.getPrice()) max = Library(books[i]);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
67
.config/Code/User/History/55b0855c/kjjA.cpp
Normal file
67
.config/Code/User/History/55b0855c/kjjA.cpp
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
229
.config/Code/User/History/55b0855c/l0Um.cpp
Normal file
229
.config/Code/User/History/55b0855c/l0Um.cpp
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
Assignment 3
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(){
|
||||
bookTitle = new char[100];
|
||||
author = new char[100];
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0;
|
||||
}
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
int Library::totalBooks = 0;
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByPrice(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getPrice()>books[j].getPrice()){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTitle(Library books[], char* titlename){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(strcmp(books[i].getBookTitle(), titlename) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[]){
|
||||
Library max(books[0]);
|
||||
for(int i=1;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getPrice()>max.getPrice()) max = Library(books[i]);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
Library::setTotalBooks(0);
|
||||
Library books[100];
|
||||
char title[100], author[100];
|
||||
int id, quantity;
|
||||
float price;
|
||||
cout<<"Enter number of books: ";
|
||||
int n;
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++){
|
||||
cout<<"Enter book title: ";
|
||||
cin>>title;
|
||||
cout<<"Enter author name: ";
|
||||
cin>>author;
|
||||
cout<<"Enter book ID: ";
|
||||
cin>>id;
|
||||
cout<<"Enter quantity: ";
|
||||
cin>>quantity;
|
||||
cout<<"Enter price: ";
|
||||
cin>>price;
|
||||
Library book;
|
||||
book.setBookTitle(title);
|
||||
book.setAuthor(author);
|
||||
book.setBookID(id);
|
||||
book.setQuantity(quantity);
|
||||
book.setPrice(price);
|
||||
addBook(books, book);
|
||||
}
|
||||
|
||||
|
||||
cout<<"Total Books: "<<Library::getTotalBooks()<<endl;
|
||||
cout<<"Enter book ID to remove: ";
|
||||
int removeID;
|
||||
cin>>removeID;
|
||||
removeBook(books, removeID);
|
||||
cout<<"Total Books: "<<Library::getTotalBooks()<<endl;
|
||||
|
||||
cout<<"Enter book ID to get: ";
|
||||
int getID;
|
||||
cin>>getID;
|
||||
Library getBook = getBookAt(books, getID);
|
||||
cout<<"Book Title: "<<getBook.getBookTitle()<<endl;
|
||||
cout<<"Author: "<<getBook.getAuthor()<<endl;
|
||||
cout<<"Book ID: "<<getBook.getBookID()<<endl;
|
||||
cout<<"Quantity: "<<getBook.getQuantity()<<endl;
|
||||
cout<<"Price: "<<getBook.getPrice()<<endl;
|
||||
|
||||
cout<<"Enter book title to search: ";
|
||||
char searchTitle[100];
|
||||
cin>>searchTitle;
|
||||
if(searchByTitle(books, searchTitle)) cout<<"Book found!"<<endl;
|
||||
else cout<<"Book not found!"<<endl;
|
||||
|
||||
cout<<"Most expensive book: "<<mostExpensiveBook(books).getBookTitle()<<endl;
|
||||
|
||||
sortByTitle(books);
|
||||
cout<<"Books sorted by title: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getBookTitle()<<endl;
|
||||
}
|
||||
|
||||
sortByAuthor(books);
|
||||
cout<<"Books sorted by author: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getAuthor()<<endl;
|
||||
}
|
||||
|
||||
sortByPrice(books);
|
||||
cout<<"Books sorted by price: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getPrice()<<endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
107
.config/Code/User/History/55b0855c/lmhx.cpp
Normal file
107
.config/Code/User/History/55b0855c/lmhx.cpp
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(bookID), quantity(quantity), price(price){
|
||||
strcpy(this->bookTtile, library.bookTtile);
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
92
.config/Code/User/History/55b0855c/mLSd.cpp
Normal file
92
.config/Code/User/History/55b0855c/mLSd.cpp
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
150
.config/Code/User/History/55b0855c/o3JX.cpp
Normal file
150
.config/Code/User/History/55b0855c/o3JX.cpp
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByPrice(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getPrice()>books[j].getPrice()){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTitle(Library books[], char* titlename){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(strcmp(books[i].getBookTitle(), titlename) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[]){
|
||||
Library max(books[0]);
|
||||
for(int i=1;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getPrice()>max.getPrice()) max = Library(books[i]);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
64
.config/Code/User/History/55b0855c/oQTk.cpp
Normal file
64
.config/Code/User/History/55b0855c/oQTk.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
this->totalBooks = totalBooks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
101
.config/Code/User/History/55b0855c/ra6C.cpp
Normal file
101
.config/Code/User/History/55b0855c/ra6C.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
228
.config/Code/User/History/55b0855c/rlXQ.cpp
Normal file
228
.config/Code/User/History/55b0855c/rlXQ.cpp
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(){
|
||||
bookTitle = new char[100];
|
||||
author = new char[100];
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0;
|
||||
}
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByPrice(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getPrice()>books[j].getPrice()){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTitle(Library books[], char* titlename){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(strcmp(books[i].getBookTitle(), titlename) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[]){
|
||||
Library max(books[0]);
|
||||
for(int i=1;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getPrice()>max.getPrice()) max = Library(books[i]);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
Library::setTotalBooks(0);
|
||||
Library books[100];
|
||||
char title[100], author[100];
|
||||
int id, quantity;
|
||||
float price;
|
||||
cout<<"Enter number of books: ";
|
||||
int n;
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++){
|
||||
cout<<"Enter book title: ";
|
||||
cin>>title;
|
||||
cout<<"Enter author name: ";
|
||||
cin>>author;
|
||||
cout<<"Enter book ID: ";
|
||||
cin>>id;
|
||||
cout<<"Enter quantity: ";
|
||||
cin>>quantity;
|
||||
cout<<"Enter price: ";
|
||||
cin>>price;
|
||||
Library book;
|
||||
book.setBookTitle(title);
|
||||
book.setAuthor(author);
|
||||
book.setBookID(id);
|
||||
book.setQuantity(quantity);
|
||||
book.setPrice(price);
|
||||
addBook(books, book);
|
||||
}
|
||||
|
||||
|
||||
cout<<"Total Books: "<<Library::getTotalBooks()<<endl;
|
||||
cout<<"Enter book ID to remove: ";
|
||||
int removeID;
|
||||
cin>>removeID;
|
||||
removeBook(books, removeID);
|
||||
cout<<"Total Books: "<<Library::getTotalBooks()<<endl;
|
||||
|
||||
cout<<"Enter book ID to get: ";
|
||||
int getID;
|
||||
cin>>getID;
|
||||
Library getBook = getBookAt(books, getID);
|
||||
cout<<"Book Title: "<<getBook.getBookTitle()<<endl;
|
||||
cout<<"Author: "<<getBook.getAuthor()<<endl;
|
||||
cout<<"Book ID: "<<getBook.getBookID()<<endl;
|
||||
cout<<"Quantity: "<<getBook.getQuantity()<<endl;
|
||||
cout<<"Price: "<<getBook.getPrice()<<endl;
|
||||
|
||||
cout<<"Enter book title to search: ";
|
||||
char searchTitle[100];
|
||||
cin>>searchTitle;
|
||||
if(searchByTitle(books, searchTitle)) cout<<"Book found!"<<endl;
|
||||
else cout<<"Book not found!"<<endl;
|
||||
|
||||
cout<<"Most expensive book: "<<mostExpensiveBook(books).getBookTitle()<<endl;
|
||||
|
||||
sortByTitle(books);
|
||||
cout<<"Books sorted by title: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getBookTitle()<<endl;
|
||||
}
|
||||
|
||||
sortByAuthor(books);
|
||||
cout<<"Books sorted by author: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getAuthor()<<endl;
|
||||
}
|
||||
|
||||
sortByPrice(books);
|
||||
cout<<"Books sorted by price: "<<endl;
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
cout<<books[i].getPrice()<<endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
64
.config/Code/User/History/55b0855c/sEwS.cpp
Normal file
64
.config/Code/User/History/55b0855c/sEwS.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
109
.config/Code/User/History/55b0855c/sZJM.cpp
Normal file
109
.config/Code/User/History/55b0855c/sZJM.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(bookID), quantity(quantity), price(price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
bookTitle = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
92
.config/Code/User/History/55b0855c/tEYH.cpp
Normal file
92
.config/Code/User/History/55b0855c/tEYH.cpp
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i = 0; i < Library::getTotalBooks(); i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j = i; j < Library::getTotalBooks() - 1; j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
79
.config/Code/User/History/55b0855c/tKuF.cpp
Normal file
79
.config/Code/User/History/55b0855c/tKuF.cpp
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[index] = book;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
188
.config/Code/User/History/55b0855c/v1np.cpp
Normal file
188
.config/Code/User/History/55b0855c/v1np.cpp
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(){
|
||||
bookTitle = new char[100];
|
||||
author = new char[100];
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0;
|
||||
}
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]>books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByAuthor(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getAuthor()[0]>books[j].getAuthor()[0]){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByPrice(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i+1;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getPrice()>books[j].getPrice()){
|
||||
Library temp(books[i]);
|
||||
books[i] = Library(books[j]);
|
||||
books[j] = Library(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTitle(Library books[], char* titlename){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(strcmp(books[i].getBookTitle(), titlename) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[]){
|
||||
Library max(books[0]);
|
||||
for(int i=1;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getPrice()>max.getPrice()) max = Library(books[i]);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
// take input and test all fucntions
|
||||
Library::setTotalBooks(0);
|
||||
Library books[100];
|
||||
char title[100], author[100];
|
||||
int id, quantity;
|
||||
float price;
|
||||
cout<<"Enter number of books: ";
|
||||
int n;
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++){
|
||||
cout<<"Enter book title: ";
|
||||
cin>>title;
|
||||
cout<<"Enter author name: ";
|
||||
cin>>author;
|
||||
cout<<"Enter book ID: ";
|
||||
cin>>id;
|
||||
cout<<"Enter quantity: ";
|
||||
cin>>quantity;
|
||||
cout<<"Enter price: ";
|
||||
cin>>price;
|
||||
Library book;
|
||||
book.setBookTitle(title);
|
||||
book.setAuthor(author);
|
||||
book.setBookID(id);
|
||||
book.setQuantity(quantity);
|
||||
book.setPrice(price);
|
||||
addBook(books, book);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
110
.config/Code/User/History/55b0855c/vVEH.cpp
Normal file
110
.config/Code/User/History/55b0855c/vVEH.cpp
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTitle;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
Library(const Library& library) : bookID(library.bookID), quantity(library.quantity), price(library.price){
|
||||
bookTitle = new char[strlen(library.bookTitle)];
|
||||
strcpy(this->bookTitle, library.bookTitle);
|
||||
author = new char[strlen(library.author)];
|
||||
strcpy(this->author, library.author);
|
||||
}
|
||||
|
||||
char* getBookTitle(){
|
||||
return bookTitle;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
|
||||
void setBookTitle(char* title){
|
||||
bookTitle = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int totalBooks){
|
||||
Library::totalBooks = totalBooks;
|
||||
}
|
||||
static int getTotalBooks(){
|
||||
return Library::totalBooks;
|
||||
}
|
||||
|
||||
void calcTotalPrice(){
|
||||
cout<<"Total Price: "<<this->price * this->quantity<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Library getBookAt(Library books[], int index){
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[], Library book){
|
||||
books[Library::getTotalBooks()] = book;
|
||||
Library::setTotalBooks(Library::getTotalBooks() + 1);
|
||||
}
|
||||
|
||||
void removeBook(Library books[], int bookID){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
if(books[i].getBookID() == bookID){
|
||||
for(int j=i;j<Library::getTotalBooks()-1;j++){
|
||||
books[j] = books[j + 1];
|
||||
}
|
||||
Library::setTotalBooks(Library::getTotalBooks() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sortByTitle(Library books[]){
|
||||
for(int i=0;i<Library::getTotalBooks();i++){
|
||||
for(int j=i;j<Library::getTotalBooks();j++){
|
||||
if(books[i].getBookTitle()[0]<books[j].getBookTitle()[0]){
|
||||
Library temp(books[i]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
64
.config/Code/User/History/55b0855c/xIFB.cpp
Normal file
64
.config/Code/User/History/55b0855c/xIFB.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Library{
|
||||
char* bookTtile;
|
||||
char* author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
|
||||
// getter
|
||||
char* getBookTitle(){
|
||||
return bookTtile;
|
||||
}
|
||||
char* getAuthor(){
|
||||
return author;
|
||||
}
|
||||
int getBookID(){
|
||||
return bookID;
|
||||
}
|
||||
int getQuantity(){
|
||||
return quantity;
|
||||
}
|
||||
float getPrice(){
|
||||
return price;
|
||||
}
|
||||
// setter
|
||||
void setBookTitle(char* title){
|
||||
bookTtile = title;
|
||||
}
|
||||
void setAuthor(char* authorName){
|
||||
author = authorName;
|
||||
}
|
||||
void setBookID(int id){
|
||||
bookID = id;
|
||||
}
|
||||
void setQuantity(int q){
|
||||
quantity = q;
|
||||
}
|
||||
void setPrice(float p){
|
||||
price = p;
|
||||
}
|
||||
|
||||
static void setTotalBooks(int t){
|
||||
totalBooks = t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue