test
This commit is contained in:
parent
37776af5db
commit
ab03d5f10c
4045 changed files with 286212 additions and 3 deletions
271
.config/Code/User/History/-131a2af4/02RO.cpp
Normal file
271
.config/Code/User/History/-131a2af4/02RO.cpp
Normal file
|
@ -0,0 +1,271 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j + 1 < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
// books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
books[i].setBookTitle(bookName);
|
||||
books[i].setAuthor(authorName);
|
||||
books[i].setBookID(id);
|
||||
books[i].setQuantity(booksQuantity);
|
||||
books[i].setPrice(bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
272
.config/Code/User/History/-131a2af4/3jwS.cpp
Normal file
272
.config/Code/User/History/-131a2af4/3jwS.cpp
Normal file
|
@ -0,0 +1,272 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i-1; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
Library::setTotalBooks(numBooks);
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
// books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
books[i].setBookTitle(bookName);
|
||||
books[i].setAuthor(authorName);
|
||||
books[i].setBookID(id);
|
||||
books[i].setQuantity(booksQuantity);
|
||||
books[i].setPrice(bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
271
.config/Code/User/History/-131a2af4/5oh9.cpp
Normal file
271
.config/Code/User/History/-131a2af4/5oh9.cpp
Normal file
|
@ -0,0 +1,271 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 1; j < Library::getTotalBooks(); j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
// books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
books[i].setBookTitle(bookName);
|
||||
books[i].setAuthor(authorName);
|
||||
books[i].setBookID(id);
|
||||
books[i].setQuantity(booksQuantity);
|
||||
books[i].setPrice(bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
271
.config/Code/User/History/-131a2af4/71QD.cpp
Normal file
271
.config/Code/User/History/-131a2af4/71QD.cpp
Normal file
|
@ -0,0 +1,271 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
// books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
books[i].setBookTitle(bookName);
|
||||
books[i].setAuthor(authorName);
|
||||
books[i].setBookID(id);
|
||||
books[i].setQuantity(booksQuantity);
|
||||
books[i].setPrice(bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
266
.config/Code/User/History/-131a2af4/9oTO.cpp
Normal file
266
.config/Code/User/History/-131a2af4/9oTO.cpp
Normal file
|
@ -0,0 +1,266 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
266
.config/Code/User/History/-131a2af4/DFD7.cpp
Normal file
266
.config/Code/User/History/-131a2af4/DFD7.cpp
Normal file
|
@ -0,0 +1,266 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < 99 - i; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < 99; i++) {
|
||||
for (int j = 0; j < 99 - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < 99; i++) {
|
||||
for (int j = 0; j < 99 - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
266
.config/Code/User/History/-131a2af4/I2f2.cpp
Normal file
266
.config/Code/User/History/-131a2af4/I2f2.cpp
Normal file
|
@ -0,0 +1,266 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
271
.config/Code/User/History/-131a2af4/KKSz.cpp
Normal file
271
.config/Code/User/History/-131a2af4/KKSz.cpp
Normal file
|
@ -0,0 +1,271 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i-1; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
// books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
books[i].setBookTitle(bookName);
|
||||
books[i].setAuthor(authorName);
|
||||
books[i].setBookID(id);
|
||||
books[i].setQuantity(booksQuantity);
|
||||
books[i].setPrice(bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
0
.config/Code/User/History/-131a2af4/OyPi.cpp
Normal file
0
.config/Code/User/History/-131a2af4/OyPi.cpp
Normal file
271
.config/Code/User/History/-131a2af4/RwFw.cpp
Normal file
271
.config/Code/User/History/-131a2af4/RwFw.cpp
Normal file
|
@ -0,0 +1,271 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[]) {
|
||||
for (int i = 0; i < 1; i++) {
|
||||
for (int j = 0; j < i; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
// books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
books[i].setBookTitle(bookName);
|
||||
books[i].setAuthor(authorName);
|
||||
books[i].setBookID(id);
|
||||
books[i].setQuantity(booksQuantity);
|
||||
books[i].setPrice(bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
271
.config/Code/User/History/-131a2af4/SZ5K.cpp
Normal file
271
.config/Code/User/History/-131a2af4/SZ5K.cpp
Normal file
|
@ -0,0 +1,271 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i-1; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
// books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
books[i].setBookTitle(bookName);
|
||||
books[i].setAuthor(authorName);
|
||||
books[i].setBookID(id);
|
||||
books[i].setQuantity(booksQuantity);
|
||||
books[i].setPrice(bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
2678
.config/Code/User/History/-131a2af4/Yufd.cpp
Normal file
2678
.config/Code/User/History/-131a2af4/Yufd.cpp
Normal file
File diff suppressed because it is too large
Load diff
271
.config/Code/User/History/-131a2af4/acJi.cpp
Normal file
271
.config/Code/User/History/-131a2af4/acJi.cpp
Normal file
|
@ -0,0 +1,271 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
// books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
books[i].setBookTitle(bookName);
|
||||
books[i].setAuthor(authorName);
|
||||
books[i].setBookID(id);
|
||||
books[i].setQuantity(booksQuantity);
|
||||
books[i].setPrice(bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
266
.config/Code/User/History/-131a2af4/bdBv.cpp
Normal file
266
.config/Code/User/History/-131a2af4/bdBv.cpp
Normal file
|
@ -0,0 +1,266 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < 99; i++) {
|
||||
for (int j = 0; j < 99 - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < 99; i++) {
|
||||
for (int j = 0; j < 99 - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
1
.config/Code/User/History/-131a2af4/entries.json
Normal file
1
.config/Code/User/History/-131a2af4/entries.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Stuff/a3/ali2.cpp","entries":[{"id":"oRqB.cpp","timestamp":1711905847733},{"id":"Yufd.cpp","timestamp":1711905905604},{"id":"OyPi.cpp","timestamp":1711905925645},{"id":"hyl6.cpp","timestamp":1711905948049},{"id":"DFD7.cpp","timestamp":1711906070572},{"id":"bdBv.cpp","timestamp":1711906080769},{"id":"9oTO.cpp","timestamp":1711906100620},{"id":"I2f2.cpp","timestamp":1711906187000},{"id":"sIvO.cpp","timestamp":1711906350289},{"id":"eonH.cpp","timestamp":1711906377038},{"id":"5oh9.cpp","timestamp":1711906726522},{"id":"jCjv.cpp","timestamp":1711906800879},{"id":"71QD.cpp","timestamp":1711906844386},{"id":"02RO.cpp","timestamp":1711906944724},{"id":"acJi.cpp","timestamp":1711906964117},{"id":"KKSz.cpp","timestamp":1711907079695},{"id":"3jwS.cpp","timestamp":1711907145693},{"id":"SZ5K.cpp","timestamp":1711907259725},{"id":"RwFw.cpp","timestamp":1711907349413}]}
|
271
.config/Code/User/History/-131a2af4/eonH.cpp
Normal file
271
.config/Code/User/History/-131a2af4/eonH.cpp
Normal file
|
@ -0,0 +1,271 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
// books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
books[i].setBookTitle(bookName);
|
||||
books[i].setAuthor(authorName);
|
||||
books[i].setBookID(id);
|
||||
books[i].setQuantity(booksQuantity);
|
||||
books[i].setPrice(bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
266
.config/Code/User/History/-131a2af4/hyl6.cpp
Normal file
266
.config/Code/User/History/-131a2af4/hyl6.cpp
Normal file
|
@ -0,0 +1,266 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[100]) {
|
||||
for (int i = 0; i < 99; i++) {
|
||||
for (int j = 0; j < 99 - i; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < 99; i++) {
|
||||
for (int j = 0; j < 99 - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < 99; i++) {
|
||||
for (int j = 0; j < 99 - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
271
.config/Code/User/History/-131a2af4/jCjv.cpp
Normal file
271
.config/Code/User/History/-131a2af4/jCjv.cpp
Normal file
|
@ -0,0 +1,271 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 1; j < Library::getTotalBooks(); j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
// books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
books[i].setBookTitle(bookName);
|
||||
books[i].setAuthor(authorName);
|
||||
books[i].setBookID(id);
|
||||
books[i].setQuantity(booksQuantity);
|
||||
books[i].setPrice(bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
2946
.config/Code/User/History/-131a2af4/oRqB.cpp
Normal file
2946
.config/Code/User/History/-131a2af4/oRqB.cpp
Normal file
File diff suppressed because it is too large
Load diff
271
.config/Code/User/History/-131a2af4/sIvO.cpp
Normal file
271
.config/Code/User/History/-131a2af4/sIvO.cpp
Normal file
|
@ -0,0 +1,271 @@
|
|||
#include<iostream>
|
||||
#include<cstring>
|
||||
using namespace std;
|
||||
|
||||
class Library {
|
||||
private:
|
||||
char *bookTitle;
|
||||
char *author;
|
||||
int bookID;
|
||||
int quantity;
|
||||
float price;
|
||||
static int totalBooks;
|
||||
|
||||
public:
|
||||
//Constructors
|
||||
Library() : bookTitle(nullptr), author(nullptr) {
|
||||
bookID = 0;
|
||||
quantity = 0;
|
||||
price = 0.0;
|
||||
}
|
||||
|
||||
Library(char* title, char* authorName, int id, int newQuantity, float bookPrice) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
bookID = id;
|
||||
quantity = newQuantity;
|
||||
price = bookPrice;
|
||||
totalBooks += newQuantity;
|
||||
}
|
||||
|
||||
// ~Library() {
|
||||
// delete[] bookTitle;
|
||||
// delete[] author;
|
||||
// totalBooks -= quantity;
|
||||
// }
|
||||
|
||||
//Getters
|
||||
char* getBookTitle() { return bookTitle; }
|
||||
char* getAuthor() { return author; }
|
||||
int getBookID() { return bookID; }
|
||||
int getQuantity() { return quantity; }
|
||||
float getPrice() { return price; }
|
||||
|
||||
static int getTotalBooks() {
|
||||
return totalBooks;
|
||||
}
|
||||
|
||||
//Setters
|
||||
void setBookTitle(char* title) {
|
||||
bookTitle = new char[strlen(title) + 1];
|
||||
strcpy(bookTitle, title);
|
||||
}
|
||||
|
||||
void setAuthor(char* authorName) {
|
||||
author = new char[strlen(authorName) + 1];
|
||||
strcpy(author, authorName);
|
||||
}
|
||||
|
||||
void setBookID(int bookID) { this->bookID = bookID; }
|
||||
void setPrice(float price) { this->price = price; }
|
||||
static void setTotalBooks(int total) { totalBooks = total; }
|
||||
|
||||
void setQuantity(int newQuantity) {
|
||||
if (newQuantity >= 0) {
|
||||
totalBooks += (newQuantity - quantity);
|
||||
this->quantity = newQuantity;
|
||||
} else {
|
||||
cout << "Quantity cannot be negative." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Other member functions
|
||||
void calcTotalPrice() {
|
||||
float totalPrice = price * quantity;
|
||||
cout << "The total price for all copies is Rs: " << totalPrice << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int Library :: totalBooks = 0;
|
||||
|
||||
Library getBook_at(Library books[100], int index) {
|
||||
return books[index];
|
||||
}
|
||||
|
||||
void addBook(Library books[100], Library newBook) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == 0) {
|
||||
books[i] = newBook;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Library is full. Cannot add more books," << endl;
|
||||
}
|
||||
|
||||
void removeBook(Library books[100], int bookID) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() == bookID) {
|
||||
books[i] = Library();
|
||||
}
|
||||
}
|
||||
cout << "Book of ID " << bookID << " not found." << endl;
|
||||
}
|
||||
|
||||
void SortByTitle(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getBookTitle(), books[j + 1].getBookTitle()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SortByAuthor(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (strcmp(books[i].getAuthor(), books[j + 1].getAuthor()) > 0) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SortByPrice(Library books[100]) {
|
||||
for (int i = 0; i < Library::getTotalBooks(); i++) {
|
||||
for (int j = 0; j < Library::getTotalBooks() - i; j++) {
|
||||
if (books[i].getPrice() > books[j + 1].getPrice()) {
|
||||
Library temp = books[j];
|
||||
books[j] = books[j + 1];
|
||||
books[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool searchByTittle(Library books[100], char* titlename) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (strcmp(books[i].getBookTitle(), titlename) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Library mostExpensiveBook(Library books[100]) {
|
||||
Library mostExpensive = books[0];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getPrice() > mostExpensive.getPrice()) {
|
||||
mostExpensive = books[i];
|
||||
}
|
||||
}
|
||||
return mostExpensive;
|
||||
}
|
||||
|
||||
void displayBooks(Library books[100]) {
|
||||
cout << "Books in the library: " << endl;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (books[i].getBookID() != 0) {
|
||||
cout << "Book Title: " << books[i].getBookTitle() << ", Author: " << books[i].getAuthor() << ", Price: " << books[i].getPrice() << ", Quantity: " << books[i].getQuantity() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
Library books[100];
|
||||
|
||||
int numBooks;
|
||||
cout << "Enter the total number of books: ";
|
||||
cin >> numBooks;
|
||||
|
||||
for (int i = 0; i < numBooks && i < 100; i++) {
|
||||
char bookName[100];
|
||||
char authorName[100];
|
||||
int id;
|
||||
int booksQuantity;
|
||||
float bookPrice;
|
||||
|
||||
cout << "Enter details for Book " << i + 1 << ":" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(bookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore();
|
||||
cin.getline(authorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> id;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> booksQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> bookPrice;
|
||||
|
||||
// books[i] = Library(bookName, authorName, id, booksQuantity, bookPrice);
|
||||
books[i].setBookTitle(bookName);
|
||||
books[i].setAuthor(authorName);
|
||||
books[i].setBookID(id);
|
||||
books[i].setQuantity(booksQuantity);
|
||||
books[i].setPrice(bookPrice);
|
||||
}
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
SortByTitle(books);
|
||||
cout << "Books sorted by title:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByAuthor(books);
|
||||
cout << "Books sorted by author:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
SortByPrice(books);
|
||||
cout << "Books sorted by price:" << endl;
|
||||
displayBooks(books);
|
||||
|
||||
|
||||
Library mostExpensive = mostExpensiveBook(books);
|
||||
cout << "The most expensive book of the library is: " << mostExpensive.getBookTitle() << " by " << mostExpensive.getAuthor() << endl;
|
||||
|
||||
char newBookName[100];
|
||||
char newAuthorName[100];
|
||||
int newID;
|
||||
int newQuantity;
|
||||
float newPrice;
|
||||
|
||||
cout << "Enter details for the new book:" << endl;
|
||||
cout << "Book title: ";
|
||||
cin.ignore();
|
||||
cin.getline(newBookName, 100);
|
||||
cout << "Name of author: ";
|
||||
//cin.ignore(); // Uncomment if needed
|
||||
cin.getline(newAuthorName, 100);
|
||||
cout << "ID: ";
|
||||
cin >> newID;
|
||||
cout << "Quantity of books: ";
|
||||
cin >> newQuantity;
|
||||
cout << "Price: ";
|
||||
cin >> newPrice;
|
||||
|
||||
addBook(books, Library(newBookName, newAuthorName, newID, newQuantity, newPrice));
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
int removeID;
|
||||
cout << "Enter the ID of the book to remove: ";
|
||||
cin >> removeID;
|
||||
|
||||
removeBook(books, removeID);
|
||||
|
||||
displayBooks(books);
|
||||
|
||||
// Search by title
|
||||
char searchTitle[100];
|
||||
cout << "Enter the title to search: ";
|
||||
cin.ignore();
|
||||
cin.getline(searchTitle, 100);
|
||||
|
||||
if (searchByTittle(books, searchTitle)) {
|
||||
cout << "Book found!" << endl;
|
||||
} else {
|
||||
cout << "Book not found!" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
1
.config/Code/User/History/-1c97f40/entries.json
Normal file
1
.config/Code/User/History/-1c97f40/entries.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Hibernate/hibernate/src/main/java/com/practice/Student.java","entries":[{"id":"hs27.java","timestamp":1711091228223}]}
|
44
.config/Code/User/History/-1c97f40/hs27.java
Normal file
44
.config/Code/User/History/-1c97f40/hs27.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package com.practice;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Student{
|
||||
|
||||
@Id
|
||||
private int rollNo;
|
||||
|
||||
private String name;
|
||||
private double gpa;
|
||||
|
||||
public Student(){
|
||||
|
||||
}
|
||||
|
||||
public Student(int rollNo, String name, double gpa){
|
||||
this.rollNo = rollNo;
|
||||
this.name = name;
|
||||
this.gpa = gpa;
|
||||
}
|
||||
|
||||
public int getRollNo(){
|
||||
return rollNo;
|
||||
}
|
||||
public void setRollNo(int rollNo){
|
||||
this.rollNo = rollNo;
|
||||
}
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public double getGPA(){
|
||||
return gpa;
|
||||
}
|
||||
public void setGPA(double gpa){
|
||||
this.gpa = gpa;
|
||||
}
|
||||
|
||||
}
|
44
.config/Code/User/History/-1cb86127/08bF
Normal file
44
.config/Code/User/History/-1cb86127/08bF
Normal file
|
@ -0,0 +1,44 @@
|
|||
CXXFLAGS = -g3 -Wall -fmessage-length=0 #-Werror
|
||||
|
||||
OBJS = util.o game.o Ball.o Paddle.o
|
||||
|
||||
LIBS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
|
||||
|
||||
TARGET = game
|
||||
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(TARGET)
|
||||
|
||||
######
|
||||
|
||||
# CXX = g++
|
||||
# CXXFLAGS = -Wall -g
|
||||
# LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
# OBJS = game.o Ball.o Paddle.o util.o
|
||||
|
||||
# game: $(OBJS)
|
||||
# $(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
# game.o: game.cpp Ball.h Paddle.h util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Ball.o: Ball.cpp Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Paddle.o: Paddle.cpp Paddle.h Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# util.o: util.cpp util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# clean:
|
||||
# rm -f *.o game
|
44
.config/Code/User/History/-1cb86127/BJai
Normal file
44
.config/Code/User/History/-1cb86127/BJai
Normal file
|
@ -0,0 +1,44 @@
|
|||
CXXFLAGS = -g3 -Wall -fmessage-length=0 #-Werror
|
||||
|
||||
OBJS = util.o game.o Ball.o Paddle.o Brick.o GameLevel.o Level1.o Food.o
|
||||
|
||||
LIBS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
|
||||
|
||||
TARGET = game
|
||||
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(TARGET)
|
||||
|
||||
######
|
||||
|
||||
# CXX = g++
|
||||
# CXXFLAGS = -Wall -g
|
||||
# LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
# OBJS = game.o Ball.o Paddle.o util.o
|
||||
|
||||
# game: $(OBJS)
|
||||
# $(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
# game.o: game.cpp Ball.h Paddle.h util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Ball.o: Ball.cpp Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Paddle.o: Paddle.cpp Paddle.h Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# util.o: util.cpp util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# clean:
|
||||
# rm -f *.o game
|
44
.config/Code/User/History/-1cb86127/Dp2v
Normal file
44
.config/Code/User/History/-1cb86127/Dp2v
Normal file
|
@ -0,0 +1,44 @@
|
|||
CXXFLAGS = -g3 -Wall -fmessage-length=0 #-Werror
|
||||
|
||||
OBJS = util.o game.o Ball.o Paddle.o Brick.o GameLevel.o Level1.o Level2.o Level3.o Food.o PinkFood.o GreenFood.o RedFood.o BlueFood.o YellowFood.o BrickBreaker.o
|
||||
|
||||
LIBS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
|
||||
|
||||
TARGET = game
|
||||
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(TARGET)
|
||||
|
||||
######
|
||||
|
||||
# CXX = g++
|
||||
# CXXFLAGS = -Wall -g
|
||||
# LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
# OBJS = game.o Ball.o Paddle.o util.o
|
||||
|
||||
# game: $(OBJS)
|
||||
# $(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
# game.o: game.cpp Ball.h Paddle.h util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Ball.o: Ball.cpp Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Paddle.o: Paddle.cpp Paddle.h Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# util.o: util.cpp util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# clean:
|
||||
# rm -f *.o game
|
44
.config/Code/User/History/-1cb86127/H85Z
Normal file
44
.config/Code/User/History/-1cb86127/H85Z
Normal file
|
@ -0,0 +1,44 @@
|
|||
CXXFLAGS = -g3 -Wall -fmessage-length=0 #-Werror
|
||||
|
||||
OBJS = util.o game.o Ball.o Paddle.o Brick.o GameLevel.o Level1.o Food.o PinkFood.o GreenFood.o RedFood.o BlueFood.o YellowFood.o BrickBreaker.o
|
||||
|
||||
LIBS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
|
||||
|
||||
TARGET = game
|
||||
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(TARGET)
|
||||
|
||||
######
|
||||
|
||||
# CXX = g++
|
||||
# CXXFLAGS = -Wall -g
|
||||
# LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
# OBJS = game.o Ball.o Paddle.o util.o
|
||||
|
||||
# game: $(OBJS)
|
||||
# $(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
# game.o: game.cpp Ball.h Paddle.h util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Ball.o: Ball.cpp Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Paddle.o: Paddle.cpp Paddle.h Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# util.o: util.cpp util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# clean:
|
||||
# rm -f *.o game
|
18
.config/Code/User/History/-1cb86127/Y9b6
Normal file
18
.config/Code/User/History/-1cb86127/Y9b6
Normal file
|
@ -0,0 +1,18 @@
|
|||
# CXXFLAGS = -g3 -Wall -fmessage-length=0 #-Werror
|
||||
|
||||
# OBJS = util.o game.o
|
||||
|
||||
# LIBS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
|
||||
|
||||
# TARGET = game
|
||||
|
||||
|
||||
# $(TARGET): $(OBJS)
|
||||
# $(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||
|
||||
# all: $(TARGET)
|
||||
|
||||
# clean:
|
||||
# rm -f $(OBJS) $(TARGET)
|
44
.config/Code/User/History/-1cb86127/bIOb
Normal file
44
.config/Code/User/History/-1cb86127/bIOb
Normal file
|
@ -0,0 +1,44 @@
|
|||
CXXFLAGS = -g3 -Wall -fmessage-length=0 #-Werror
|
||||
|
||||
OBJS = util.o game.o Ball.o Paddle.o Brick.o GameLevel.o Level1.o Level2.o Level3.o Food.o PinkFood.o GreenFood.o RedFood.o BlueFood.o YellowFood.o BrickBreaker.o
|
||||
|
||||
LIBS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
|
||||
|
||||
TARGET = game
|
||||
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(TARGET)
|
||||
|
||||
######
|
||||
|
||||
# CXX = g++
|
||||
# CXXFLAGS = -Wall -g
|
||||
# LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
# OBJS = game.o Ball.o Paddle.o util.o
|
||||
|
||||
# game: $(OBJS)
|
||||
# $(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
# game.o: game.cpp Ball.h Paddle.h util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Ball.o: Ball.cpp Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Paddle.o: Paddle.cpp Paddle.h Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# util.o: util.cpp util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# clean:
|
||||
# rm -f *.o game
|
42
.config/Code/User/History/-1cb86127/eNtw
Normal file
42
.config/Code/User/History/-1cb86127/eNtw
Normal file
|
@ -0,0 +1,42 @@
|
|||
# CXXFLAGS = -g3 -Wall -fmessage-length=0 #-Werror
|
||||
|
||||
# OBJS = util.o game.o
|
||||
|
||||
# LIBS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
|
||||
|
||||
# TARGET = game
|
||||
|
||||
|
||||
# $(TARGET): $(OBJS)
|
||||
# $(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||
|
||||
# all: $(TARGET)
|
||||
|
||||
# clean:
|
||||
# rm -f $(OBJS) $(TARGET)
|
||||
|
||||
CXX = g++
|
||||
CXXFLAGS = -Wall -g
|
||||
LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
OBJS = game.o Ball.o Paddle.o util.o
|
||||
|
||||
game: $(OBJS)
|
||||
$(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
game.o: game.cpp Ball.h Paddle.h util.h
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
Ball.o: Ball.cpp Ball.h
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
Paddle.o: Paddle.cpp Paddle.h Ball.h
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
util.o: util.cpp util.h
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o game
|
1
.config/Code/User/History/-1cb86127/entries.json
Normal file
1
.config/Code/User/History/-1cb86127/entries.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Stuff/OOP/Project/Makefile","entries":[{"id":"Y9b6","timestamp":1714274464750},{"id":"eNtw","source":"Workspace Edit","timestamp":1714274470077},{"id":"pQQr","timestamp":1714274552961},{"id":"08bF","timestamp":1714274577412},{"id":"oa99","timestamp":1714444420261},{"id":"w8dM","timestamp":1714702095993},{"id":"BJai","timestamp":1714702188165},{"id":"o8JU","timestamp":1714896759288},{"id":"H85Z","timestamp":1715078595740},{"id":"Dp2v","timestamp":1715162236826},{"id":"bIOb","timestamp":1715185042230}]}
|
44
.config/Code/User/History/-1cb86127/o8JU
Normal file
44
.config/Code/User/History/-1cb86127/o8JU
Normal file
|
@ -0,0 +1,44 @@
|
|||
CXXFLAGS = -g3 -Wall -fmessage-length=0 #-Werror
|
||||
|
||||
OBJS = util.o game.o Ball.o Paddle.o Brick.o GameLevel.o Level1.o Food.o PinkFood.o GreenFood.o RedFood.o BlueFood.o YellowFood.o
|
||||
|
||||
LIBS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
|
||||
|
||||
TARGET = game
|
||||
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(TARGET)
|
||||
|
||||
######
|
||||
|
||||
# CXX = g++
|
||||
# CXXFLAGS = -Wall -g
|
||||
# LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
# OBJS = game.o Ball.o Paddle.o util.o
|
||||
|
||||
# game: $(OBJS)
|
||||
# $(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
# game.o: game.cpp Ball.h Paddle.h util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Ball.o: Ball.cpp Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Paddle.o: Paddle.cpp Paddle.h Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# util.o: util.cpp util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# clean:
|
||||
# rm -f *.o game
|
44
.config/Code/User/History/-1cb86127/oa99
Normal file
44
.config/Code/User/History/-1cb86127/oa99
Normal file
|
@ -0,0 +1,44 @@
|
|||
CXXFLAGS = -g3 -Wall -fmessage-length=0 #-Werror
|
||||
|
||||
OBJS = util.o game.o Ball.o Paddle.o Brick.o GameLevel.o Level1.o
|
||||
|
||||
LIBS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
|
||||
|
||||
TARGET = game
|
||||
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(TARGET)
|
||||
|
||||
######
|
||||
|
||||
# CXX = g++
|
||||
# CXXFLAGS = -Wall -g
|
||||
# LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
# OBJS = game.o Ball.o Paddle.o util.o
|
||||
|
||||
# game: $(OBJS)
|
||||
# $(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
# game.o: game.cpp Ball.h Paddle.h util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Ball.o: Ball.cpp Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Paddle.o: Paddle.cpp Paddle.h Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# util.o: util.cpp util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# clean:
|
||||
# rm -f *.o game
|
44
.config/Code/User/History/-1cb86127/pQQr
Normal file
44
.config/Code/User/History/-1cb86127/pQQr
Normal file
|
@ -0,0 +1,44 @@
|
|||
# CXXFLAGS = -g3 -Wall -fmessage-length=0 #-Werror
|
||||
|
||||
# OBJS = util.o game.o
|
||||
|
||||
# LIBS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
|
||||
|
||||
# TARGET = game
|
||||
|
||||
|
||||
# $(TARGET): $(OBJS)
|
||||
# $(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||
|
||||
# all: $(TARGET)
|
||||
|
||||
# clean:
|
||||
# rm -f $(OBJS) $(TARGET)
|
||||
|
||||
######
|
||||
|
||||
CXX = g++
|
||||
CXXFLAGS = -Wall -g
|
||||
LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
OBJS = game.o Ball.o Paddle.o util.o
|
||||
|
||||
game: $(OBJS)
|
||||
$(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
game.o: game.cpp Ball.h Paddle.h util.h
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
Ball.o: Ball.cpp Ball.h
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
Paddle.o: Paddle.cpp Paddle.h Ball.h
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
util.o: util.cpp util.h
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o game
|
44
.config/Code/User/History/-1cb86127/w8dM
Normal file
44
.config/Code/User/History/-1cb86127/w8dM
Normal file
|
@ -0,0 +1,44 @@
|
|||
CXXFLAGS = -g3 -Wall -fmessage-length=0 #-Werror
|
||||
|
||||
OBJS = util.o game.o Ball.o Paddle.o Brick.o GameLevel.o Level1.o Food.o
|
||||
|
||||
LIBS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
|
||||
|
||||
TARGET = game
|
||||
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(TARGET)
|
||||
|
||||
######
|
||||
|
||||
# CXX = g++
|
||||
# CXXFLAGS = -Wall -g
|
||||
# LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lglut -lGLU -lGL -lX11 -lfreeimage -pthread
|
||||
|
||||
# OBJS = game.o Ball.o Paddle.o util.o
|
||||
|
||||
# game: $(OBJS)
|
||||
# $(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
# game.o: game.cpp Ball.h Paddle.h util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Ball.o: Ball.cpp Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# Paddle.o: Paddle.cpp Paddle.h Ball.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# util.o: util.cpp util.h
|
||||
# $(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
# clean:
|
||||
# rm -f *.o game
|
86
.config/Code/User/History/-270545a0/004C.java
Normal file
86
.config/Code/User/History/-270545a0/004C.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
pt.getChildren().add(tt);
|
||||
tab.shrink();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/0KG0.java
Normal file
70
.config/Code/User/History/-270545a0/0KG0.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
88
.config/Code/User/History/-270545a0/0mRF.java
Normal file
88
.config/Code/User/History/-270545a0/0mRF.java
Normal file
|
@ -0,0 +1,88 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
75
.config/Code/User/History/-270545a0/3Dy7.java
Normal file
75
.config/Code/User/History/-270545a0/3Dy7.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
ttTabs.play();
|
||||
ttTabs.setOnFinished(ev -> {
|
||||
index.incrementAndGet();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.play();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
87
.config/Code/User/History/-270545a0/3Gha.java
Normal file
87
.config/Code/User/History/-270545a0/3Gha.java
Normal file
|
@ -0,0 +1,87 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
86
.config/Code/User/History/-270545a0/3v5W.java
Normal file
86
.config/Code/User/History/-270545a0/3v5W.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
pt.getChildren().add(tt);
|
||||
tab.shrink();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/4DaJ.java
Normal file
70
.config/Code/User/History/-270545a0/4DaJ.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
86
.config/Code/User/History/-270545a0/4fVm.java
Normal file
86
.config/Code/User/History/-270545a0/4fVm.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/4tD7.java
Normal file
70
.config/Code/User/History/-270545a0/4tD7.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
79
.config/Code/User/History/-270545a0/5MgE.java
Normal file
79
.config/Code/User/History/-270545a0/5MgE.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
ttTabs.play();
|
||||
ttTabs.setOnFinished(ev -> {
|
||||
index.incrementAndGet();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.play();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/5PTH.java
Normal file
70
.config/Code/User/History/-270545a0/5PTH.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/8M4F.java
Normal file
70
.config/Code/User/History/-270545a0/8M4F.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
80
.config/Code/User/History/-270545a0/9UzD.java
Normal file
80
.config/Code/User/History/-270545a0/9UzD.java
Normal file
|
@ -0,0 +1,80 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
ttTabs.play();
|
||||
ttTabs.setOnFinished(ev -> {
|
||||
index.incrementAndGet();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
ttTabs.play();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
86
.config/Code/User/History/-270545a0/DY10.java
Normal file
86
.config/Code/User/History/-270545a0/DY10.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
pt.getChildren().add(tt);
|
||||
tab.shrink();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
89
.config/Code/User/History/-270545a0/E4xn.java
Normal file
89
.config/Code/User/History/-270545a0/E4xn.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
tab.shrink();
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
// TODO: fix the animation for right most tab closing
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tt.play();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
86
.config/Code/User/History/-270545a0/EOJH.java
Normal file
86
.config/Code/User/History/-270545a0/EOJH.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
pt.getChildren().add(tt);
|
||||
tab.shrink();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
89
.config/Code/User/History/-270545a0/Eg02.java
Normal file
89
.config/Code/User/History/-270545a0/Eg02.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
// TODO: fix the animation for right most tab closing
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
89
.config/Code/User/History/-270545a0/FtFe.java
Normal file
89
.config/Code/User/History/-270545a0/FtFe.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
// TODO: fix the animation for right most tab closing
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
86
.config/Code/User/History/-270545a0/IFxT.java
Normal file
86
.config/Code/User/History/-270545a0/IFxT.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
pt.getChildren().add(tt);
|
||||
tab.shrink();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
86
.config/Code/User/History/-270545a0/JDH2.java
Normal file
86
.config/Code/User/History/-270545a0/JDH2.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
83
.config/Code/User/History/-270545a0/JRQb.java
Normal file
83
.config/Code/User/History/-270545a0/JRQb.java
Normal file
|
@ -0,0 +1,83 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
for(int i=index.get();i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getNodes().get(0));
|
||||
}
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/KVIZ.java
Normal file
70
.config/Code/User/History/-270545a0/KVIZ.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/KZQp.java
Normal file
70
.config/Code/User/History/-270545a0/KZQp.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
84
.config/Code/User/History/-270545a0/ODPd.java
Normal file
84
.config/Code/User/History/-270545a0/ODPd.java
Normal file
|
@ -0,0 +1,84 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
pt.getChildren().add(tt);
|
||||
tab.shrink();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
76
.config/Code/User/History/-270545a0/RMfP.java
Normal file
76
.config/Code/User/History/-270545a0/RMfP.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
// ParallelTransition pt = new ParallelTransition();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
ttTabs.play();
|
||||
ttTabs.setOnFinished(ev -> {
|
||||
index.incrementAndGet();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.play();
|
||||
// pt.getChildren().add(ttTabs);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/ThiM.java
Normal file
70
.config/Code/User/History/-270545a0/ThiM.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
79
.config/Code/User/History/-270545a0/VM8K.java
Normal file
79
.config/Code/User/History/-270545a0/VM8K.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
ttTabs.play();
|
||||
ttTabs.setOnFinished(ev -> {
|
||||
index.incrementAndGet();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.play();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
80
.config/Code/User/History/-270545a0/VRWR.java
Normal file
80
.config/Code/User/History/-270545a0/VRWR.java
Normal file
|
@ -0,0 +1,80 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/YMpI.java
Normal file
70
.config/Code/User/History/-270545a0/YMpI.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
89
.config/Code/User/History/-270545a0/ZO5D.java
Normal file
89
.config/Code/User/History/-270545a0/ZO5D.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
tab.shrink();
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
// TODO: fix the animation for right most tab closing
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tt.play();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
86
.config/Code/User/History/-270545a0/Zwza.java
Normal file
86
.config/Code/User/History/-270545a0/Zwza.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
pt.getChildren().add(tt);
|
||||
tab.shrink();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
89
.config/Code/User/History/-270545a0/bQe8.java
Normal file
89
.config/Code/User/History/-270545a0/bQe8.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
// TODO: fix the animation for right most tab closing
|
||||
|
||||
// ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
// tt.setByX(-155);
|
||||
// for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
// ttTabs.setByX(-155);
|
||||
// pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
// pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
89
.config/Code/User/History/-270545a0/bhTm.java
Normal file
89
.config/Code/User/History/-270545a0/bhTm.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
// ((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
tab.shrink();
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
// TODO: fix the animation for right most tab closing
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tt.play();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
83
.config/Code/User/History/-270545a0/c7F9.java
Normal file
83
.config/Code/User/History/-270545a0/c7F9.java
Normal file
|
@ -0,0 +1,83 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
for(int i=index.get();i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
}
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
76
.config/Code/User/History/-270545a0/cEog.java
Normal file
76
.config/Code/User/History/-270545a0/cEog.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
if(index<Main.getNoOfTabs()){
|
||||
|
||||
}
|
||||
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
ttTabs.play();
|
||||
ttTabs.setOnFinished(ev -> {
|
||||
index.incrementAndGet();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.play();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
79
.config/Code/User/History/-270545a0/cWkE.java
Normal file
79
.config/Code/User/History/-270545a0/cWkE.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
89
.config/Code/User/History/-270545a0/dpGI.java
Normal file
89
.config/Code/User/History/-270545a0/dpGI.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
// ((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
// TODO: fix the animation for right most tab closing
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/eRrv.java
Normal file
70
.config/Code/User/History/-270545a0/eRrv.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
1
.config/Code/User/History/-270545a0/entries.json
Normal file
1
.config/Code/User/History/-270545a0/entries.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Stuff/JBrowse/jbrowse/src/main/java/com/jb/TabButton.java","entries":[{"id":"cEog.java","timestamp":1713589737414},{"id":"3Dy7.java","timestamp":1713589751217},{"id":"5MgE.java","timestamp":1713589847691},{"id":"9UzD.java","timestamp":1713589945458},{"id":"VM8K.java","timestamp":1713589959418},{"id":"yPmE.java","timestamp":1713590061249},{"id":"fl24.java","timestamp":1713591913239},{"id":"RMfP.java","timestamp":1713592001222},{"id":"nf2J.java","timestamp":1713781581300},{"id":"cWkE.java","timestamp":1713781602354},{"id":"VRWR.java","source":"Import 'ParallelTransition' (javafx.animation)","timestamp":1713781607847},{"id":"c7F9.java","timestamp":1713781649038},{"id":"JRQb.java","timestamp":1713781666909},{"id":"sKrq.java","timestamp":1713781684869},{"id":"jeRu.java","timestamp":1713781696553},{"id":"0mRF.java","timestamp":1713782010233},{"id":"004C.java","timestamp":1713782977838},{"id":"ODPd.java","timestamp":1713783039422},{"id":"3v5W.java","timestamp":1713783144182},{"id":"IFxT.java","timestamp":1713783320466},{"id":"DY10.java","timestamp":1713783331853},{"id":"EOJH.java","timestamp":1713783372560},{"id":"Zwza.java","timestamp":1713783421333},{"id":"4fVm.java","timestamp":1713783451470},{"id":"xUYa.java","timestamp":1713783523337},{"id":"3Gha.java","timestamp":1713783550391},{"id":"Eg02.java","timestamp":1713783632838},{"id":"FtFe.java","timestamp":1713789651042},{"id":"gXId.java","timestamp":1713789674861},{"id":"gAaY.java","timestamp":1713789688441},{"id":"pAn4.java","timestamp":1713789740113},{"id":"bQe8.java","timestamp":1713789761655},{"id":"ZO5D.java","timestamp":1713789873687},{"id":"E4xn.java","timestamp":1713789888551},{"id":"bhTm.java","timestamp":1713790139862},{"id":"dpGI.java","timestamp":1713790181619},{"id":"JDH2.java","timestamp":1713790215438},{"id":"5PTH.java","timestamp":1713790248319},{"id":"q5gM.java","source":"Workspace Edit","timestamp":1713790432851},{"id":"jC5p.java","timestamp":1713834289919},{"id":"KZQp.java","timestamp":1713834308931},{"id":"4DaJ.java","timestamp":1713834320908},{"id":"eRrv.java","timestamp":1713834350590},{"id":"KVIZ.java","timestamp":1713834394746},{"id":"ThiM.java","timestamp":1713953194310},{"id":"0KG0.java","timestamp":1713955804099},{"id":"YMpI.java","timestamp":1713956236909},{"id":"qK5q.java","timestamp":1713956252241},{"id":"4tD7.java","timestamp":1713957991559},{"id":"8M4F.java","timestamp":1713958014969}]}
|
77
.config/Code/User/History/-270545a0/fl24.java
Normal file
77
.config/Code/User/History/-270545a0/fl24.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
// ParallelTransition pt = new ParallelTransition();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
ttTabs.play();
|
||||
ttTabs.setOnFinished(ev -> {
|
||||
index.incrementAndGet();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.play();
|
||||
// pt.getChildren().add(ttTabs);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
89
.config/Code/User/History/-270545a0/gAaY.java
Normal file
89
.config/Code/User/History/-270545a0/gAaY.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
tab.shrink();
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
// TODO: fix the animation for right most tab closing
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tt.play();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
89
.config/Code/User/History/-270545a0/gXId.java
Normal file
89
.config/Code/User/History/-270545a0/gXId.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
tab.shrink();
|
||||
// TODO: fix the animation for right most tab closing
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tt.play();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/jC5p.java
Normal file
70
.config/Code/User/History/-270545a0/jC5p.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
// @SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
86
.config/Code/User/History/-270545a0/jeRu.java
Normal file
86
.config/Code/User/History/-270545a0/jeRu.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
for(int i=index.get();i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
pt.play();
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
79
.config/Code/User/History/-270545a0/nf2J.java
Normal file
79
.config/Code/User/History/-270545a0/nf2J.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
|
||||
|
||||
|
||||
// ParallelTransition pt = new ParallelTransition();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
89
.config/Code/User/History/-270545a0/pAn4.java
Normal file
89
.config/Code/User/History/-270545a0/pAn4.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
tab.shrink();
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else Main.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
// TODO: fix the animation for right most tab closing
|
||||
|
||||
// ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
// tt.setByX(-155);
|
||||
// for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
// ttTabs.setByX(-155);
|
||||
// pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
tt.play();
|
||||
// pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/q5gM.java
Normal file
70
.config/Code/User/History/-270545a0/q5gM.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
70
.config/Code/User/History/-270545a0/qK5q.java
Normal file
70
.config/Code/User/History/-270545a0/qK5q.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(JBrowse.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(JBrowse.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
int index = JBrowse.getTabs().indexOf(tab);
|
||||
JBrowse.getTabs().remove(tab);
|
||||
|
||||
if(index<JBrowse.getNoOfTabs()) JBrowse.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
else JBrowse.getTabs().get(index-1).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), JBrowse.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<JBrowse.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), JBrowse.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tab.shrink();
|
||||
tt.play();
|
||||
pt.play();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
85
.config/Code/User/History/-270545a0/sKrq.java
Normal file
85
.config/Code/User/History/-270545a0/sKrq.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
for(int i=index.get();i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getNodes().get(0));
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
pt.play();
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
86
.config/Code/User/History/-270545a0/xUYa.java
Normal file
86
.config/Code/User/History/-270545a0/xUYa.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.jb;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getTabButton(), tab.getStackPane());
|
||||
int index = Main.getTabs().indexOf(tab);
|
||||
Main.getTabs().remove(tab);
|
||||
|
||||
if(index<Main.getNoOfTabs()) Main.getTabs().get(index).getTabButton().toggleButton.setSelected(true);
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
for(int i=index;i<Main.getNoOfTabs();i++){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(i).getTabButton());
|
||||
ttTabs.setByX(-155);
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
pt.play();
|
||||
|
||||
|
||||
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.setByX(-155);
|
||||
// ttTabs.play();
|
||||
// ttTabs.setOnFinished(ev -> {
|
||||
// index.incrementAndGet();
|
||||
// if(index.get()<Main.getNoOfTabs()){
|
||||
// ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
// ttTabs.play();
|
||||
// // pt.getChildren().add(ttTabs);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
80
.config/Code/User/History/-270545a0/yPmE.java
Normal file
80
.config/Code/User/History/-270545a0/yPmE.java
Normal file
|
@ -0,0 +1,80 @@
|
|||
package com.jb;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TabButton extends StackPane{
|
||||
|
||||
private ToggleButton toggleButton;
|
||||
private Button closeBtn;
|
||||
@SuppressWarnings("unused")
|
||||
private BrowserTab tab;
|
||||
|
||||
public TabButton(BrowserTab tab){
|
||||
toggleButton = new ToggleButton("Home");
|
||||
closeBtn = new Button("");
|
||||
this.tab = tab;
|
||||
|
||||
this.setId("tab-button-container");
|
||||
toggleButton.setId("tab-button");
|
||||
closeBtn.setId("tab-close-button");
|
||||
|
||||
toggleButton.setSelected(true);
|
||||
toggleButton.setToggleGroup(Main.getToggleGroup());
|
||||
closeBtn.setTranslateX(120);
|
||||
|
||||
StackPane.setAlignment(toggleButton, Pos.TOP_LEFT);
|
||||
StackPane.setAlignment(closeBtn, Pos.TOP_LEFT);
|
||||
|
||||
this.getChildren().addAll(toggleButton, closeBtn);
|
||||
|
||||
|
||||
|
||||
toggleButton.setOnAction(e -> {
|
||||
if(!toggleButton.isSelected()) toggleButton.setSelected(true);
|
||||
tab.bringToFront();
|
||||
});
|
||||
|
||||
closeBtn.setOnAction(e -> {
|
||||
if(Main.getNoOfTabs() == 1) ((Stage)this.getScene().getWindow()).close();
|
||||
else{
|
||||
((StackPane)(this.getScene().getRoot())).getChildren().removeAll(tab.getNodes());
|
||||
AtomicInteger index = new AtomicInteger(Main.getTabs().indexOf(tab));
|
||||
Main.getTabs().remove(tab);
|
||||
TranslateTransition tt = new TranslateTransition(new Duration(250), Main.getNewTabBtn());
|
||||
tt.setByX(-155);
|
||||
tt.play();
|
||||
tab.shrink();
|
||||
|
||||
ParallelTransition pt = new ParallelTransition();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
TranslateTransition ttTabs = new TranslateTransition(new Duration(250), Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.setByX(-155);
|
||||
ttTabs.play();
|
||||
ttTabs.setOnFinished(ev -> {
|
||||
index.incrementAndGet();
|
||||
if(index.get()<Main.getNoOfTabs()){
|
||||
ttTabs.setNode(Main.getTabs().get(index.get()).getNodes().get(0));
|
||||
ttTabs.play();
|
||||
pt.getChildren().add(ttTabs);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
30
.config/Code/User/History/-2b6dc0c0/3xem.cpp
Normal file
30
.config/Code/User/History/-2b6dc0c0/3xem.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
};
|
||||
class B{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
};
|
||||
class C{
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
44
.config/Code/User/History/-2b6dc0c0/4X7m.cpp
Normal file
44
.config/Code/User/History/-2b6dc0c0/4X7m.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"a show\n";
|
||||
}
|
||||
};
|
||||
class B{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"b show\n";
|
||||
}
|
||||
};
|
||||
class C : public A, public B{
|
||||
public:
|
||||
C(){
|
||||
cout<<"C cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"c show\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
C obj;
|
||||
obj.show();
|
||||
obj.A::show();
|
||||
|
||||
return 0;
|
||||
}
|
24
.config/Code/User/History/-2b6dc0c0/8X01.cpp
Normal file
24
.config/Code/User/History/-2b6dc0c0/8X01.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
|
||||
};
|
||||
class B{
|
||||
|
||||
};
|
||||
class C{
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
50
.config/Code/User/History/-2b6dc0c0/EDS4.cpp
Normal file
50
.config/Code/User/History/-2b6dc0c0/EDS4.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"a show\n";
|
||||
}
|
||||
};
|
||||
class B : public A{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"b show\n";
|
||||
}
|
||||
};
|
||||
class C : public A{
|
||||
public:
|
||||
C(){
|
||||
cout<<"C cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"c show\n";
|
||||
}
|
||||
};
|
||||
class D : public A, public B{
|
||||
public:
|
||||
D(){
|
||||
cout<<"D cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"d show\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
D obj;
|
||||
return 0;
|
||||
}
|
50
.config/Code/User/History/-2b6dc0c0/HSqH.cpp
Normal file
50
.config/Code/User/History/-2b6dc0c0/HSqH.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"a show\n";
|
||||
}
|
||||
};
|
||||
class B : public A{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"b show\n";
|
||||
}
|
||||
};
|
||||
class C : public A{
|
||||
public:
|
||||
C(){
|
||||
cout<<"C cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"c show\n";
|
||||
}
|
||||
};
|
||||
class D : public C, public B{
|
||||
public:
|
||||
D(){
|
||||
cout<<"D cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"d show\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
D obj;
|
||||
return 0;
|
||||
}
|
44
.config/Code/User/History/-2b6dc0c0/IBub.cpp
Normal file
44
.config/Code/User/History/-2b6dc0c0/IBub.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"a show\n";
|
||||
}
|
||||
};
|
||||
class B : public A{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"b show\n";
|
||||
}
|
||||
};
|
||||
class C : public A{
|
||||
public:
|
||||
C(){
|
||||
cout<<"C cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"c show\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
C obj;
|
||||
obj.show();
|
||||
// obj.A::show();
|
||||
|
||||
return 0;
|
||||
}
|
42
.config/Code/User/History/-2b6dc0c0/IgwX.cpp
Normal file
42
.config/Code/User/History/-2b6dc0c0/IgwX.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"a show\n";
|
||||
}
|
||||
};
|
||||
class B{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"b show\n";
|
||||
}
|
||||
};
|
||||
class C : public A, public B{
|
||||
public:
|
||||
C(){
|
||||
cout<<"C cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"c show\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
44
.config/Code/User/History/-2b6dc0c0/LNvO.cpp
Normal file
44
.config/Code/User/History/-2b6dc0c0/LNvO.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"a show\n";
|
||||
}
|
||||
};
|
||||
class B{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"b show\n";
|
||||
}
|
||||
};
|
||||
class C : public A, public B{
|
||||
public:
|
||||
C(){
|
||||
cout<<"C cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"c show\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
C obj;
|
||||
obj.show();
|
||||
// obj.A::show();
|
||||
|
||||
return 0;
|
||||
}
|
53
.config/Code/User/History/-2b6dc0c0/RSSJ.cpp
Normal file
53
.config/Code/User/History/-2b6dc0c0/RSSJ.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"a show\n";
|
||||
}
|
||||
};
|
||||
class B : public A{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"b show\n";
|
||||
}
|
||||
};
|
||||
class C : public A{
|
||||
public:
|
||||
C(){
|
||||
cout<<"C cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"c show\n";
|
||||
}
|
||||
};
|
||||
class D : public A, public B{
|
||||
public:
|
||||
D(){
|
||||
cout<<"D cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"d show\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
C obj;
|
||||
obj.show();
|
||||
// obj.A::show();
|
||||
|
||||
return 0;
|
||||
}
|
44
.config/Code/User/History/-2b6dc0c0/SXPy.cpp
Normal file
44
.config/Code/User/History/-2b6dc0c0/SXPy.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"a show\n";
|
||||
}
|
||||
};
|
||||
class B{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"b show\n";
|
||||
}
|
||||
};
|
||||
class C : public A, public B{
|
||||
public:
|
||||
C(){
|
||||
cout<<"C cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"c show\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
C obj;
|
||||
obj.show();
|
||||
// obj.A::show();
|
||||
|
||||
return 0;
|
||||
}
|
27
.config/Code/User/History/-2b6dc0c0/WcUr.cpp
Normal file
27
.config/Code/User/History/-2b6dc0c0/WcUr.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
};
|
||||
class B{
|
||||
|
||||
};
|
||||
class C{
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
44
.config/Code/User/History/-2b6dc0c0/YDZM.cpp
Normal file
44
.config/Code/User/History/-2b6dc0c0/YDZM.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"a show\n";
|
||||
}
|
||||
};
|
||||
class B{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"b show\n";
|
||||
}
|
||||
};
|
||||
class C : public A, public B{
|
||||
public:
|
||||
C(){
|
||||
cout<<"C cstr\n";
|
||||
}
|
||||
// void show(){
|
||||
// cout<<"c show\n";
|
||||
// }
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
C obj;
|
||||
obj.show();
|
||||
// obj.A::show();
|
||||
|
||||
return 0;
|
||||
}
|
44
.config/Code/User/History/-2b6dc0c0/dE6P.cpp
Normal file
44
.config/Code/User/History/-2b6dc0c0/dE6P.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"a show\n";
|
||||
}
|
||||
};
|
||||
class B{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"b show\n";
|
||||
}
|
||||
};
|
||||
class C : public A, public B{
|
||||
public:
|
||||
C(){
|
||||
cout<<"C cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"c show\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
C obj;
|
||||
obj.show();
|
||||
// obj.A::show();
|
||||
|
||||
return 0;
|
||||
}
|
1
.config/Code/User/History/-2b6dc0c0/entries.json
Normal file
1
.config/Code/User/History/-2b6dc0c0/entries.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Stuff/OOP/test.cpp","entries":[{"id":"ye9H.cpp","timestamp":1714454764066},{"id":"8X01.cpp","timestamp":1714454793232},{"id":"WcUr.cpp","timestamp":1714454819167},{"id":"3xem.cpp","timestamp":1714454832944},{"id":"gdmx.cpp","timestamp":1714454852374},{"id":"yJzR.cpp","timestamp":1714454875514},{"id":"wEf5.cpp","timestamp":1714454900836},{"id":"IgwX.cpp","timestamp":1714454922041},{"id":"vr11.cpp","timestamp":1714454940532},{"id":"4X7m.cpp","timestamp":1714455417438},{"id":"SXPy.cpp","timestamp":1714455482974},{"id":"LNvO.cpp","timestamp":1714455551442},{"id":"YDZM.cpp","timestamp":1714455679587},{"id":"dE6P.cpp","timestamp":1714455702592},{"id":"IBub.cpp","timestamp":1714457715011},{"id":"fyo2.cpp","timestamp":1714457747761},{"id":"RSSJ.cpp","timestamp":1714457772256},{"id":"EDS4.cpp","timestamp":1714457793045},{"id":"HSqH.cpp","timestamp":1714457870531},{"id":"uARp.cpp","timestamp":1714457930000},{"id":"nOOp.cpp","timestamp":1714457946937},{"id":"yYX1.cpp","timestamp":1714457988065}]}
|
47
.config/Code/User/History/-2b6dc0c0/fyo2.cpp
Normal file
47
.config/Code/User/History/-2b6dc0c0/fyo2.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class A{
|
||||
public:
|
||||
A(){
|
||||
cout<<"A cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"a show\n";
|
||||
}
|
||||
};
|
||||
class B : public A{
|
||||
public:
|
||||
B(){
|
||||
cout<<"B cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"b show\n";
|
||||
}
|
||||
};
|
||||
class C : public A{
|
||||
public:
|
||||
C(){
|
||||
cout<<"C cstr\n";
|
||||
}
|
||||
void show(){
|
||||
cout<<"c show\n";
|
||||
}
|
||||
};
|
||||
class D : public A, public B{
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
C obj;
|
||||
obj.show();
|
||||
// obj.A::show();
|
||||
|
||||
return 0;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue