diff --git a/Answers/Add Your Projects Here.txt b/40230112109/Add Your Projects Here.txt
similarity index 100%
rename from Answers/Add Your Projects Here.txt
rename to 40230112109/Add Your Projects Here.txt
diff --git a/40230112109/LMS/.idea/workspace.xml b/40230112109/LMS/.idea/workspace.xml
new file mode 100644
index 0000000..eaad679
--- /dev/null
+++ b/40230112109/LMS/.idea/workspace.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "associatedIndex": 4
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1713872559761
+
+
+ 1713872559761
+
+
+
+
\ No newline at end of file
diff --git a/40230112109/Library/.gitignore b/40230112109/Library/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/40230112109/Library/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/40230112109/Library/.idea/.gitignore b/40230112109/Library/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/40230112109/Library/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/40230112109/Library/.idea/.name b/40230112109/Library/.idea/.name
new file mode 100644
index 0000000..002da1d
--- /dev/null
+++ b/40230112109/Library/.idea/.name
@@ -0,0 +1 @@
+Main.java
\ No newline at end of file
diff --git a/40230112109/Library/.idea/encodings.xml b/40230112109/Library/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/40230112109/Library/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/40230112109/Library/.idea/inspectionProfiles/Project_Default.xml b/40230112109/Library/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..c43d165
--- /dev/null
+++ b/40230112109/Library/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/40230112109/Library/.idea/misc.xml b/40230112109/Library/.idea/misc.xml
new file mode 100644
index 0000000..4258c62
--- /dev/null
+++ b/40230112109/Library/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/40230112109/Library/.idea/uiDesigner.xml b/40230112109/Library/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/40230112109/Library/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/40230112109/Library/.idea/vcs.xml b/40230112109/Library/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/40230112109/Library/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/40230112109/Library/pom.xml b/40230112109/Library/pom.xml
new file mode 100644
index 0000000..95d6586
--- /dev/null
+++ b/40230112109/Library/pom.xml
@@ -0,0 +1,17 @@
+
+
+ 4.0.0
+
+ org.example
+ LMS
+ 1.0-SNAPSHOT
+
+
+ 18
+ 18
+ UTF-8
+
+
+
\ No newline at end of file
diff --git a/40230112109/Library/src/main/java/org/example/Admins.java b/40230112109/Library/src/main/java/org/example/Admins.java
new file mode 100644
index 0000000..a02ff00
--- /dev/null
+++ b/40230112109/Library/src/main/java/org/example/Admins.java
@@ -0,0 +1,27 @@
+package org.example;
+
+import java.util.Date;
+
+public class Admins extends User{
+ // Attributes
+ private String password;
+ // Getters & Setters
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ // Constructor
+ Admins(String name, String uniqueID, String phoneNumber, String password){
+ super(name, uniqueID, phoneNumber);
+ this.password = password;
+ }
+
+ @Override
+ public void register(Date registrationDate) {
+
+ }
+}
diff --git a/40230112109/Library/src/main/java/org/example/Book.java b/40230112109/Library/src/main/java/org/example/Book.java
new file mode 100644
index 0000000..d3587ec
--- /dev/null
+++ b/40230112109/Library/src/main/java/org/example/Book.java
@@ -0,0 +1,65 @@
+package org.example;
+
+import java.util.UUID;
+//***** Attributes *****//
+public class Book {
+ private String bookID;
+ private String title;
+ private String author;
+ private String description;
+ private boolean availability;
+
+ // Constructor
+ Book(String title, String author, String description){
+ this.title = title;
+ this.author = author;
+ this.description = description;
+ this.bookID = generateUniqueId();
+ this.availability = true;
+ }
+ // Getters and Setters
+
+ public String getBookID() {
+ return bookID;
+ }
+
+ public void setBookID(String bookID) {
+ this.bookID = bookID;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isAvailability() {
+ return availability;
+ }
+
+ public void setAvailability(boolean availability) {
+ this.availability = availability;
+ }
+
+ public static String generateUniqueId(){
+ return UUID.randomUUID().toString();
+ }
+}
diff --git a/40230112109/Library/src/main/java/org/example/Library.java b/40230112109/Library/src/main/java/org/example/Library.java
new file mode 100644
index 0000000..bab01ea
--- /dev/null
+++ b/40230112109/Library/src/main/java/org/example/Library.java
@@ -0,0 +1,159 @@
+package org.example;
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class Library {
+ // Attributes
+ private String libraryName;
+ private int capacity;
+ private String operatingHours;
+ // String = bookId
+ private Map booksMap;
+ private List users;
+ private List rentals;
+
+ //***** Constructor *****//
+ Library(String libraryName, int capacity, String operatingHours) {
+ this.libraryName = libraryName;
+ this.capacity = capacity;
+ this.operatingHours = operatingHours;
+ this.booksMap = new HashMap<>();
+ this.users = new ArrayList<>();
+ this.rentals = new ArrayList<>();
+ }
+
+ //***** Getters & Setters *****//
+ public String getLibraryName() {
+ return libraryName;
+ }
+
+ public void setLibraryName(String libraryName) {
+ this.libraryName = libraryName;
+ }
+
+ public int getCapacity() {
+ return capacity;
+ }
+
+ public void setCapacity(int capacity) {
+ this.capacity = capacity;
+ }
+
+ public String getOperatingHours() {
+ return operatingHours;
+ }
+
+ public void setOperatingHours(String operatingHours) {
+ this.operatingHours = operatingHours;
+ }
+
+ public Map getBooksMap() {
+ return booksMap;
+ }
+
+ public void setBooksMap(Map booksMap) {
+ this.booksMap = booksMap;
+ }
+
+ public List getUsers() {
+ return users;
+ }
+
+ public void setUsers(List users) {
+ this.users = users;
+ }
+
+ public List getRentals() {
+ return rentals;
+ }
+
+ public void setRentals(List rentals) {
+ this.rentals = rentals;
+ }
+
+ //***** Methods *****//
+ public void addBook(Book book) {
+ // Ensure book ID is unique
+ String bookId = Book.generateUniqueId();
+ book.setBookID(bookId);
+ booksMap.put(bookId, book);
+ // Check library capacity
+ if (users.size() >= capacity) {
+ System.out.println("Library is full.");
+ return;
+ }
+ booksMap.put(bookId, book);
+ }
+
+ // To find book.
+ public Book findBookById(String id) {
+ boolean result = false;
+ for (int i = 0; i < this.booksMap.size(); i++) {
+ if (this.booksMap.get(i).equals(id)) {
+ result = true;
+ }
+ }
+ if (!result) {
+ System.out.println("This book is not avalibale!");
+ }
+ return booksMap.get(id);
+ }
+
+ // To add a user by admin.
+ public void addUser(User user) {
+ // Check if the user is an admin trying to add another admin
+ if (user instanceof Admins && users.stream().anyMatch(u -> u instanceof Admins)) {
+ System.out.println("Only one admin can exist.");
+ return;
+ }
+ users.add(user);
+ }
+
+ // To find user.
+ public User findUserById(String id) {
+ return users.stream().filter(u -> u.getUniqueID().equals(id)).findFirst().orElse(null);
+ }
+
+ // To show all book.
+ public List getAvailableBooks() {
+ return booksMap.values().stream().filter(Book::isAvailability).collect(Collectors.toList());
+ }
+
+ public void returnBook(String bookId) {
+ Book book = booksMap.get(bookId);
+ if (book != null) {
+ Optional optionalRental = rentals.stream()
+ .filter(r -> r.getBook().equals(book))
+ .findFirst();
+ if (optionalRental.isPresent()) {
+ Rent rental = optionalRental.get();
+ rental.setReturned(true);
+ book.setAvailability(true);
+ }
+ }
+ }
+
+ private String generateUniqueId() {
+ return UUID.randomUUID().toString();
+ }
+
+ public User findUserByNameOrId(String nameOrId) {
+ return users.stream()
+ .filter(u -> u.getUniqueID().equals(nameOrId) || u.getUserName().equalsIgnoreCase(nameOrId))
+ .findFirst()
+ .orElse(null);
+ }
+
+ public void rentBook(String bookId, User user) {
+ Book book = booksMap.get(bookId);
+ if (book != null && book.isAvailability()) {
+ // Assuming there's a way to mark a book as unavailable
+ book.setAvailability(false);
+ // Create a new rental record
+ rentals.add(new Rent(book, (NormalUsers) user, new Date()));
+ System.out.println("Book rented successfully.");
+ } else {
+ System.out.println("The book is not available or not found.");
+ }
+ }
+}
diff --git a/40230112109/Library/src/main/java/org/example/LibraryCLI.java b/40230112109/Library/src/main/java/org/example/LibraryCLI.java
new file mode 100644
index 0000000..f624136
--- /dev/null
+++ b/40230112109/Library/src/main/java/org/example/LibraryCLI.java
@@ -0,0 +1,113 @@
+package org.example;
+
+import java.util.List;
+import java.util.Scanner;
+public class LibraryCLI {
+ private Library library;
+
+ public LibraryCLI(Library library) {
+ this.library = library;
+ }
+
+ public void run() {
+ Scanner scanner = new Scanner(System.in);
+ while (true) {
+ System.out.print("\nEnter command:(Write \"help\" to see all commands.) ");
+ String command = scanner.nextLine();
+ String[] parts = command.split(" ");
+
+ if (parts.length == 0) {
+ continue; // Skip empty lines
+ }
+
+ String action = parts[0].toLowerCase();
+
+ if ("help".equalsIgnoreCase(action)) {
+ printHelpCommands();
+ continue;
+ }
+
+ if ("add book".equalsIgnoreCase(action)) {
+ if (parts.length != 4) {
+ System.out.println("Usage: lib add book []");
+ continue;
+ }
+ String title = parts[1];
+ String author = parts[2];
+ String description = parts.length > 3 ? parts[3] : "";
+ library.addBook(new Book(title, author, description));
+ } else if ("get hrs".equalsIgnoreCase(action)) {
+ System.out.println("Library operating hours are 9 AM - 5 PM.");
+ } else if ("rent".equalsIgnoreCase(action)) {
+ if (parts.length != 2) {
+ System.out.println("Usage: lib rent ");
+ continue;
+ }
+ String bookTitle = parts[1];
+ Book book = library.findBookById(bookTitle);
+ if (book != null && book.isAvailability()) {
+ // Assuming there's a way to find the user by name or ID
+ User user = library.findUserByNameOrId(parts[2]); // Placeholder method
+ if (user != null) {
+ library.rentBook(String.valueOf(book), user);
+ } else {
+ System.out.println("User not found.");
+ }
+ } else {
+ System.out.println("Book not available or not found.");
+ }
+ } else if ("add member".equalsIgnoreCase(action)) {
+ if (parts.length != 3) {
+ System.out.println("Usage: lib add member ");
+ continue;
+ }
+ String id = parts[1];
+ String password = parts[2];
+ library.addUser(new Admins("Admin", id, "", password)); // Simplified for demonstration
+ } else if ("rent for member".equalsIgnoreCase(action)) {
+ if (parts.length != 4) {
+ System.out.println("Usage: lib rent ");
+ continue;
+ }
+ String bookTitle = parts[1];
+ String memberName = parts[2];
+ String memberID = parts[3];
+ // Similar to "rent" but finds the member by name or ID
+ } else if ("get available books".equalsIgnoreCase(action)) {
+ List availableBooks = library.getAvailableBooks();
+ System.out.println("Available books:");
+ for (Book book : availableBooks) {
+ System.out.println(book.getTitle());
+ }
+ } else if ("remove member".equalsIgnoreCase(action)) {
+ if (parts.length != 2) {
+ System.out.println("Usage: lib remove member ");
+ continue;
+ }
+ String id = parts[1];
+ // Find and remove the member
+ } else if ("return".equalsIgnoreCase(action)) {
+ if (parts.length != 2) {
+ System.out.println("Usage: lib return ");
+ continue;
+ }
+ String bookTitle = parts[1];
+ library.returnBook(bookTitle);
+ } else {
+ System.out.println("Unknown command.");
+ }
+ }
+ }
+ private void printHelpCommands() {
+ System.out.println("\nAvailable Commands:");
+ System.out.println("1. Add a book: lib add book []");
+ System.out.println("2. Get library hours: lib get hrs");
+ System.out.println("3. Rent a book: lib rent ");
+ System.out.println("4. Add a member: lib add member ");
+ System.out.println("5. Rent a book for a member: lib rent ");
+ System.out.println("6. Get available books: lib get available books");
+ System.out.println("7. Remove a member: lib remove member ");
+ System.out.println("8. Return a book: lib return ");
+ System.out.println("Type 'help' anytime for this list of commands.");
+ }
+}
\ No newline at end of file
diff --git a/40230112109/Library/src/main/java/org/example/MyApp.java b/40230112109/Library/src/main/java/org/example/MyApp.java
new file mode 100644
index 0000000..72928d3
--- /dev/null
+++ b/40230112109/Library/src/main/java/org/example/MyApp.java
@@ -0,0 +1,14 @@
+package org.example;
+
+public class MyApp {
+ public static void main(String[] args) {
+ System.out.print("Hi! Welcome to Arva's library♥");
+ Library library = new Library("Example Library", 100, "9 AM - 5 PM");
+
+ // Create an instance of LibraryCLI
+ LibraryCLI cli = new LibraryCLI(library);
+
+ // Start the interactive session
+ cli.run();
+ }
+}
\ No newline at end of file
diff --git a/40230112109/Library/src/main/java/org/example/NormalUsers.java b/40230112109/Library/src/main/java/org/example/NormalUsers.java
new file mode 100644
index 0000000..447f9e6
--- /dev/null
+++ b/40230112109/Library/src/main/java/org/example/NormalUsers.java
@@ -0,0 +1,26 @@
+package org.example;
+
+import javax.xml.crypto.Data;
+import java.util.Date;
+
+public class NormalUsers extends User{
+ // Attributes
+ private Date registrationDate;
+ // Getters & Setters
+ public Date getRegistrationDate() {
+ return registrationDate;
+ }
+ public void setRegistrationDate(Date registrationDate) {
+ this.registrationDate = registrationDate;
+ }
+ // Constructor
+ NormalUsers(String name, String uniqueID, String phoneNumber, Date registrationDate) {
+ super(name, uniqueID, phoneNumber);
+ this.registrationDate = registrationDate;
+ }
+
+ @Override
+ public void register(Date registrationDate) {
+ this.registrationDate = registrationDate;
+ }
+}
diff --git a/40230112109/Library/src/main/java/org/example/Rent.java b/40230112109/Library/src/main/java/org/example/Rent.java
new file mode 100644
index 0000000..2d679a4
--- /dev/null
+++ b/40230112109/Library/src/main/java/org/example/Rent.java
@@ -0,0 +1,54 @@
+package org.example;
+
+import javax.xml.crypto.Data;
+import java.util.Date;
+
+public class Rent {
+ // Attributes
+ private Book book;
+ private NormalUsers normalUser;
+ private boolean returned;
+ private Date rentalDate;
+ // Getters & Setters
+
+ public Book getBook() {
+ return book;
+ }
+
+ public void setBook(Book book) {
+ this.book = book;
+ }
+
+ public NormalUsers getNormalUser() {
+ return normalUser;
+ }
+
+ public void setNormalUser(NormalUsers normalUser) {
+ this.normalUser = normalUser;
+ }
+
+ public boolean isReturned() {
+ return returned;
+ }
+
+ public void setReturned(boolean returned) {
+ this.returned = returned;
+ }
+ //***** Methods *****//
+ public Date getRentalDate() {
+ return rentalDate;
+ }
+
+ public void setRentalDate(Date rentalDate) {
+ this.rentalDate = rentalDate;
+ }
+
+ // Constructor
+
+ public Rent(Book book, NormalUsers normalUser, Date rentalDate) {
+ this.book = book;
+ this.normalUser = normalUser;
+ this.returned = false;
+ this.rentalDate = rentalDate;
+ }
+}
diff --git a/40230112109/Library/src/main/java/org/example/User.java b/40230112109/Library/src/main/java/org/example/User.java
new file mode 100644
index 0000000..f91fbea
--- /dev/null
+++ b/40230112109/Library/src/main/java/org/example/User.java
@@ -0,0 +1,41 @@
+package org.example;
+
+import java.util.Date;
+
+public abstract class User {
+ protected String userName;
+ protected String uniqueID;
+ protected String phoneNumber;
+ //***** Constructor *****//
+ User(String name, String uniqueID, String phoneNumber){
+ this.userName = name;
+ this.uniqueID = uniqueID;
+ this.phoneNumber = phoneNumber;
+ }
+ //***** Getters & Setters *****//
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getUniqueID() {
+ return uniqueID;
+ }
+
+ public void setUniqueID(String uniqueID) {
+ this.uniqueID = uniqueID;
+ }
+
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+
+ public void setPhoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+ //***** Methods *****//
+ public abstract void register(Date registrationDate);
+}