diff --git a/Answers/40130212091/.idea/.gitignore b/Answers/40130212091/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/Answers/40130212091/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/Answers/40130212091/.idea/40130212091.iml b/Answers/40130212091/.idea/40130212091.iml
new file mode 100644
index 0000000..b107a2d
--- /dev/null
+++ b/Answers/40130212091/.idea/40130212091.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40130212091/.idea/misc.xml b/Answers/40130212091/.idea/misc.xml
new file mode 100644
index 0000000..6f29fee
--- /dev/null
+++ b/Answers/40130212091/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40130212091/.idea/modules.xml b/Answers/40130212091/.idea/modules.xml
new file mode 100644
index 0000000..1c6f695
--- /dev/null
+++ b/Answers/40130212091/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40130212091/.idea/vcs.xml b/Answers/40130212091/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/Answers/40130212091/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40130212091/Admin.java b/Answers/40130212091/Admin.java
new file mode 100644
index 0000000..cb5a1e1
--- /dev/null
+++ b/Answers/40130212091/Admin.java
@@ -0,0 +1,15 @@
+
+public class Admin extends User {
+
+ private String password, Id;
+ public Admin(String name ,String phoneNumber, String password){
+ super(name, phoneNumber);
+ this.password = password;
+ }
+
+ public String getPassword(){
+ return password;
+ }
+
+
+}
diff --git a/Answers/40130212091/Book.java b/Answers/40130212091/Book.java
new file mode 100644
index 0000000..fbc11fe
--- /dev/null
+++ b/Answers/40130212091/Book.java
@@ -0,0 +1,40 @@
+
+public class Book extends Library {
+ private int bookID;
+ private String title, author;
+ private boolean availabilityStatus;
+ private String description;
+
+ private int i = 100;
+
+ public Book(String name, String author, String subtitle){
+ this.title = name;
+ this.author = author;
+ this.description = subtitle;
+ this.availabilityStatus = true;
+ this.bookID = ++i;
+
+ }
+
+ public String getTitle(){
+ return title;
+ }
+
+ public String getAuthor(){
+ return author;
+ }
+
+ public boolean getAvailabilityStatus(){
+ return availabilityStatus;
+ }
+
+ public void setAvailabilityStatus(boolean c){
+ availabilityStatus = c;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+
+}
diff --git a/Answers/40130212091/Library.java b/Answers/40130212091/Library.java
new file mode 100644
index 0000000..9ebe67b
--- /dev/null
+++ b/Answers/40130212091/Library.java
@@ -0,0 +1,98 @@
+import java.util.ArrayList;
+
+public class Library{
+ private String libraryName = "myLibrary";
+ private int capacity = 350 ;
+
+ private String operatingHours = "8:00 _ 21:00";
+
+
+ private ArrayList bookList = new ArrayList<>();
+ private ArrayList userList = new ArrayList<>();
+ private ArrayList rentList = new ArrayList<>();
+
+
+ public String getHours() {
+ return operatingHours;
+ }
+ public String getLibraryName(){
+ return libraryName;
+ }
+
+ public int getCapacity(){
+ return capacity;
+ }
+
+ public void addBook(String name, String author, String subtitle){
+ Book book = new Book(name, author, subtitle);
+ bookList.add(book);
+ }
+
+ public void addMember(String name, String phoneNumber){
+ NormalUser normalUser = new NormalUser( name, phoneNumber);
+ userList.add(normalUser);
+ }
+
+ public void rentBook(String bookName, String userName){
+ for (int i = 0; i < userList.size(); i++){
+ if (userList.get(i).getName() == userName){
+ for (int j = 0; j < bookList.size(); j++){
+ if (bookList.get(j).getTitle() == bookName){
+ if (bookList.get(j).getAvailabilityStatus()){
+ Rent rent = new Rent(userList.get(i), bookList.get(j));
+ rentList.add(rent);
+ System.out.println("successful");
+ return;
+ }
+ else {
+ System.out.println("Book Is Unavailable");
+ return;
+ }
+ }
+ }
+ System.out.println("book not found");
+ return;
+ }
+ }
+ System.out.println("user not found");
+ }
+
+ public void removeMember(String memberId){
+ for (int i = 0; i < userList.size(); i++){
+ if (userList.get(i).getId() == memberId){
+ userList.remove(i);
+ System.out.println("successful");
+ return;
+ }
+ }
+ System.out.println("member not found");
+ }
+
+ public void returnBook(String bookName){
+ for (int i = 0; i < bookList.size(); i++){
+ if(bookList.get(i).getTitle() == bookName){
+ bookList.get(i).setAvailabilityStatus(true);
+ for (int j = 0; j < rentList.size(); j++){
+ if (rentList.get(j).getBookObject().getTitle() == bookName){
+ rentList.remove(j);
+ System.out.println("successful");
+ return;
+ }
+ }
+ System.out.println("book not found");
+ }
+ }
+ System.out.println("book not found");
+ }
+
+
+ public void availableBooks(){
+ for (int i = 0; i < bookList.size(); i++){
+ if(bookList.get(i).getAvailabilityStatus()){
+ System.out.println(bookList.get(i).getTitle() + "\n");
+ }
+ }
+ }
+
+
+}
diff --git a/Answers/40130212091/MyApp.java b/Answers/40130212091/MyApp.java
new file mode 100644
index 0000000..77c7509
--- /dev/null
+++ b/Answers/40130212091/MyApp.java
@@ -0,0 +1,64 @@
+
+import java.util.Scanner;
+
+public class MyApp {
+
+ public static void main(String[] args) {
+ Library library = new Library();
+ System.out.println("Hello welcome to " + library.getLibraryName());
+ System.out.println("capacity : " + library.getCapacity());
+ System.out.println("enter a command");
+
+ Scanner command = new Scanner(System.in);
+ String input;
+ while (true) {
+ System.out.println("~~~ ");
+ input = command.nextLine();
+ if (input.equalsIgnoreCase("exit")) {
+ break;
+ }
+ commandLine(input.split(" "), library);
+ }
+ command.close();
+ }
+
+ public static void commandLine(String[] order, Library library) {
+ try {
+ if (order[1].equals("lib") && order[2].equals("add") && order[3].equals("book")) {
+ library.addBook(order[4], order[5], order[6]);
+ } else if (order[1].equals("lib") && order[2].equals("add") && order[3].equals("member")) {
+ library.addMember(order[4], order[5]);
+ } else if (order[1].equals("lib") && order[2].equals("rent")) {
+ library.rentBook(order[4], order[5]);
+ } else if (order[1].equals("lib") && order[2].equals("get") && order[3].equals("hrs")) {
+ System.out.println(library.getHours());
+ } else if (order[1].equals("lib") && order[2].equals("get") && order[3].equals("books")) {
+ library.availableBooks();
+ } else if (order[1].equals("lib") && order[2].equals("remove") && order[3].equals("member")) {
+ library.removeMember(order[4]);
+
+ } else if (order[1].equals("lib") && order[2].equals("return")) {
+ library.returnBook(order[4]);
+ } else if (order[1].equals("lib") && order[2].equals("help")) {
+ System.out.println("lib add book : Add a new book to the library.\n" +
+ "lib get hrs: Retrieve library operating hours.\n" +
+ "lib rent : Rent a book from the library.\n" +
+ "lib add member : Add a new member to the library (admin privilege required).\n" +
+ "lib rent : Rent a book for a specific member.\n" +
+ "lib get available books: View available books for rental.\n" +
+ "lib remove member : Remove a member from the library (admin privilege required).\n" +
+ "lib return : Return a rented book to the library.\n" +
+ "lib add admin : Add a new admin to the library\n" +
+ ">>> ");
+ }
+ else{
+ throw new Exception();
+ }
+ } catch(
+ Exception e)
+
+ {
+ throw new RuntimeException("enter a correct command");
+ }
+}
+}
diff --git a/Answers/40130212091/NormalUser.java b/Answers/40130212091/NormalUser.java
new file mode 100644
index 0000000..ebd1bd8
--- /dev/null
+++ b/Answers/40130212091/NormalUser.java
@@ -0,0 +1,15 @@
+public class NormalUser extends User {
+
+ private int Id;
+ private int j = 100;
+
+ public NormalUser(String name, String phoneNumber){
+ super(name, phoneNumber);
+ this.Id = ++j;
+ }
+
+ public String getId(){
+ return toString(Id);
+ }
+
+}
diff --git a/Answers/40130212091/Rent.java b/Answers/40130212091/Rent.java
new file mode 100644
index 0000000..a8f945c
--- /dev/null
+++ b/Answers/40130212091/Rent.java
@@ -0,0 +1,29 @@
+import java.util.Date;
+import java.util.HashMap;
+
+public class Rent extends Library {
+ private NormalUser normalUserObject;
+ private Book bookObject;
+ private long rentalDate;
+ private int RentalID;
+ Date date = new Date();
+
+ HashMap rent = new HashMap<>();
+ private int c = 1;
+
+ public Rent(NormalUser normalUser, Book book){
+ this.normalUserObject = normalUser;
+ this.bookObject = book;
+ this.rentalDate = date.getTime();
+ RentalID = ++c;
+ }
+
+ public User getnormalUserObject(){
+ return normalUserObject;
+ }
+
+ public Book getBookObject(){
+ return bookObject;
+ }
+
+}
diff --git a/Answers/40130212091/User.java b/Answers/40130212091/User.java
new file mode 100644
index 0000000..1af65a0
--- /dev/null
+++ b/Answers/40130212091/User.java
@@ -0,0 +1,34 @@
+
+public class User extends Library{
+ private String name;
+ private String phoneNumber;
+
+ private int Id;
+
+
+ public User(String name, String phoneNumber){
+ this.name = name;
+ this.phoneNumber = phoneNumber;
+ }
+
+ public String getName(){
+ return name;
+ }
+
+ public String getPhoneNumber(){
+ return phoneNumber;
+ }
+
+ public String getId(){
+ String IdStr = toString(Id);
+ return IdStr;
+ }
+
+ String toString(int id) {
+ return toString(id);
+ }
+
+ public User() {
+
+ }
+}
diff --git a/Answers/40130212091/out/production/40130212091/.idea/.gitignore b/Answers/40130212091/out/production/40130212091/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/Answers/40130212091/out/production/40130212091/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/Answers/40130212091/out/production/40130212091/.idea/40130212091.iml b/Answers/40130212091/out/production/40130212091/.idea/40130212091.iml
new file mode 100644
index 0000000..b107a2d
--- /dev/null
+++ b/Answers/40130212091/out/production/40130212091/.idea/40130212091.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40130212091/out/production/40130212091/.idea/misc.xml b/Answers/40130212091/out/production/40130212091/.idea/misc.xml
new file mode 100644
index 0000000..6f29fee
--- /dev/null
+++ b/Answers/40130212091/out/production/40130212091/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40130212091/out/production/40130212091/.idea/modules.xml b/Answers/40130212091/out/production/40130212091/.idea/modules.xml
new file mode 100644
index 0000000..1c6f695
--- /dev/null
+++ b/Answers/40130212091/out/production/40130212091/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40130212091/out/production/40130212091/.idea/vcs.xml b/Answers/40130212091/out/production/40130212091/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/Answers/40130212091/out/production/40130212091/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40130212091/out/production/40130212091/Admin.class b/Answers/40130212091/out/production/40130212091/Admin.class
new file mode 100644
index 0000000..22e01ae
Binary files /dev/null and b/Answers/40130212091/out/production/40130212091/Admin.class differ
diff --git a/Answers/40130212091/out/production/40130212091/Book.class b/Answers/40130212091/out/production/40130212091/Book.class
new file mode 100644
index 0000000..465bd19
Binary files /dev/null and b/Answers/40130212091/out/production/40130212091/Book.class differ
diff --git a/Answers/40130212091/out/production/40130212091/Library.class b/Answers/40130212091/out/production/40130212091/Library.class
new file mode 100644
index 0000000..50051a7
Binary files /dev/null and b/Answers/40130212091/out/production/40130212091/Library.class differ
diff --git a/Answers/40130212091/out/production/40130212091/MyApp.class b/Answers/40130212091/out/production/40130212091/MyApp.class
new file mode 100644
index 0000000..a5ac040
Binary files /dev/null and b/Answers/40130212091/out/production/40130212091/MyApp.class differ
diff --git a/Answers/40130212091/out/production/40130212091/NormalUser.class b/Answers/40130212091/out/production/40130212091/NormalUser.class
new file mode 100644
index 0000000..d877988
Binary files /dev/null and b/Answers/40130212091/out/production/40130212091/NormalUser.class differ
diff --git a/Answers/40130212091/out/production/40130212091/Rent.class b/Answers/40130212091/out/production/40130212091/Rent.class
new file mode 100644
index 0000000..ba206f5
Binary files /dev/null and b/Answers/40130212091/out/production/40130212091/Rent.class differ
diff --git a/Answers/40130212091/out/production/40130212091/User.class b/Answers/40130212091/out/production/40130212091/User.class
new file mode 100644
index 0000000..154cbf2
Binary files /dev/null and b/Answers/40130212091/out/production/40130212091/User.class differ