diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/Library-Management-System.iml b/.idea/Library-Management-System.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/Library-Management-System.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..6f29fee
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..2e1b46d
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/untitled7/.gitignore b/Answers/untitled7/.gitignore
new file mode 100644
index 0000000..f68d109
--- /dev/null
+++ b/Answers/untitled7/.gitignore
@@ -0,0 +1,29 @@
+### IntelliJ IDEA ###
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/Answers/untitled7/.idea/.gitignore b/Answers/untitled7/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/Answers/untitled7/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/Answers/untitled7/.idea/misc.xml b/Answers/untitled7/.idea/misc.xml
new file mode 100644
index 0000000..6f29fee
--- /dev/null
+++ b/Answers/untitled7/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/untitled7/.idea/modules.xml b/Answers/untitled7/.idea/modules.xml
new file mode 100644
index 0000000..2659b24
--- /dev/null
+++ b/Answers/untitled7/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/untitled7/.idea/uiDesigner.xml b/Answers/untitled7/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/Answers/untitled7/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/untitled7/src/Admin.java b/Answers/untitled7/src/Admin.java
new file mode 100644
index 0000000..3f16451
--- /dev/null
+++ b/Answers/untitled7/src/Admin.java
@@ -0,0 +1,23 @@
+import java.util.ArrayList;
+import java.util.Scanner;
+
+public class Admin extends User{
+ private String Password;
+ public Admin(String Name, String UserID, String PhoneNumber, String Password){
+ super(Name, UserID, PhoneNumber);
+ this.Password=Password;
+ }
+ public static ArrayList Admins = new ArrayList<>();
+
+
+ public String getPassword() {
+ return Password;
+ }
+
+ public void AdminSignUp(){
+ Scanner input= new Scanner(System.in);
+ super.Name=input.nextLine();
+ super.UserID=input.nextLine();
+ super.PhoneNumber=input.nextLine();
+ }
+}
diff --git a/Answers/untitled7/src/Book.java b/Answers/untitled7/src/Book.java
new file mode 100644
index 0000000..5042e8e
--- /dev/null
+++ b/Answers/untitled7/src/Book.java
@@ -0,0 +1,36 @@
+import jdk.jfr.Description;
+
+public class Book {
+ private int BookID;
+ private String Title, Author, Description;
+ private boolean AvailibilityStatus;
+ public Book(String Title, String Author,String Description){
+ BookID=1;
+ this.Title=Title;
+ this.Author=Author;
+ this.Description=Description;
+ this.AvailibilityStatus=true;
+ }
+
+ public int getBookID() {
+ return BookID;
+ }
+
+ public String getAuthor() {
+ return Author;
+ }
+
+ public String getDescription() {
+ return Description;
+ }
+
+ public String getTitle() {
+ return Title;
+ }
+ public void setAvailibilityStatus(){
+ this.AvailibilityStatus=(!AvailibilityStatus);
+ }
+ public boolean getAvailibilityStatus(){
+ return AvailibilityStatus;
+ }
+}
diff --git a/Answers/untitled7/src/CLI.java b/Answers/untitled7/src/CLI.java
new file mode 100644
index 0000000..13e5c11
--- /dev/null
+++ b/Answers/untitled7/src/CLI.java
@@ -0,0 +1,139 @@
+import java.util.Scanner;
+
+public class CLI {
+ private Library library;
+ private NormalUser currentUser;
+ private Admin currentAdmin;
+
+ public CLI(Library library) {
+ this.library = library;
+ this.currentUser = null;
+ this.currentAdmin=null;
+ }
+ private Admin findAdmin(String Name,String UserID,String Password) {
+ for (Admin user : library.getAllAdmins()) {
+ if (user.getUserID().equals(UserID) && user.getName().equals(Name) && user.getPassword().equals(Password)) {
+ currentAdmin=user;
+ }
+ }
+ return currentAdmin;
+ }
+ private NormalUser findNormalUser(String Name,String UserID) {
+ for (NormalUser user : library.getAllNormalUsers()) {
+ if (user.getUserID().equals(UserID) && user.getName().equals(Name)) {
+ currentUser=user;
+ }
+ }
+ return currentUser;
+ }
+ public void start(){
+
+ while(currentAdmin==null && currentUser==null) {
+ System.out.println("1.Sign in");
+ System.out.println("2.Sign up");
+ Scanner scanner = new Scanner(System.in);
+ int input = scanner.nextInt();
+ if (input == 1) {
+ System.out.println("1.Sign in as Admin");
+ System.out.println("2.Sign in as Normal User");
+ int input1 = scanner.nextInt();
+ if (input1 == 1) {
+ System.out.println("insert name:");
+ String name = scanner.next();
+ System.out.println("insert id:");
+ String userid = scanner.next();
+ System.out.println("insert password:");
+ String pass = scanner.next();
+ currentAdmin = findAdmin(name, userid, pass);
+ if (currentAdmin == null) {
+ System.out.println("User not found");
+ } else {
+ System.out.println("Login Successfully");
+ }
+ }
+ if (input1 == 2) {
+ System.out.println("insert name:");
+ String name = scanner.next();
+ System.out.println("insert id:");
+ String userid = scanner.next();
+ currentUser = findNormalUser(name, userid);
+ if (currentUser == null) {
+ System.out.println("User not found");
+ } else {
+ System.out.println("Login Successfully");
+ }
+ }
+
+ }
+ if (input == 2) {
+ System.out.println("1.Sign up as Admin");
+ System.out.println("2.Sign up as Normal User");
+ int input1 = scanner.nextInt();
+ if (input1 == 1) {
+ System.out.println("insert name:");
+ String name = scanner.next();
+ System.out.println("insert id:");
+ String userid = scanner.next();
+ System.out.println("insert password:");
+ String pass = scanner.next();
+ System.out.println("insert phonenumber:");
+ String phonenumber = scanner.next();
+ library.addNewAdmin(new Admin(name, userid, phonenumber, pass));
+ System.out.println("Sign up Successfully");
+
+ }
+ if (input1 == 2) {
+ System.out.println("insert name:");
+ String name = scanner.next();
+ System.out.println("insert id:");
+ String userid = scanner.next();
+ System.out.println("insert phonenumber:");
+ String phonenumber = scanner.next();
+ library.addNewNormalUser(new NormalUser(name, userid, phonenumber));
+ System.out.println("Sign up Successfully");
+ }
+ }
+ }
+ if (currentAdmin!=null){
+ System.out.println("1.Add a new book to the library");
+ System.out.println("2.Add a new book to the library");
+ System.out.println("3.Rent a book from the library");
+ System.out.println("4.Add a new member to the library");
+ System.out.println("5.Rent a book for a specific member");
+ System.out.println("6.View available books for rental");
+ System.out.println("7.Remove a member from the library");
+ System.out.println("8.Return a rented book to the library");
+
+ }
+ if (currentUser!=null){
+ System.out.println("1.Add a new book to the library");
+ System.out.println("2.Add a new book to the library");
+ System.out.println("3.Rent a book from the library");
+ System.out.println("4.Rent a book for a specific member");
+ System.out.println("5.View available books for rental");
+ System.out.println("6.Return a rented book to the library");
+ Scanner scanner = new Scanner(System.in);
+ int input = scanner.nextInt();
+ if(input==1){
+ System.out.println("book name:");
+ String name = scanner.next();
+ System.out.println("book author:");
+ String author = scanner.next();
+ System.out.println("book description:");
+ String description = scanner.next();
+ library.addNewBook(new Book(name,author,description));
+ }
+ if(input==2){
+ System.out.println("library operating hours: "+library.getOperatingHours());
+ }
+ if(input==3){
+ System.out.println("book name:");
+ String name = scanner.next();
+ library.newRent(currentUser,);
+ }
+
+ }
+
+
+ }
+}
diff --git a/Answers/untitled7/src/Library.java b/Answers/untitled7/src/Library.java
new file mode 100644
index 0000000..b825388
--- /dev/null
+++ b/Answers/untitled7/src/Library.java
@@ -0,0 +1,84 @@
+import java.time.LocalDate;
+import java.util.ArrayList;
+
+public class Library {
+ private String Name;
+ private int Capacity;
+ private String OperatingHours;
+ private ArrayList BookRepository;
+ private ArrayList AllAdmins;
+ private ArrayList AllNormalUsers;
+
+ private ArrayList RentalRegistry;
+
+ public Library(String Name, int Capacity, String OperatingHours) {
+ this.Name = Name;
+ this.Capacity = Capacity;
+ this.OperatingHours = OperatingHours;
+ this.BookRepository = new ArrayList<>();
+ this.AllAdmins = new ArrayList<>();
+ this.AllNormalUsers=new ArrayList<>();
+ this.RentalRegistry = new ArrayList<>();
+ }
+
+ public String getName() {
+ return Name;
+ }
+
+ public int getCapacity() {
+ return Capacity;
+ }
+
+ public String getOperatingHours() {
+ return OperatingHours;
+ }
+
+ public void addNewBook(Book book) {
+ if(Capacity>BookRepository.size()) {
+ BookRepository.add(book);
+ }
+ }
+
+ public ArrayList getAvailableBooks() {
+ ArrayList AvailableBooks = new ArrayList<>();
+ for (Book book : BookRepository) {
+ if (book.getAvailibilityStatus()) {
+ AvailableBooks.add(book);
+ }
+ }
+ return AvailableBooks;
+ }
+
+
+ public void addNewAdmin(Admin user){
+ AllAdmins.add(user);
+ }
+ public void addNewNormalUser(NormalUser user){
+ AllNormalUsers.add(user);
+ }
+ public void removeNormalUser(NormalUser user){
+ AllNormalUsers.remove(user);
+ }
+ public ArrayList getAllAdmins(){
+ return AllAdmins;
+ }
+ public ArrayList getAllNormalUsers(){
+ return AllNormalUsers;
+ }
+ public void newRent(NormalUser normalUser, Book book){
+ if (book.getAvailibilityStatus()){
+// String rentalDate = LocalDate.now().toString();
+ book.setAvailibilityStatus();
+ Rent rent = new Rent(LocalDate.now().toString(),book,normalUser);
+ RentalRegistry.add(rent);
+ }
+ }
+ public void returnBook(Book book) {
+ for (Rent rent : RentalRegistry) {
+ if (rent.getBook().equals(book)) {
+ RentalRegistry.remove(rent);
+ book.setAvailibilityStatus();
+ }
+ }
+ }
+}
diff --git a/Answers/untitled7/src/MyApp.java b/Answers/untitled7/src/MyApp.java
new file mode 100644
index 0000000..4f6544c
--- /dev/null
+++ b/Answers/untitled7/src/MyApp.java
@@ -0,0 +1,10 @@
+import java.util.Scanner;
+
+public class MyApp {
+ public static void main(String[] args) {
+
+ Library library=new Library("a",12,"8-18");
+ CLI cli=new CLI(library);
+ cli.start();
+ }
+}
\ No newline at end of file
diff --git a/Answers/untitled7/src/NormalUser.java b/Answers/untitled7/src/NormalUser.java
new file mode 100644
index 0000000..ed4ede0
--- /dev/null
+++ b/Answers/untitled7/src/NormalUser.java
@@ -0,0 +1,19 @@
+import java.util.ArrayList;
+
+public class NormalUser extends User{
+ private String RegistrationDate;
+ public NormalUser(String Name, String UserID, String PhoneNumber){
+ super(Name, UserID, PhoneNumber);
+ this.RegistrationDate=RegistrationDate;
+ }
+
+ public String getRegistrationDate() {
+ return RegistrationDate;
+ }
+
+ public static ArrayList NormalUsers = new ArrayList<>();
+
+ public static void NormalUserSignUp(NormalUser a){
+ NormalUsers.add(a);
+ }
+}
diff --git a/Answers/untitled7/src/Rent.java b/Answers/untitled7/src/Rent.java
new file mode 100644
index 0000000..27ea66e
--- /dev/null
+++ b/Answers/untitled7/src/Rent.java
@@ -0,0 +1,28 @@
+public class Rent {
+ private int RentalID=1;
+ private String RentalDate;
+ private Book book;
+ private NormalUser normalUser;
+ public Rent (String RentalDate,Book book, NormalUser normalUser){
+ this.RentalID=RentalID+1;
+ this.RentalDate=RentalDate;
+ this.book=book;
+ this.normalUser=normalUser;
+ }
+
+ public int getRentalID() {
+ return RentalID;
+ }
+
+ public Book getBook() {
+ return book;
+ }
+
+ public String getRentalDate() {
+ return RentalDate;
+ }
+
+ public NormalUser getNormalUser() {
+ return normalUser;
+ }
+}
diff --git a/Answers/untitled7/src/User.java b/Answers/untitled7/src/User.java
new file mode 100644
index 0000000..cf2f57c
--- /dev/null
+++ b/Answers/untitled7/src/User.java
@@ -0,0 +1,44 @@
+import java.time.LocalDate;
+import java.util.Scanner;
+
+public class User {
+ protected String Name, UserID, PhoneNumber;
+ private String RegistrationDate;
+ private String Password;
+ public User(String Name, String UserID, String PhoneNumber){
+ this.PhoneNumber=PhoneNumber;
+ this.UserID=UserID;
+ this.Name=Name;
+ this.RegistrationDate= LocalDate.now().toString();
+ }
+ public User(String Name, String UserID,String Password, String PhoneNumber){
+ this.PhoneNumber=PhoneNumber;
+ this.UserID=UserID;
+ this.Name=Name;
+ this.Password=Password;
+ }
+
+ public String getName() {
+ return Name;
+ }
+
+ public String getPhoneNumber() {
+ return PhoneNumber;
+ }
+
+ public String getUserID() {
+ return UserID;
+ }
+
+ public String getPassword() {
+ return Password;
+ }
+
+ @Override
+ public String toString() {
+ return "Objname{" + "property1=" + Name+
+ UserID+
+ PhoneNumber;
+
+ }
+}
diff --git a/Answers/untitled7/untitled7.iml b/Answers/untitled7/untitled7.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/Answers/untitled7/untitled7.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file