From ca7890db8166dc1e18a6d1570c12e0d54f1a0b5f Mon Sep 17 00:00:00 2001
From: aran7227 <161644211+aran7227@users.noreply.github.com>
Date: Sun, 12 May 2024 13:52:14 +0330
Subject: [PATCH 1/3] project Ddone...
---
.idea/misc.xml | 6 ++++
.idea/modules.xml | 8 +++++
.idea/vcs.xml | 7 +++++
.idea/workspace.xml | 58 +++++++++++++++++++++++++++++++++++
Library-Management-System.iml | 11 +++++++
5 files changed, 90 insertions(+)
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 .idea/workspace.xml
create mode 100644 Library-Management-System.iml
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..639900d
--- /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..d5f086e
--- /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..d7f209d
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..e1021c9
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1715508570372
+
+
+ 1715508570372
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Library-Management-System.iml b/Library-Management-System.iml
new file mode 100644
index 0000000..27891c9
--- /dev/null
+++ b/Library-Management-System.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 3358f85a84e181d2de6597e92084e8be69492200 Mon Sep 17 00:00:00 2001
From: aran7227 <161644211+aran7227@users.noreply.github.com>
Date: Tue, 11 Jun 2024 13:44:24 +0330
Subject: [PATCH 2/3] add forgotten files
---
Answers/Admin.java | 10 ++
Answers/Book.java | 18 ++++
Answers/CLI.java | 76 +++++++++++++++
Answers/Library.java | 7 ++
Answers/Myapp.java | 6 ++
Answers/Normaluser.java | 12 +++
Answers/Rent.java | 13 +++
Answers/Run.java | 211 ++++++++++++++++++++++++++++++++++++++++
Answers/User.java | 9 ++
9 files changed, 362 insertions(+)
create mode 100644 Answers/Admin.java
create mode 100644 Answers/Book.java
create mode 100644 Answers/CLI.java
create mode 100644 Answers/Library.java
create mode 100644 Answers/Myapp.java
create mode 100644 Answers/Normaluser.java
create mode 100644 Answers/Rent.java
create mode 100644 Answers/Run.java
create mode 100644 Answers/User.java
diff --git a/Answers/Admin.java b/Answers/Admin.java
new file mode 100644
index 0000000..adb6867
--- /dev/null
+++ b/Answers/Admin.java
@@ -0,0 +1,10 @@
+import java.util.HashMap;
+
+public class Admin extends User {
+ HashMap adminsave=new HashMap<>();
+ public void addAdmin(String adname,String adpass) {
+ uname=adname;
+ userpass=adpass;
+ adminsave.put(adname, adpass);
+ }
+}
diff --git a/Answers/Book.java b/Answers/Book.java
new file mode 100644
index 0000000..d3e0b0a
--- /dev/null
+++ b/Answers/Book.java
@@ -0,0 +1,18 @@
+import java.util.HashMap;
+
+public class Book {
+ int bookid=1;
+ String bookname;
+ String author;
+ String description;
+ boolean dastresi=false;
+ HashMap writerdooni=new HashMap<>();
+ HashMap subdooni=new HashMap<>();
+ public void bmaker(String bookname, String author, String description) {
+ this.bookname = bookname;
+ this.author = author;
+ this.description = description;
+ bookid++;
+ this.dastresi=true;
+ }
+}
\ No newline at end of file
diff --git a/Answers/CLI.java b/Answers/CLI.java
new file mode 100644
index 0000000..a74a753
--- /dev/null
+++ b/Answers/CLI.java
@@ -0,0 +1,76 @@
+public class CLI {
+ Library ketkh=new Library();
+ Rent r=new Rent();
+ Book bok=new Book();
+ Normaluser nu=new Normaluser();
+ Admin addd=new Admin();
+ public void libaddbook(String bname,String writer,String sub) {
+ if (!(ketkh.bookesm.contains(bname) && bok.writerdooni.containsValue(writer) && bok.subdooni.containsValue(sub))) {
+ Book b = new Book();
+ b.bmaker(bname, writer, sub);
+ ketkh.mylib.add(b);
+ ketkh.bookesm.add(b.bookname);
+ bok.writerdooni.put(bname,writer);
+ bok.subdooni.put(bname,sub);
+ } else {
+ System.out.println("this book already exists!");
+ }
+ }
+ public void libgethrs() {
+ System.out.println("az 9:00 sobh ta 11:00 shab.");
+ }
+ public void librent(String bname,String mn1) {
+ r.rentmem.put(mn1, nu.memidsave.get(mn1));
+ if (ketkh.bookesm.contains(bname)) {
+ r.rentsaz(bname);
+ ketkh.bookesm.remove(bname);
+ System.out.println("book is rented!");
+ } else {
+ System.out.println("book not found!");
+ }
+ }
+ public void libaddmember(String sname,String password) {
+ if (nu.mempasssave.containsKey(sname)==false && nu.mempasssave.containsValue(password)==false) {
+ nu.makeaccount(sname, password);
+ System.out.println("member added!");
+ } else {
+ System.out.println("this member already exists!");
+ }
+ }
+ public void librentforamember(String boname,String memn) {
+ if (nu.mempasssave.containsKey(memn)) {
+ librent(boname,memn);
+ } else {
+ System.out.println("user not found!");
+ }
+ }
+ public void libgetavailablebooks() {
+ System.out.println(ketkh.bookesm);
+ }
+ public void libremovemember(String memname) {
+ if (nu.mempasssave.containsKey(memname)) {
+ nu.mempasssave.remove(memname);
+ nu.memidsave.remove(memname);
+ if (addd.adminsave.containsKey(memname)) {
+ addd.adminsave.remove(memname);
+ }
+ if (r.rentmem.containsKey(memname)) {
+ r.rentmem.remove(memname);
+ }
+ System.out.println("member removed.");
+ } else {
+ System.out.println("user not found!");
+ }
+ }
+ public void libreturn(String bookn) {
+ if (r.bookrent.containsKey(bookn)) {
+ r.bookrent.remove(bookn);
+ ketkh.bookesm.add(bookn);
+ System.out.println("book returned.");
+ } else if (ketkh.bookesm.contains(bookn)) {
+ System.out.println("the book hasnt been rented yet!");
+ } else {
+ System.out.println("this book hasnt been in our library!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Answers/Library.java b/Answers/Library.java
new file mode 100644
index 0000000..e6d2d6a
--- /dev/null
+++ b/Answers/Library.java
@@ -0,0 +1,7 @@
+import java.util.ArrayList;
+public class Library {
+ String libname = "nooshirvanilib";
+ ArrayList mylib = new ArrayList<>();
+ ArrayList bookesm=new ArrayList<>();
+ int cap=bookesm.size();
+}
\ No newline at end of file
diff --git a/Answers/Myapp.java b/Answers/Myapp.java
new file mode 100644
index 0000000..9fec89c
--- /dev/null
+++ b/Answers/Myapp.java
@@ -0,0 +1,6 @@
+public class Myapp {
+ public static void main(String[] args) {
+ Run obj=new Run();
+ obj.runner();
+ }
+}
diff --git a/Answers/Normaluser.java b/Answers/Normaluser.java
new file mode 100644
index 0000000..1378be7
--- /dev/null
+++ b/Answers/Normaluser.java
@@ -0,0 +1,12 @@
+import java.time.LocalDate;
+
+public class Normaluser extends User {
+ LocalDate logindate=LocalDate.now();
+ public void makeaccount(String lname,String lpass) {
+ uname = lname;
+ userpass = lpass;
+ memidsave.put(lname,userid);
+ userid++;
+ mempasssave.put(lname,lpass);
+ }
+}
\ No newline at end of file
diff --git a/Answers/Rent.java b/Answers/Rent.java
new file mode 100644
index 0000000..4865e3a
--- /dev/null
+++ b/Answers/Rent.java
@@ -0,0 +1,13 @@
+import java.time.LocalDate;
+import java.util.HashMap;
+
+public class Rent {
+ int rentid=1;
+ LocalDate rentdate = LocalDate.now();
+ HashMap bookrent=new HashMap<>();
+ HashMap rentmem=new HashMap<>();
+ public void rentsaz(String esmb) {
+ bookrent.put(esmb,rentid);
+ rentid++;
+ }
+}
\ No newline at end of file
diff --git a/Answers/Run.java b/Answers/Run.java
new file mode 100644
index 0000000..4eb1b47
--- /dev/null
+++ b/Answers/Run.java
@@ -0,0 +1,211 @@
+import java.time.LocalTime;
+import java.util.Scanner;
+
+public class Run {
+ Book bk=new Book();
+ CLI tab=new CLI();
+ Normaluser u=new Normaluser();
+ Admin ad=new Admin();
+ Library bc=new Library();
+ Rent rt=new Rent();
+ LocalTime t=LocalTime.now();
+ LocalTime t1=LocalTime.of(9,00,00);
+ LocalTime t2=LocalTime.of(23,00,00);
+ public void runner() {
+ Scanner sc=new Scanner(System.in);
+ Scanner sc2=new Scanner(System.in);
+ if (t.isAfter(t1) && t.isBefore(t2)) {
+ u.makeaccount("Aran Rafiaei","40230212043");
+ ad.addAdmin("Aran Rafiaei","40230212043");
+ tab.libaddbook("binavayan","Victor Hogo","ketab dar morede chand binavast.");
+ tab.libaddbook("bishoori","Xavier Crement","ye ketab dar morede bishoori.");
+ tab.libaddbook("nooshirvani kojast","nashenas","addresse nooshivani be zaban haye mokhtalef.");
+ System.out.println("Welcome to Nooshirvani library! choose the number of one of options below.");
+ System.out.println("1.Yes");
+ System.out.println("2.No"+"\n");
+ System.out.print("Are you Admin: ");
+ String name="";
+ for (;;) {
+ String yn=sc.nextLine();
+ boolean l=false;
+ switch (yn) {
+ case "1":
+ System.out.print("enter the password: ");
+ for (;;) {
+ String pass=sc.nextLine();
+ if (ad.adminsave.containsValue(pass)) {
+ name="Aran Rafiaei";
+ break;
+ } else {
+ System.out.print("admin not found!try another password: ");
+ }
+ }
+ l=true;
+ break;
+ case "2":
+ System.out.println("you must make account.first, enter your name below.");
+ System.out.print("my name is: ");
+ for (;;) {
+ name=sc.nextLine();
+ if (u.mempasssave.containsKey(name)==false) {
+ break;
+ } else {
+ System.out.print("your name must be unique.try another: ");
+ }
+ }
+ System.out.print("enter a password: ");
+ String pasw;
+ while (true) {
+ pasw=sc2.nextLine();
+ if (u.mempasssave.containsValue(pasw)) {
+ System.out.print("this password is not unique: ");
+ } else {
+ break;
+ }
+ }
+ u.makeaccount(name,pasw);
+ l=true;
+ System.out.println("now you have an account.");
+ break;
+ default:
+ System.out.print("wrong option.try again: ");
+ break;
+ }
+ if (l==true) {
+ break;
+ }
+ }
+ System.out.println("here they are our options of library.choose the number of one of them.");
+ boolean m=true;
+ for (;;) {
+ if (m) {
+ System.out.println("1.add a book");
+ System.out.println("2.get work hours");
+ System.out.println("3.rent a book");
+ System.out.println("4.add a member (admins only)");
+ System.out.println("5.rent a book for a member");
+ System.out.println("6.see available books");
+ System.out.println("7.remove a member (admins only)");
+ System.out.println("8.return a book");
+ System.out.println("9.exit");
+ System.out.print("I choose: ");
+ }
+ boolean kh=false;
+ String op=sc.nextLine();
+ switch (op) {
+ case "1":
+ m=true;
+ System.out.print("enter book name: ");
+ String bname=sc.nextLine();
+ System.out.print("enter the author: ");
+ String nv=sc.nextLine();
+ System.out.print("what is the book about: ");
+ String caption=sc2.nextLine();
+ tab.libaddbook(bname,nv,caption);
+ if (!(bc.bookesm.contains(bname) && bk.writerdooni.containsValue(nv) && bk.subdooni.containsValue(caption))) {
+ System.out.println("book added.");
+ }
+ break;
+ case "2":
+ m=true;
+ tab.libgethrs();
+ break;
+ case "3":
+ m=true;
+ System.out.print("enter the name of the book: ");
+ String boname=sc.nextLine();
+ tab.librent(boname,name);
+ break;
+ case "4":
+ m=true;
+ System.out.print("enter the admin password: ");
+ String adminpass=sc.nextLine();
+ if (ad.adminsave.containsValue(adminpass)==false) {
+ System.out.println("seems like you are not admin.");
+ break;
+ }
+ System.out.print("enter a name: ");
+ String mname= sc.nextLine();
+ System.out.print("enter a password: ");
+ String mpass=sc2.nextLine();
+ boolean a=false;
+ if (u.mempasssave.containsKey(mname)==false && u.mempasssave.containsValue(mpass)==false) {
+ a=true;
+ }
+ tab.libaddmember(mname,mpass);
+ if (a) {
+ System.out.println("would you like to consider your member as admin?");
+ System.out.print("enter yes\\no: ");
+ for (;;) {
+ String ans = sc2.nextLine();
+ boolean b = false;
+ switch (ans) {
+ case "yes":
+ ad.addAdmin(mname, mpass);
+ System.out.println("admin added!");
+ b = true;
+ break;
+ case "no":
+ b = true;
+ break;
+ default:
+ System.out.print("you must enter \"yes\" or \"no\": ");
+ break;
+ }
+ if (b == true) {
+ break;
+ }
+ }
+ }
+ break;
+ case "5":
+ m=true;
+ System.out.print("enter the name: ");
+ String mename=sc.nextLine();
+ System.out.print("enter the name of the book: ");
+ String bn=sc.nextLine();
+ tab.librentforamember(bn,mename);
+ break;
+ case "6":
+ m=true;
+ tab.libgetavailablebooks();
+ break;
+ case "7":
+ m=true;
+ System.out.print("enter the admin password: ");
+ String pw=sc.nextLine();
+ if (ad.adminsave.containsValue(pw)==false) {
+ System.out.println("seems like you are not admin.");
+ break;
+ }
+ System.out.print("enter the name of member: ");
+ String rm=sc.nextLine();
+ tab.libremovemember(rm);
+ break;
+ case "8":
+ m=true;
+ System.out.print("enter the name of the book: ");
+ String rbn=sc.nextLine();
+ tab.libreturn(rbn);
+ break;
+ case "9":
+ kh=true;
+ break;
+ default:
+ m=false;
+ System.out.print("wrong option.try again: ");
+ break;
+ }
+ if (kh) {
+ System.out.print("see you later.");
+ break;
+ }
+ if (m) {
+ System.out.println("anything else?");
+ }
+ }
+ } else {
+ System.out.println("Sorry,we are closed!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Answers/User.java b/Answers/User.java
new file mode 100644
index 0000000..6fa86a4
--- /dev/null
+++ b/Answers/User.java
@@ -0,0 +1,9 @@
+import java.util.HashMap;
+
+public class User {
+ String uname;
+ int userid=10;
+ String userpass;
+ HashMap mempasssave=new HashMap<>();
+ HashMap memidsave=new HashMap<>();
+}
From b3309c515e6ff1305666a2649038fd4676e4e745 Mon Sep 17 00:00:00 2001
From: aran7227 <161644211+aran7227@users.noreply.github.com>
Date: Fri, 5 Jul 2024 19:24:52 +0330
Subject: [PATCH 3/3] Update objects in Run.java
---
Answers/Run.java | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/Answers/Run.java b/Answers/Run.java
index 4eb1b47..b33d65b 100644
--- a/Answers/Run.java
+++ b/Answers/Run.java
@@ -2,12 +2,7 @@
import java.util.Scanner;
public class Run {
- Book bk=new Book();
CLI tab=new CLI();
- Normaluser u=new Normaluser();
- Admin ad=new Admin();
- Library bc=new Library();
- Rent rt=new Rent();
LocalTime t=LocalTime.now();
LocalTime t1=LocalTime.of(9,00,00);
LocalTime t2=LocalTime.of(23,00,00);
@@ -15,8 +10,8 @@ public void runner() {
Scanner sc=new Scanner(System.in);
Scanner sc2=new Scanner(System.in);
if (t.isAfter(t1) && t.isBefore(t2)) {
- u.makeaccount("Aran Rafiaei","40230212043");
- ad.addAdmin("Aran Rafiaei","40230212043");
+ tab.nu.makeaccount("Aran Rafiaei","40230212043");
+ tab.addd.addAdmin("Aran Rafiaei","40230212043");
tab.libaddbook("binavayan","Victor Hogo","ketab dar morede chand binavast.");
tab.libaddbook("bishoori","Xavier Crement","ye ketab dar morede bishoori.");
tab.libaddbook("nooshirvani kojast","nashenas","addresse nooshivani be zaban haye mokhtalef.");
@@ -33,7 +28,7 @@ public void runner() {
System.out.print("enter the password: ");
for (;;) {
String pass=sc.nextLine();
- if (ad.adminsave.containsValue(pass)) {
+ if (tab.addd.adminsave.containsValue(pass)) {
name="Aran Rafiaei";
break;
} else {
@@ -47,7 +42,7 @@ public void runner() {
System.out.print("my name is: ");
for (;;) {
name=sc.nextLine();
- if (u.mempasssave.containsKey(name)==false) {
+ if (tab.nu.mempasssave.containsKey(name)==false) {
break;
} else {
System.out.print("your name must be unique.try another: ");
@@ -57,13 +52,13 @@ public void runner() {
String pasw;
while (true) {
pasw=sc2.nextLine();
- if (u.mempasssave.containsValue(pasw)) {
+ if (tab.nu.mempasssave.containsValue(pasw)) {
System.out.print("this password is not unique: ");
} else {
break;
}
}
- u.makeaccount(name,pasw);
+ tab.nu.makeaccount(name,pasw);
l=true;
System.out.println("now you have an account.");
break;
@@ -120,7 +115,7 @@ public void runner() {
m=true;
System.out.print("enter the admin password: ");
String adminpass=sc.nextLine();
- if (ad.adminsave.containsValue(adminpass)==false) {
+ if (tab.addd.adminsave.containsValue(adminpass)==false) {
System.out.println("seems like you are not admin.");
break;
}
@@ -129,7 +124,7 @@ public void runner() {
System.out.print("enter a password: ");
String mpass=sc2.nextLine();
boolean a=false;
- if (u.mempasssave.containsKey(mname)==false && u.mempasssave.containsValue(mpass)==false) {
+ if (tab.nu.mempasssave.containsKey(mname)==false && tab.nu.mempasssave.containsValue(mpass)==false) {
a=true;
}
tab.libaddmember(mname,mpass);
@@ -141,7 +136,7 @@ public void runner() {
boolean b = false;
switch (ans) {
case "yes":
- ad.addAdmin(mname, mpass);
+ tab.addd.addAdmin(mname, mpass);
System.out.println("admin added!");
b = true;
break;
@@ -174,7 +169,7 @@ public void runner() {
m=true;
System.out.print("enter the admin password: ");
String pw=sc.nextLine();
- if (ad.adminsave.containsValue(pw)==false) {
+ if (tab.addd.adminsave.containsValue(pw)==false) {
System.out.println("seems like you are not admin.");
break;
}
@@ -208,4 +203,4 @@ public void runner() {
System.out.println("Sorry,we are closed!");
}
}
-}
\ No newline at end of file
+}