From d5748eff68074b0205d0c11a392604272386a9b8 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 18:23:37 +0330 Subject: [PATCH 01/47] MyApp class is added to project --- Answers/40230112081/MyApp.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Answers/40230112081/MyApp.java diff --git a/Answers/40230112081/MyApp.java b/Answers/40230112081/MyApp.java new file mode 100644 index 0000000..3fd1a76 --- /dev/null +++ b/Answers/40230112081/MyApp.java @@ -0,0 +1,5 @@ +public class MyApp { + public static void main(String[] args){ + + } +} From 86ad6bf2d1b7bdd0670888d1ca38bea0f3ff9540 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 18:31:52 +0330 Subject: [PATCH 02/47] User class is added to project --- Answers/40230112081/User.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Answers/40230112081/User.java diff --git a/Answers/40230112081/User.java b/Answers/40230112081/User.java new file mode 100644 index 0000000..94f6a88 --- /dev/null +++ b/Answers/40230112081/User.java @@ -0,0 +1,21 @@ +public class User { + private String user_name; + private String userID; + private String phonenumber; + private String role; + + // constructor + public User(String userName, String userId, String phoneNumber, String role) + { + this.role = role; + this.phonenumber = phoneNumber; + this.user_name = userName; + this.userID = userId; + } + + // getters + public String getUserID() { return this.userID; } + public String getUser_name() { return this.user_name; } + public String getPhonenumber() { return this.phonenumber; } + public String getRole() { return this.role; } +} From 4012f6e3a36ea1709a42e1b66835fa55d5dc3ce8 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 18:58:21 +0330 Subject: [PATCH 03/47] myFileClass is added to project and it includes methods like add-to-file --- Answers/40230112081/myFileCLass.java | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Answers/40230112081/myFileCLass.java diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java new file mode 100644 index 0000000..d2a7ec2 --- /dev/null +++ b/Answers/40230112081/myFileCLass.java @@ -0,0 +1,61 @@ +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; + +public class myFileCLass { + public File f; + public String dir; + + public void add_to_file(String query){ + f = new File(dir); + FileOutputStream fos = null; + try + { + fos = new FileOutputStream(f); + fos.write(query.getBytes(StandardCharsets.UTF_8)); + }catch (Exception e) + { + e.printStackTrace(); + } + finally { + try{ + if(fos != null) + fos.close(); + + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public ArrayList lines_of_file() + { + String line; + ArrayList lines = new ArrayList<>(); + BufferedReader br = null; + FileReader fr = null; + try{ + fr = new FileReader(f); + br = new BufferedReader(fr); // use buffer reader to read more efficient + while((line = br.readLine()) != null){ + lines.add(line); + } + + }catch (Exception e){ + e.printStackTrace(); + } + finally { + try { + if(fr != null) + fr.close(); + if(br != null) + br.close(); + } + catch(Exception e){ + e.printStackTrace(); + } + } + return lines; + } + +} From d7e37a1a0378c2dc70e914acdf0e5d96ce02aa6c Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 19:58:45 +0330 Subject: [PATCH 04/47] Book class is added to project --- Answers/40230112081/.idea/.gitignore | 3 + Answers/40230112081/.idea/40230112081.iml | 11 +++ Answers/40230112081/.idea/misc.xml | 6 ++ Answers/40230112081/.idea/modules.xml | 8 ++ Answers/40230112081/.idea/vcs.xml | 6 ++ Answers/40230112081/Book.java | 31 ++++++++ Answers/40230112081/myFileCLass.java | 69 +++++++++++++++++- .../production/40230112081/.idea/.gitignore | 3 + .../40230112081/.idea/40230112081.iml | 11 +++ .../out/production/40230112081/.idea/misc.xml | 6 ++ .../production/40230112081/.idea/modules.xml | 8 ++ .../out/production/40230112081/.idea/vcs.xml | 6 ++ .../out/production/40230112081/MyApp.class | Bin 0 -> 358 bytes .../out/production/40230112081/User.class | Bin 0 -> 886 bytes .../production/40230112081/myFileCLass.class | Bin 0 -> 5067 bytes .../out/production/40230112081/test.class | Bin 0 -> 1861 bytes 16 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 Answers/40230112081/.idea/.gitignore create mode 100644 Answers/40230112081/.idea/40230112081.iml create mode 100644 Answers/40230112081/.idea/misc.xml create mode 100644 Answers/40230112081/.idea/modules.xml create mode 100644 Answers/40230112081/.idea/vcs.xml create mode 100644 Answers/40230112081/Book.java create mode 100644 Answers/40230112081/out/production/40230112081/.idea/.gitignore create mode 100644 Answers/40230112081/out/production/40230112081/.idea/40230112081.iml create mode 100644 Answers/40230112081/out/production/40230112081/.idea/misc.xml create mode 100644 Answers/40230112081/out/production/40230112081/.idea/modules.xml create mode 100644 Answers/40230112081/out/production/40230112081/.idea/vcs.xml create mode 100644 Answers/40230112081/out/production/40230112081/MyApp.class create mode 100644 Answers/40230112081/out/production/40230112081/User.class create mode 100644 Answers/40230112081/out/production/40230112081/myFileCLass.class create mode 100644 Answers/40230112081/out/production/40230112081/test.class diff --git a/Answers/40230112081/.idea/.gitignore b/Answers/40230112081/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Answers/40230112081/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Answers/40230112081/.idea/40230112081.iml b/Answers/40230112081/.idea/40230112081.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/Answers/40230112081/.idea/40230112081.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112081/.idea/misc.xml b/Answers/40230112081/.idea/misc.xml new file mode 100644 index 0000000..07115cd --- /dev/null +++ b/Answers/40230112081/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Answers/40230112081/.idea/modules.xml b/Answers/40230112081/.idea/modules.xml new file mode 100644 index 0000000..4567373 --- /dev/null +++ b/Answers/40230112081/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112081/.idea/vcs.xml b/Answers/40230112081/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/Answers/40230112081/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Answers/40230112081/Book.java b/Answers/40230112081/Book.java new file mode 100644 index 0000000..19de87e --- /dev/null +++ b/Answers/40230112081/Book.java @@ -0,0 +1,31 @@ +import javax.print.DocFlavor; + +public class Book { + private String id; + private String title; + private String author; + private String description; + private String status; + + // constructor + public Book(String id,String title,String author,String description,String status) + { + this.id = id; + this.title = title; + this.author = author; + this.description = description; + this.status = status; + } + + // getters + public String getId() { return this.id; } + public String getTitle() { return this.title; } + public String getAuthor() { return this.author; } + public String getDescription() { return this.description; } + public String getStatus() { return this.status; } + + // setter + public void change_status(String new_stat) { + this.status = new_stat; + } +} diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index d2a7ec2..acdd1e7 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -5,14 +5,14 @@ public class myFileCLass { public File f; public String dir; - public void add_to_file(String query){ f = new File(dir); FileOutputStream fos = null; try { - fos = new FileOutputStream(f); + fos = new FileOutputStream(f, true); fos.write(query.getBytes(StandardCharsets.UTF_8)); + fos.write("\n".getBytes(StandardCharsets.UTF_8)); }catch (Exception e) { e.printStackTrace(); @@ -30,6 +30,7 @@ public void add_to_file(String query){ public ArrayList lines_of_file() { + f = new File(dir); String line; ArrayList lines = new ArrayList<>(); BufferedReader br = null; @@ -58,4 +59,68 @@ public ArrayList lines_of_file() return lines; } + public int set_id(){ + return lines_of_file().size(); + } + + public void addUser(User u){ + String username = u.getUser_name(); + String id = u.getUserID(); + String phone = u.getPhonenumber(); + String role = u.getRole(); + String query =id+","+username + "," +phone+","+role; + add_to_file(query); + } + + public ArrayList getIDInFile(){ + int flag; + ArrayList ids = new ArrayList<>(); + ArrayList lines = lines_of_file(); + for(String l : lines){ + flag = l.indexOf(","); + ids.add(l.substring(0, flag)); + } + return ids; + } + public ArrayList getUsernameInFile(){ + int f1, f2; + ArrayList usernames = new ArrayList<>(); + ArrayList lines = lines_of_file(); + for(String l : lines){ + f1 = l.indexOf(","); + f2 = l.indexOf(",", f1+1); + usernames.add(l.substring(f1+1,f2)); + } + return usernames; + } + public ArrayList getPhoneNumbersInFile(){ + int f1,f2,f3; + ArrayList phones = new ArrayList<>(); + ArrayList lines = lines_of_file(); + for(String l : lines){ + f1 = l.indexOf(","); + f2 = l.indexOf(",", f1+1); + f3 = l.indexOf(",",f2+1); + phones.add(l.substring(f2+1, f3)); + } + return phones; + } + public ArrayList getUserRolesInFile(){ + int f1,f2,f3,f4; + ArrayList roles = new ArrayList<>(); + ArrayList lines = lines_of_file(); + for(String l : lines){ + f1 = l.indexOf(","); + f2 = l.indexOf(",", f1+1); + f3 = l.indexOf(",",f2+1); + roles.add(l.substring(f3+1)); + } + return roles; + } + } + + + +// user : id,username,phonenumber,role +// book : id,title,author,description,status \ No newline at end of file diff --git a/Answers/40230112081/out/production/40230112081/.idea/.gitignore b/Answers/40230112081/out/production/40230112081/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Answers/40230112081/out/production/40230112081/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Answers/40230112081/out/production/40230112081/.idea/40230112081.iml b/Answers/40230112081/out/production/40230112081/.idea/40230112081.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/Answers/40230112081/out/production/40230112081/.idea/40230112081.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112081/out/production/40230112081/.idea/misc.xml b/Answers/40230112081/out/production/40230112081/.idea/misc.xml new file mode 100644 index 0000000..07115cd --- /dev/null +++ b/Answers/40230112081/out/production/40230112081/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Answers/40230112081/out/production/40230112081/.idea/modules.xml b/Answers/40230112081/out/production/40230112081/.idea/modules.xml new file mode 100644 index 0000000..4567373 --- /dev/null +++ b/Answers/40230112081/out/production/40230112081/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112081/out/production/40230112081/.idea/vcs.xml b/Answers/40230112081/out/production/40230112081/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/Answers/40230112081/out/production/40230112081/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Answers/40230112081/out/production/40230112081/MyApp.class b/Answers/40230112081/out/production/40230112081/MyApp.class new file mode 100644 index 0000000000000000000000000000000000000000..6d2ef3b291e10658f25510d62ab16ccf7ec12a3b GIT binary patch literal 358 zcmZutO-sW-5Pg&8!^UcBE8e}e3g!pY3Z>9f)I%i~Pn)>JE$ODLsnDP0N$}tg@JC5! zS3waM<_$CNy_wzp_}y<;`Z5OLHgkiaY(ZE<}|Hqip@%^qWWZM2J%79kkc%AyE}2WF1?|}-ijC)q fYxClIuJ}c+xH2zp*n5SUQ#6{Wd?AEhc9*HF~3aYxNy!M-!MCw#q5Gv-&os|j} zHO$mE4vOCe8Wv)a0wu0so^9mZ+NNT$f+fX)^ySRSoJs$NJ`qGULgK!Lw>$3Llf&Y> z7RyvD*YGhsr(lKUCPjm>aXphY%$9yrPsQ|1tkYgI6W`&1y(3!`)YxGZ8#_kKsSYbu z)N5FU)g@5cNh=7PGR%&Pra^zpov3DW)Of5z5@^uSh$dcrK9evFJ{yj8G!6z3CLlpE zSf`;yislr5$$mnA{^l|r) zRrI1mo3KH}R#%%d6UmlcnT&q1JCQYm*dnaiMs(c^rRs+aJ!WKrXhXYzze7RgH1LH% zyA)Krr#f=+xREhp?#Z3#l#{!8?bJzI+15B1#7^whun%3tl68)CCsG7vVMF6g21$tf zHGBfyq@f;*P2-u(?zYBZiFTbh=1&j@G#tbs1#^@1oE=HWN8-#&!D9D{QXE+GEf~;n z7=sGD*~E)9Wt&8UIEo<^!y1lBtlq;}gMFZ}{34B{^a(>uUeItt^yQ8sx?6Tn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<|B$K`mE;LeKGG^%G*L1qW%TyPZH`; z>f+R$rf!0|G<7C*=dsMfvx`yhB645D*BM3BlCDu2D(t0+yl8!l?E-AvMS7Ldv4PnZ z-@t3E)HkVbK=5DKuA;g_#q;}!hvo>^KVn`guFKN@4~q!=9^sRf^Tc^qfT!FmJ~46{77lwy3I!6jUF*23o) zcjWmB-oQ=nU!^2#uT}0>QBQdV3%rsAs%LRl(bF21ya5~dyA4hB+lu{M_3<;epB|2o z2*cQn(nRZub_cHCSVm{J;Io{?X&r=qTCw_GKSHa%mQ z)9e*)&$pCOa_u9`5z1L>zi{p*ulC@Fy!;jh?WsXX?2!{_%A+rj{=1gV)YREwL1Isx zfRmttAK}N&`8!NWl5ZmYj`Z;7crSlOB3}NEMtsfTkT>Le2m^@tn?n9P5>s<+xplIW z5bkE$d)Uo;*{%CXhc1>sYTYdTN$-WeYr;=(n|J$2mOCtqhbN!IPbro0d<}j^$xAN_ zSg7;A;jZyVt9-rD4 z4*AMBJ}=wN_E)xnOJ_Tq9(HmsXICFHI6%@J;hy0Xk3s`*6JcUJ_HP4Rl_b4+R zVhatE-N(?*#_Hy5?&JTDq}AG4g|!?3f`^|LwRp?Iqn*6}6(xCT9xNae#oHDh^U!G_ zV>gqHjOYXpTX%yg3Nkf<%p&-utw;po;zA>>?{>pG1!(GcPA2h)15LzhVPn1HlAMWt z2b&!tIoNO{I@s{(U?W?#7EJBrze;gg0jKvu-YK9~vx(((SPo7APO~sOWg{or4!&0Q zW1P?>2-)dED}*`k1T2+S4Gvg4_$sr(+Rv9^p0Jfk3Jz@LZ1o3(%}f6WEZBSnLfJY2 z%huf>Jq5O<0$Vjy3${|+_7vgv>k`}~krOU%J_|PjCY&Nd4sPutIk*Kv0S7leUECVJpRLcLBFDJfy7$kMJ8l1ML3y S`1gDKk*gr3r}#5IMCd<6XILu$ literal 0 HcmV?d00001 diff --git a/Answers/40230112081/out/production/40230112081/test.class b/Answers/40230112081/out/production/40230112081/test.class new file mode 100644 index 0000000000000000000000000000000000000000..3908f0df32148c89be01cca64a94366b21e82fcd GIT binary patch literal 1861 zcma)6OK%%h6#lO5c5}u3s%lk2v6IN?Ojm_CdZdFL=<`&Mm5harm{KH zaV$3q9i18s12G)hgOc5>dR9pxU^@!^nTDrbPR%)$nwRxl%PdXl(9kXMdlZI}2bxIW zUWLxm=B!<`W-?~Asw0kI1Op1uTGeu^linjQ%Do{22@EsayzMH)eYi$J3}-uQQyNAU zdUr~==DOx)#;$rgMi7)rjv6?I&x*uN3kKh%y z$CoSXWygx(wYGs@GVPmA)=fS~<<1GU-;?YA70dmZe<@<^DhJjhp z_EWnkWiQl9s~mA$-6kvJwmi5fs#=Kc+v`E84&S$nG%wQ2EonidS6fm#w2kx2XV08Vgtl-Y-I>r6oprqN*ihd+|30DDaXH-~ Date: Thu, 9 May 2024 21:00:00 +0330 Subject: [PATCH 05/47] New methods added to project for search& add to files related to Books & Users --- Answers/40230112081/myFileCLass.java | 73 ++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index acdd1e7..2a9b72f 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -118,6 +118,79 @@ public ArrayList getUserRolesInFile(){ return roles; } + public void addBook(Book b){ + String query; + String id, title, author, desc, status; + id = b.getId(); + title = b.getTitle(); + author = b.getAuthor(); + desc = b.getDescription(); + status = b.getStatus(); + query = id + "," + title + "," + author + "," + desc + "," + status; + add_to_file(query); + } + + public ArrayList getIdFromFileBook(){ + int f1; + ArrayList lines = lines_of_file(); + ArrayList ids = new ArrayList<>(); + for(String str : lines){ + f1 = str.indexOf(","); + ids.add(str.substring(0, f1)); + } + return ids; + } + + public ArrayList getTitlesFromFileBook(){ + int f1,f2; + ArrayList lines = lines_of_file(); + ArrayList titles = new ArrayList<>(); + for(String str : lines){ + f1 = str.indexOf(","); + f2 = str.indexOf(",", f1+1); + titles.add(str.substring(f1+1, f2)); + } + return titles; + } + public ArrayList getAuthorsFromFileBook(){ + int f1,f2, f3; + ArrayList lines = lines_of_file(); + ArrayList authors = new ArrayList<>(); + for(String str : lines){ + f1 = str.indexOf(","); + f2 = str.indexOf(",", f1+1); + f3 = str.indexOf(",", f2+1); + authors.add(str.substring(f2+1, f3)); + } + return authors; + } + public ArrayList getDescriptionsFromFileBook(){ + int f1,f2, f3, f4; + ArrayList lines = lines_of_file(); + ArrayList descrips = new ArrayList<>(); + for(String str : lines){ + f1 = str.indexOf(","); + f2 = str.indexOf(",", f1+1); + f3 = str.indexOf(",", f2+1); + f4 = str.indexOf(",", f3+1); + descrips.add(str.substring(f3+1, f4)); + } + return descrips; + } + public ArrayList getStatsFromFileBook(){ + int f1,f2, f3, f4; + ArrayList lines = lines_of_file(); + ArrayList stats = new ArrayList<>(); + for(String str : lines){ + f1 = str.indexOf(","); + f2 = str.indexOf(",", f1+1); + f3 = str.indexOf(",", f2+1); + f4 = str.indexOf(",", f3+1); + stats.add(str.substring(f4+1)); + } + return stats; + } + } From 4a0ddc948070cb9c6584082d361b2f48746554af Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 21:43:10 +0330 Subject: [PATCH 06/47] Book class has been updated --- Answers/40230112081/Book.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Answers/40230112081/Book.java b/Answers/40230112081/Book.java index 19de87e..2616827 100644 --- a/Answers/40230112081/Book.java +++ b/Answers/40230112081/Book.java @@ -1,4 +1,4 @@ -import javax.print.DocFlavor; + public class Book { private String id; From f448c71d556cf1162800a21890c670b63be555b7 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 21:49:49 +0330 Subject: [PATCH 07/47] Library class is added to project --- Answers/40230112081/Library.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Answers/40230112081/Library.java diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java new file mode 100644 index 0000000..4e82000 --- /dev/null +++ b/Answers/40230112081/Library.java @@ -0,0 +1,12 @@ +public class Library { + private String libName; + private int libCap; + private String oprHours; + + // repos & registries + myFileCLass usersFileHandle; + myFileCLass adminsFileHandle; + myFileCLass booksFileHandle; + + // verifications +} From 3dc3dc3ec4cc9d5d1a92bcdf10244084464ef2e7 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 22:16:17 +0330 Subject: [PATCH 08/47] Verification class is added to verify Users ID, Phonenumber, username. --- Answers/40230112081/Verifications.java | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Answers/40230112081/Verifications.java diff --git a/Answers/40230112081/Verifications.java b/Answers/40230112081/Verifications.java new file mode 100644 index 0000000..b8eb14e --- /dev/null +++ b/Answers/40230112081/Verifications.java @@ -0,0 +1,62 @@ +import java.util.ArrayList; + +public class Verifications { + + public int ascii(char ch){ + return (int)ch; + } + public boolean userIdValidator(String _id_){ + // User ID must be numerical with length between 10 and 15 + // ASCII Approach + if(_id_.length() < 10 || _id_.length() > 15) + return false; + else{ + for(char ch : _id_.toCharArray()){ + if(ascii(ch) < 48 || ascii(ch) > 57) + return false; + } + } + return true; + } + + public boolean userUsernameValidator(String _username_){ + // Username must include 0->9 and a->z and A->Z , just underline '_' not dash '-' + ArrayList valid_chars = new ArrayList<>(); + String upperAlph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + String Alph = upperAlph.toLowerCase(); + String numbers = "0123456789"; + + for(Character ch : upperAlph.toCharArray()){ + valid_chars.add(ch); + } + for(Character ch : Alph.toCharArray()){ + valid_chars.add(ch); + } + for(Character ch : numbers.toCharArray()){ + valid_chars.add(ch); + } + valid_chars.add('_'); + for(Character ch : _username_.toCharArray()){ + if(!valid_chars.contains(ch)) + return false; + } + + return true; + } + + public boolean userPhonenumberValidator(String _phonenumber_){ + // User phonenumber must start with any number instead of 0 + // length must be 10 + // ASCII approach + if(_phonenumber_.length() < 10 || _phonenumber_.length() > 10) + return false; + else + { + for(char ch : _phonenumber_.toCharArray()){ + if(ascii(ch) < 48 || ascii(ch) > 57) + return false; + } + } + return true; + } +} From 919d558e59ca22910d64dc5d0ed8dec5dfa5dc12 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 22:19:50 +0330 Subject: [PATCH 09/47] Users text file is added to project to store Normal users details --- Answers/40230112081/.idea/uiDesigner.xml | 124 +++++++++++++++++++++++ Answers/40230112081/Users.txt | 0 2 files changed, 124 insertions(+) create mode 100644 Answers/40230112081/.idea/uiDesigner.xml create mode 100644 Answers/40230112081/Users.txt diff --git a/Answers/40230112081/.idea/uiDesigner.xml b/Answers/40230112081/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/Answers/40230112081/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112081/Users.txt b/Answers/40230112081/Users.txt new file mode 100644 index 0000000..e69de29 From aff9a1fed8c9193f837f77f00a1cc2854863e42f Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 22:20:45 +0330 Subject: [PATCH 10/47] Books text file is added to project to store Books details --- Answers/40230112081/Books.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Answers/40230112081/Books.txt diff --git a/Answers/40230112081/Books.txt b/Answers/40230112081/Books.txt new file mode 100644 index 0000000..e69de29 From adb68a5b0e4c4e075d9f370859304e17bdb12f56 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 22:21:19 +0330 Subject: [PATCH 11/47] Admins text file is added to project to store Admin details --- Answers/40230112081/Admins.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Answers/40230112081/Admins.txt diff --git a/Answers/40230112081/Admins.txt b/Answers/40230112081/Admins.txt new file mode 100644 index 0000000..e69de29 From 683f8112ba2f039bcba172140c72b6c455fe739a Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 22:22:03 +0330 Subject: [PATCH 12/47] Rental text file is added to store rental books details --- Answers/40230112081/Rentals.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Answers/40230112081/Rentals.txt diff --git a/Answers/40230112081/Rentals.txt b/Answers/40230112081/Rentals.txt new file mode 100644 index 0000000..e69de29 From 47179d0f5c162b047ddddfbb5f99b44a6cfa74a7 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 9 May 2024 22:35:19 +0330 Subject: [PATCH 13/47] File class is updated with password detection for users --- Answers/40230112081/myFileCLass.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index 2a9b72f..75136f9 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -113,11 +113,26 @@ public ArrayList getUserRolesInFile(){ f1 = l.indexOf(","); f2 = l.indexOf(",", f1+1); f3 = l.indexOf(",",f2+1); - roles.add(l.substring(f3+1)); + f4 = l.indexOf(",", f3+1); + roles.add(l.substring(f3+1,f4)); } return roles; } + public ArrayList getUserPassword(){ + int f1,f2,f3,f4; + ArrayList passwords = new ArrayList<>(); + ArrayList lines = lines_of_file(); + for(String l : lines){ + f1 = l.indexOf(","); + f2 = l.indexOf(",", f1+1); + f3 = l.indexOf(",",f2+1); + f4 = l.indexOf(",", f3+1); + passwords.add(l.substring(f4+1)); + } + return passwords; + } + public void addBook(Book b){ String query; String id, title, author, desc, status; @@ -195,5 +210,5 @@ public ArrayList getStatsFromFileBook(){ -// user : id,username,phonenumber,role +// user : id,username,phonenumber,role,password // book : id,title,author,description,status \ No newline at end of file From 7884202bbd00864ec5f84288fc4d553822ac76e6 Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 01:30:07 +0330 Subject: [PATCH 14/47] Constructor is added to library class --- Answers/40230112081/Library.java | 33 ++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index 4e82000..fcc9675 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -4,9 +4,34 @@ public class Library { private String oprHours; // repos & registries - myFileCLass usersFileHandle; - myFileCLass adminsFileHandle; - myFileCLass booksFileHandle; - + public myFileCLass usersFileHandle; + public myFileCLass adminsFileHandle; + public myFileCLass booksFileHandle; + public myFileCLass rentalFileHandle; // verifications + public Verifications v; + // constructor + public Library(String name, String duration, int cap){ + this.oprHours = duration; + this.libCap = cap; + this.libName = name; + usersFileHandle = new myFileCLass(); + adminsFileHandle = new myFileCLass(); + booksFileHandle = new myFileCLass(); + rentalFileHandle = new myFileCLass(); + usersFileHandle.dir = "Users.txt"; + adminsFileHandle.dir = "Admins.txt"; + booksFileHandle.dir = "Books.txt"; + rentalFileHandle.dir = "Rental.txt"; + } + // getters + public String getLibName() { return this.libName; } + public int getLibCap() { return this.libCap; } + public String getOprHours() { return this.oprHours; } + + // login as admin + + // login as normal user + + } From 3ac8224d574187edeb55a1efc37e10e8add82d5a Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 01:35:12 +0330 Subject: [PATCH 15/47] Rent class is added to project with constructor and getters --- Answers/40230112081/Rent.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Answers/40230112081/Rent.java diff --git a/Answers/40230112081/Rent.java b/Answers/40230112081/Rent.java new file mode 100644 index 0000000..5875326 --- /dev/null +++ b/Answers/40230112081/Rent.java @@ -0,0 +1,28 @@ +public class Rent { + private Book rentalBook; + private User userToRentBook; + private String date; + + // constructor + public Rent(Book book, User nrmUser, String date){ + this.rentalBook = book; + this.userToRentBook = nrmUser; + this.date = date; + } + + // getters + + public String getDate(){ + return this.date; + } + + public String getUserID(){ + return this.userToRentBook.getUserID(); + } + + public String getBookID(){ + return this.rentalBook.getId(); + } + + +} From f0481833a0ce7604b90fa1aec56d0201fdc0fb7c Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 01:45:49 +0330 Subject: [PATCH 16/47] Class has been updated with method related to Rentals file --- Answers/40230112081/myFileCLass.java | 52 +++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index 75136f9..b243965 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -1,4 +1,5 @@ import java.io.*; +import java.lang.reflect.Array; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -206,9 +207,58 @@ public ArrayList getStatsFromFileBook(){ return stats; } + public void addRental(Rent r){ + String query; + String date = r.getDate(); + String userID = r.getUserID(); + String bookID = r.getBookID(); + + query = date+","+userID+","+bookID; + add_to_file(query); + } + + public ArrayList getRentalsDate(){ + ArrayList lines = lines_of_file(); + ArrayList dates = new ArrayList<>(); + int f1; + for(String str: lines){ + f1 = str.indexOf(",", 0); + dates.add(str.substring(0, f1)); + } + return dates; + } + + public ArrayList getRentalsUserID(){ + ArrayList lines = lines_of_file(); + ArrayList userIds = new ArrayList<>(); + int f1, f2; + for(String str: lines){ + f1 = str.indexOf(",", 0); + f2 = str.indexOf(",", f1+1); + userIds.add(str.substring(f1+1, f2)); + } + return userIds; + } + + public ArrayList getRentalsBookID(){ + ArrayList lines = lines_of_file(); + ArrayList bookIds = new ArrayList<>(); + int f1, f2; + for(String str: lines){ + f1 = str.indexOf(",", 0); + f2 = str.indexOf(",", f1+1); + bookIds.add(str.substring(f2+1)); + } + return bookIds; + } + + + + } // user : id,username,phonenumber,role,password -// book : id,title,author,description,status \ No newline at end of file +// book : id,title,author,description,status +// rent : date,userID,bookID \ No newline at end of file From c3e17028c8b5417b09d5b9ceb2539f9766c76be1 Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 11:29:56 +0330 Subject: [PATCH 17/47] Class has been updated with method related to Books file --- Answers/40230112081/myFileCLass.java | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index b243965..7efb47f 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -194,7 +194,7 @@ public ArrayList getDescriptionsFromFileBook(){ return descrips; } public ArrayList getStatsFromFileBook(){ - int f1,f2, f3, f4; + int f1,f2, f3, f4, f5; ArrayList lines = lines_of_file(); ArrayList stats = new ArrayList<>(); for(String str : lines){ @@ -202,11 +202,30 @@ public ArrayList getStatsFromFileBook(){ f2 = str.indexOf(",", f1+1); f3 = str.indexOf(",", f2+1); f4 = str.indexOf(",", f3+1); - stats.add(str.substring(f4+1)); + f5 = str.indexOf(",", f4+1); + stats.add(str.substring(f4+1,f5)); } return stats; } + public ArrayList getExistsFromFileBook(){ + int f1,f2, f3, f4, f5; + ArrayList lines = lines_of_file(); + ArrayList exists = new ArrayList<>(); + for(String str : lines){ + f1 = str.indexOf(","); + f2 = str.indexOf(",", f1+1); + f3 = str.indexOf(",", f2+1); + f4 = str.indexOf(",", f3+1); + f5 = str.indexOf(",", f4+1); + exists.add(str.substring(f5)); + } + return exists; + } + + + + public void addRental(Rent r){ String query; String date = r.getDate(); @@ -260,5 +279,5 @@ public ArrayList getRentalsBookID(){ // user : id,username,phonenumber,role,password -// book : id,title,author,description,status +// book : id,title,author,description,status,existence // rent : date,userID,bookID \ No newline at end of file From 8e445051cd9f4d9266673e783064dcb429099e1f Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 15:12:25 +0330 Subject: [PATCH 18/47] Sign up is made for just normal users --- Answers/40230112081/Library.java | 116 ++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index fcc9675..54fdb7c 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -1,3 +1,7 @@ +import java.sql.SQLOutput; +import java.util.ArrayList; +import java.util.Scanner; + public class Library { private String libName; private int libCap; @@ -29,9 +33,119 @@ public Library(String name, String duration, int cap){ public int getLibCap() { return this.libCap; } public String getOprHours() { return this.oprHours; } - // login as admin + public void add_normalUser(){ // sign-up just for normal users + String id, username, pass, phonenumber; + User u; + Scanner scn = new Scanner(System.in); + Scanner scn1 = new Scanner(System.in); + v = new Verifications(); + // first string verification + System.out.println("Enter your id :"); + System.out.println("Your id must be numerical with length between 10 and 15"); + while (true){ + id = scn.nextLine(); + if(v.userIdValidator(id)) + break; + else{ + System.out.println("Wrong format, try again."); + } + } + System.out.println("Enter username :"); + System.out.println("Username must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + while (true){ + username = scn.nextLine(); + if(v.userUsernameValidator(username)){ + break; + } + else{ + System.out.println("Wrong format, try again."); + } + } + System.out.println("Enter a phonenumber :"); + System.out.println("User phonenumber must start with any number instead of 0 with length 10"); + while (true){ + phonenumber = scn1.nextLine(); + if(v.userPhonenumberValidator(phonenumber)){ + break; + } + else{ + System.out.println("Wrong Format, Try again."); + } + } + // now to check file + if(usersFileHandle.getUsernameInFile().contains(username) || usersFileHandle.getIDInFile().contains(id) + || usersFileHandle.getPhoneNumbersInFile().contains(phonenumber)){ + System.out.println("Sorry, We found your id/username/phonenumber , Please goto login panel"); + return; + } + System.out.println("Set a password for yourself :"); + System.out.println("Password must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + while (true){ + pass = scn.nextLine(); + if(v.userPasswordValidator(pass)){ + break; + } + else{ + System.out.println("Wrong Format, Try Again."); + } + } + u = new User(username, id, phonenumber,"normal", pass); + usersFileHandle.addUser(u); + + } // login as normal user + // login as admin user + public void login_user(){ + System.out.println("Enter your ID:"); + String id, username, pass; + Scanner scn = new Scanner(System.in); + while(true){ + + } + } } + +/* +System.out.println("Enter your id :"); + id = scn.nextLine(); + if(usersFileHandle.getIDInFile().contains(id)){ + System.out.println("You have been registered before. Login please:-)"); + } + else { + while(true){ + if(v.userIdValidator(id)){ + break; + } + else{ + System.out.println("Enter id again, your ID must be numerical with length between 10 and 15"); + id = scn.nextLine(); + } + } + System.out.println("Enter your username :"); + System.out.println("Username must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + while(true){ + username = scn.nextLine(); + if(!v.userUsernameValidator(username) || usersFileHandle.getUsernameInFile().contains(username)){ + System.out.println("Wrong Input try again :-|"); + } + else{ + break; + } + } + System.out.println("Enter your phonenumber :"); + System.out.println("User phonenumber must start with any number instead of 0 with length 10"); + while(true){ + phonenumber = scn.nextLine(); + if(!v.userPhonenumberValidator(phonenumber) || usersFileHandle.getPhoneNumbersInFile().contains(phonenumber)){ + System.out.println("Wrong Input try again :-|"); + } + else{ + break; + } + } + + } + */ From 71c0282c45926befd3c0bda8b3ff1cc84d5c298b Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 15:13:07 +0330 Subject: [PATCH 19/47] Null String issues is resolved for file methods --- Answers/40230112081/myFileCLass.java | 63 ++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index 7efb47f..628c0fa 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -2,6 +2,7 @@ import java.lang.reflect.Array; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Objects; public class myFileCLass { public File f; @@ -59,7 +60,33 @@ public ArrayList lines_of_file() } return lines; } + public void editLineInFile(String lineToEdit, String newLine) { + try { + // Read the file + f = new File(dir); + BufferedReader reader = new BufferedReader(new FileReader(f)); + String line; + StringBuilder fileContent = new StringBuilder(); + // Read each line and replace if it matches + while ((line = reader.readLine()) != null) { + if (line.equals(lineToEdit)) { + fileContent.append(newLine).append("\n"); + } else { + fileContent.append(line).append("\n"); + } + } + reader.close(); + + // Write back to the file + FileWriter writer = new FileWriter(dir); + writer.write(fileContent.toString()); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } public int set_id(){ return lines_of_file().size(); } @@ -69,7 +96,8 @@ public void addUser(User u){ String id = u.getUserID(); String phone = u.getPhonenumber(); String role = u.getRole(); - String query =id+","+username + "," +phone+","+role; + String pass = u.getPassword(); + String query =id+","+username + "," +phone+","+role+","+pass; add_to_file(query); } @@ -78,6 +106,8 @@ public ArrayList getIDInFile(){ ArrayList ids = new ArrayList<>(); ArrayList lines = lines_of_file(); for(String l : lines){ + if(Objects.equals(l, "")) + continue; flag = l.indexOf(","); ids.add(l.substring(0, flag)); } @@ -88,6 +118,8 @@ public ArrayList getUsernameInFile(){ ArrayList usernames = new ArrayList<>(); ArrayList lines = lines_of_file(); for(String l : lines){ + if(Objects.equals(l, "")) + continue; f1 = l.indexOf(","); f2 = l.indexOf(",", f1+1); usernames.add(l.substring(f1+1,f2)); @@ -99,6 +131,8 @@ public ArrayList getPhoneNumbersInFile(){ ArrayList phones = new ArrayList<>(); ArrayList lines = lines_of_file(); for(String l : lines){ + if(Objects.equals(l, "")) + continue; f1 = l.indexOf(","); f2 = l.indexOf(",", f1+1); f3 = l.indexOf(",",f2+1); @@ -111,6 +145,8 @@ public ArrayList getUserRolesInFile(){ ArrayList roles = new ArrayList<>(); ArrayList lines = lines_of_file(); for(String l : lines){ + if(Objects.equals(l, "")) + continue; f1 = l.indexOf(","); f2 = l.indexOf(",", f1+1); f3 = l.indexOf(",",f2+1); @@ -125,6 +161,8 @@ public ArrayList getUserPassword(){ ArrayList passwords = new ArrayList<>(); ArrayList lines = lines_of_file(); for(String l : lines){ + if(Objects.equals(l, "")) + continue; f1 = l.indexOf(","); f2 = l.indexOf(",", f1+1); f3 = l.indexOf(",",f2+1); @@ -142,7 +180,8 @@ public void addBook(Book b){ author = b.getAuthor(); desc = b.getDescription(); status = b.getStatus(); - query = id + "," + title + "," + author + "," + desc + "," + status; + int exst = b.getExistence(); + query = id + "," + title + "," + author + "," + desc + "," + status + "," + String.valueOf(exst); add_to_file(query); } @@ -151,6 +190,8 @@ public ArrayList getIdFromFileBook(){ ArrayList lines = lines_of_file(); ArrayList ids = new ArrayList<>(); for(String str : lines){ + if(Objects.equals(str, "")) + continue; f1 = str.indexOf(","); ids.add(str.substring(0, f1)); } @@ -162,6 +203,8 @@ public ArrayList getTitlesFromFileBook(){ ArrayList lines = lines_of_file(); ArrayList titles = new ArrayList<>(); for(String str : lines){ + if(Objects.equals(str, "")) + continue; f1 = str.indexOf(","); f2 = str.indexOf(",", f1+1); titles.add(str.substring(f1+1, f2)); @@ -173,6 +216,8 @@ public ArrayList getAuthorsFromFileBook(){ ArrayList lines = lines_of_file(); ArrayList authors = new ArrayList<>(); for(String str : lines){ + if(Objects.equals(str, "")) + continue; f1 = str.indexOf(","); f2 = str.indexOf(",", f1+1); f3 = str.indexOf(",", f2+1); @@ -185,6 +230,8 @@ public ArrayList getDescriptionsFromFileBook(){ ArrayList lines = lines_of_file(); ArrayList descrips = new ArrayList<>(); for(String str : lines){ + if(Objects.equals(str, "")) + continue; f1 = str.indexOf(","); f2 = str.indexOf(",", f1+1); f3 = str.indexOf(",", f2+1); @@ -198,6 +245,8 @@ public ArrayList getStatsFromFileBook(){ ArrayList lines = lines_of_file(); ArrayList stats = new ArrayList<>(); for(String str : lines){ + if(Objects.equals(str, "")) + continue; f1 = str.indexOf(","); f2 = str.indexOf(",", f1+1); f3 = str.indexOf(",", f2+1); @@ -213,6 +262,8 @@ public ArrayList getExistsFromFileBook(){ ArrayList lines = lines_of_file(); ArrayList exists = new ArrayList<>(); for(String str : lines){ + if(Objects.equals(str, "")) + continue; f1 = str.indexOf(","); f2 = str.indexOf(",", f1+1); f3 = str.indexOf(",", f2+1); @@ -224,8 +275,6 @@ public ArrayList getExistsFromFileBook(){ } - - public void addRental(Rent r){ String query; String date = r.getDate(); @@ -241,6 +290,8 @@ public ArrayList getRentalsDate(){ ArrayList dates = new ArrayList<>(); int f1; for(String str: lines){ + if(Objects.equals(str, "")) + continue; f1 = str.indexOf(",", 0); dates.add(str.substring(0, f1)); } @@ -252,6 +303,8 @@ public ArrayList getRentalsUserID(){ ArrayList userIds = new ArrayList<>(); int f1, f2; for(String str: lines){ + if(Objects.equals(str, "")) + continue; f1 = str.indexOf(",", 0); f2 = str.indexOf(",", f1+1); userIds.add(str.substring(f1+1, f2)); @@ -264,6 +317,8 @@ public ArrayList getRentalsBookID(){ ArrayList bookIds = new ArrayList<>(); int f1, f2; for(String str: lines){ + if(Objects.equals(str, "")) + continue; f1 = str.indexOf(",", 0); f2 = str.indexOf(",", f1+1); bookIds.add(str.substring(f2+1)); From c47fdd7f3f2dd6043f235880b9d00d177c811239 Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 15:42:49 +0330 Subject: [PATCH 20/47] Login for normal users is made --- Answers/40230112081/Library.java | 38 +++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index 54fdb7c..c27e556 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -1,5 +1,6 @@ import java.sql.SQLOutput; import java.util.ArrayList; +import java.util.Objects; import java.util.Scanner; public class Library { @@ -96,14 +97,41 @@ public void add_normalUser(){ // sign-up just for normal users } // login as normal user // login as admin user - - public void login_user(){ - System.out.println("Enter your ID:"); - String id, username, pass; + public void login_normalUsers(){ + String phone, pass, id, user; Scanner scn = new Scanner(System.in); + int flag; while(true){ - + System.out.println("Enter your Username: (If you forget: type forget)"); + user = scn.nextLine(); + if(Objects.equals(user, "forget")) { + usersFileHandle.show_myUsername(); + continue; + } + else if (v.userUsernameValidator(user) && usersFileHandle.getUsernameInFile().contains(user)) { + flag = usersFileHandle.getUsernameInFile().indexOf(user); + break; + } + else{ + System.out.println("Username not found/wrong format, try again"); + continue; + } } + while (true){ + System.out.println("Enter your password :(if you forget , type forget)"); + pass = scn.nextLine(); + if(Objects.equals(pass,"forget")){ + usersFileHandle.show_myPassword(); + continue; + } else if (v.userPasswordValidator(pass) && Objects.equals(pass, usersFileHandle.getUserPassword().get(flag))) { + break; + } + else{ + System.out.println("Password not found/wrong format, try again"); + continue; + } + } + } } From 1a613a35625430f5edad3350ce9cbce336f2a40f Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 15:44:01 +0330 Subject: [PATCH 21/47] showPass and showUser is added to project in case of User forget his/her User/pass --- Answers/40230112081/myFileCLass.java | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index 628c0fa..0257dbc 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -3,7 +3,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Objects; - +import java.util.Scanner; public class myFileCLass { public File f; public String dir; @@ -60,6 +60,36 @@ public ArrayList lines_of_file() } return lines; } + + public void show_myUsername(){ + System.out.println("Enter your phonenumber :"); + String phone; + Scanner scn = new Scanner(System.in); + phone = scn.nextLine(); + int i = getPhoneNumbersInFile().indexOf(phone); + if(i != -1) { + System.out.println(getUsernameInFile().get(i)); + return; + } + else{ + System.out.println("Your phonenumber is not found, try phonenumber you were signed up"); + } + + } + public void show_myPassword(){ + System.out.println("Enter your phonenumber :"); + String phone; + Scanner scn = new Scanner(System.in); + phone = scn.nextLine(); + int i = getPhoneNumbersInFile().indexOf(phone); + if(i != -1) { + System.out.println(getUserPassword().get(i)); + return; + } + else{ + System.out.println("Your phonenumber is not found, try phonenumber you were signed up"); + } + } public void editLineInFile(String lineToEdit, String newLine) { try { // Read the file From e0a05723a49b02c4140caba30e94b18ff9dac957 Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 16:16:13 +0330 Subject: [PATCH 22/47] Login for admins is added to project --- Answers/40230112081/Library.java | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index c27e556..d0b0505 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -99,6 +99,7 @@ public void add_normalUser(){ // sign-up just for normal users // login as admin user public void login_normalUsers(){ String phone, pass, id, user; + v = new Verifications(); Scanner scn = new Scanner(System.in); int flag; while(true){ @@ -133,6 +134,43 @@ else if (v.userUsernameValidator(user) && usersFileHandle.getUsernameInFile().co } } + public void login_AdminUsers(){ + String phone, pass, id, user; + v = new Verifications(); + Scanner scn = new Scanner(System.in); + int flag; + while(true){ + System.out.println("Enter your Username: (If you forget: type forget)"); + user = scn.nextLine(); + if(Objects.equals(user, "forget")) { + adminsFileHandle.show_myUsername(); + continue; + } + else if (v.userUsernameValidator(user) && adminsFileHandle.getUsernameInFile().contains(user)) { + flag = adminsFileHandle.getUsernameInFile().indexOf(user); + break; + } + else{ + System.out.println("Username not found/wrong format, try again"); + continue; + } + } + while (true){ + System.out.println("Enter your password :(if you forget , type forget)"); + pass = scn.nextLine(); + if(Objects.equals(pass,"forget")){ + adminsFileHandle.show_myPassword(); + continue; + } else if (v.userPasswordValidator(pass) && Objects.equals(pass, adminsFileHandle.getUserPassword().get(flag))) { + break; + } + else{ + System.out.println("Password not found/wrong format, try again"); + continue; + } + } + + } } From a1825d8ab82ec7381e088459eff8062c09d67163 Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 16:16:55 +0330 Subject: [PATCH 23/47] CLI making is started --- Answers/40230112081/MyApp.java | 42 ++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/Answers/40230112081/MyApp.java b/Answers/40230112081/MyApp.java index 3fd1a76..ba37f30 100644 --- a/Answers/40230112081/MyApp.java +++ b/Answers/40230112081/MyApp.java @@ -1,5 +1,43 @@ -public class MyApp { - public static void main(String[] args){ +import java.io.IOException; +import java.util.Objects; +import java.util.Scanner; +public class MyApp { + public static void main(String[] args) throws IOException, InterruptedException { + Library lib = new Library("Nit central library", "7a.m.to7p.m.",100); + Scanner scn = new Scanner(System.in); + String cmd; + while (true){ + System.out.print("\033[H\033[2J"); + System.out.println("***************************************************"); + System.out.println("Welcome to "+ lib.getLibName()); + System.out.println("Each commands start with lib : Example below."); + System.out.println("to add book : lib add etc. "); + System.out.println("to login : lib login"); + System.out.println("to sign up as normal user : lib signup"); + System.out.print(">>>"); + cmd = scn.nextLine(); + if(!cmd.contains("lib")){ + System.out.println("Wrong format, try again."); + } + else{ + if(Objects.equals(cmd, "lib signup")){ + System.out.print("\033[H\033[2J"); + lib.add_normalUser(); + } + else if (Objects.equals(cmd, "lib login")) { + System.out.print("\033[H\033[2J"); + System.out.println("Login as Admin / Normal user (type admin or normal):"); + System.out.print(">>>"); + cmd = scn.nextLine(); + if(Objects.equals(cmd, "admin") || Objects.equals(cmd,"Admin")){ + lib.login_AdminUsers(); + } + else{ + lib.login_normalUsers(); + } + } + } + } } } From f644c49dc21c5c14af5b42bbb630be3338f569f9 Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 16:18:10 +0330 Subject: [PATCH 24/47] Password is added to User class --- Answers/40230112081/User.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Answers/40230112081/User.java b/Answers/40230112081/User.java index 94f6a88..9a99419 100644 --- a/Answers/40230112081/User.java +++ b/Answers/40230112081/User.java @@ -3,14 +3,16 @@ public class User { private String userID; private String phonenumber; private String role; + private String password; // constructor - public User(String userName, String userId, String phoneNumber, String role) + public User(String userName, String userId, String phoneNumber, String role, String _pass) { this.role = role; this.phonenumber = phoneNumber; this.user_name = userName; this.userID = userId; + this.password = _pass; } // getters @@ -18,4 +20,5 @@ public User(String userName, String userId, String phoneNumber, String role) public String getUser_name() { return this.user_name; } public String getPhonenumber() { return this.phonenumber; } public String getRole() { return this.role; } + public String getPassword() { return this.password; } } From 6ec7f30d552b8a647485df16338e586588b99656 Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 23:09:32 +0330 Subject: [PATCH 25/47] In normal user panel, Edit user info is added --- Answers/40230112081/Library.java | 169 +++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index d0b0505..48ace23 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -1,5 +1,6 @@ import java.sql.SQLOutput; import java.util.ArrayList; +import java.util.Arrays; import java.util.Objects; import java.util.Scanner; @@ -132,6 +133,8 @@ else if (v.userUsernameValidator(user) && usersFileHandle.getUsernameInFile().co continue; } } + User u = new User(user,usersFileHandle.getIDInFile().get(flag),usersFileHandle.getPhoneNumbersInFile().get(flag),"normal",pass); + normalUserPanel(u); } public void login_AdminUsers(){ @@ -171,6 +174,172 @@ else if (v.userUsernameValidator(user) && adminsFileHandle.getUsernameInFile().c } } + public void show_helpMenuNormalUser(){ + String cmd; + Scanner scn = new Scanner(System.in); + System.out.println("to add a book to library : lib add title author description(nonSpace description & brief)"); + System.out.println("to Rent a book from library : lib rent your_id Book_title"); + System.out.println("to Edit your phonenumber : user edit ph current_ph new_ph"); + System.out.println("to Edit your username : user edit usr current_usr new_usr"); + System.out.println("to Edit your password : user edit pss current_pss new_pss"); + System.out.println("to Return a book : lib return book_title your_id"); + System.out.println("to logout& close : enter close/exit"); + System.out.println("to get back to your panel : Enter back"); + while (true){ + System.out.print(">>>"); + cmd = scn.nextLine(); + if(Objects.equals(cmd, "back") || Objects.equals(cmd, "Back")) + break; + else{ + System.out.println("Wrong input : Try again."); + } + } + } + public void normalUserPanel(User u){ + v = new Verifications(); + String cmd; + String p1,p2, u1,u2, ps1,ps2; + String query; + ArrayList list; + Scanner scn = new Scanner(System.in); + System.out.println("*******************************************************************"); + System.out.println("Welcome to your panel " + u.getUser_name() + " :"); + while (true) { + System.out.println("Print help to get help with your commands :(Normal user privileges)"); + System.out.print(">>>"); + cmd = scn.nextLine(); + if(Objects.equals(cmd, "help") || Objects.equals(cmd, "Help") || cmd.contains("help")){ + show_helpMenuNormalUser(); + } else if (Objects.equals(cmd ,"close") || Objects.equals(cmd, "exit")) { + break; + + } else if((cmd.contains("lib") || cmd.contains("user")) && (!cmd.contains(" ") || !cmd.contains("*"))){ + list = v.get_SectionsPanelQuery(cmd); + if(Objects.equals(list.get(1), "add")){ + // add book + } + else if(Objects.equals(list.get(1), "rent")){ + // rent a book + } + else if(Objects.equals(list.get(1), "edit")){ + // edit your info + if(Objects.equals(list.get(2), "ph")){ + // edit phonenumber + p1 = list.get(3); + p2 = list.get(4); + while(true){ + if(v.userPhonenumberValidator(p2)){ + break; + } + else{ + System.out.println("Enter valid username ."); + System.out.println("User phonenumber must start with any number instead of 0 with length 10"); + p2 = scn.nextLine(); + } + } + while (true){ + if(!usersFileHandle.getPhoneNumbersInFile().contains(p2)) + break; + else{ + System.out.println("This phonenumber is already taken . try another one"); + System.out.print(">>>"); + p2 = scn.nextLine(); + } + } + + int i = usersFileHandle.getPhoneNumbersInFile().indexOf(p1); + if(Objects.equals(p1, u.getPhonenumber())){ + query = usersFileHandle.getIDInFile().get(i)+","+ + usersFileHandle.getUsernameInFile().get(i)+","+p2+",normal,"+usersFileHandle.getUserPassword().get(i); + usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(i), query); + System.out.println("phonenumber has been updated"); + } + else{ + System.out.println("Repeat your command, your current username is not correct in input. "); + } + + } + else if(Objects.equals(list.get(2), "usr")){ + u1 = list.get(3); + u2 = list.get(4); + while(true){ + if(v.userUsernameValidator(u2)){ + break; + } + else{ + System.out.println("Enter valid username ."); + System.out.println("Username must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + u2 = scn.nextLine(); + } + } + while (true){ + if(!usersFileHandle.getUsernameInFile().contains(u2)) + break; + else{ + System.out.println("This username is already taken . try another one"); + System.out.print(">>>"); + u2 = scn.nextLine(); + } + } + int i = usersFileHandle.getUsernameInFile().indexOf(u1); + if(Objects.equals(u1, u.getUser_name())){ + query = usersFileHandle.getIDInFile().get(i)+","+ + u2+","+usersFileHandle.getPhoneNumbersInFile().get(i)+",normal,"+usersFileHandle.getUserPassword().get(i); + usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(i), query); + u.set_new_username(u2); + System.out.println("Your username has been updated"); + } + else{ + System.out.println("Repeat your command, your current username is not correct in input. "); + } + + } + else if(Objects.equals(list.get(2), "pss")){ + p1 = list.get(3); + p2 = list.get(4); + while (true){ + if(v.userPasswordValidator(p2)){ + break; + } + else{ + System.out.println("Wrong format, try another password."); + } + } + + if(!Objects.equals(p1, u.getPassword())){ + System.out.println("Try command again, current password is not correct."); + } + else{ + int i = usersFileHandle.getUserPassword().indexOf(p1); + query = usersFileHandle.getIDInFile().get(i)+"," + usersFileHandle.getUsernameInFile().get(i)+","+ + usersFileHandle.getPhoneNumbersInFile().get(i) + ",normal,"+p2; + usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(i), query); + System.out.println("Your password has been updated."); + } + + } + } + else if(Objects.equals(list.get(1), "return")){ + // return a book + + } + else{ + System.out.println("Wrong format :-|"); + } + + } + else{ + System.out.println("Wrong format, try again ."); + } + } + + + } + + public void adminUserPanel(){ + + } + } From a38068d7dd1a007ec6afe879d3306f0abdaa7d89 Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 10 May 2024 23:13:48 +0330 Subject: [PATCH 26/47] Feature : to increment existence of a book in library is added to book class --- Answers/40230112081/Book.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Answers/40230112081/Book.java b/Answers/40230112081/Book.java index 2616827..df05e3c 100644 --- a/Answers/40230112081/Book.java +++ b/Answers/40230112081/Book.java @@ -6,15 +6,17 @@ public class Book { private String author; private String description; private String status; + private int existence; // constructor - public Book(String id,String title,String author,String description,String status) + public Book(String id,String title,String author,String description,String status,int existence) { this.id = id; this.title = title; this.author = author; this.description = description; this.status = status; + this.existence = existence; } // getters @@ -23,9 +25,14 @@ public Book(String id,String title,String author,String description,String statu public String getAuthor() { return this.author; } public String getDescription() { return this.description; } public String getStatus() { return this.status; } + public int getExistence() { return this.existence; } // setter public void change_status(String new_stat) { this.status = new_stat; } + + public void inc_existence(){ + this.existence++; + } } From d8b327aebba2bd0521a11f7cc7c3c0fae6639fcc Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 11 May 2024 00:19:32 +0330 Subject: [PATCH 27/47] Feature add book by normal user is added --- Answers/40230112081/Library.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index 48ace23..56204cd 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -217,6 +217,29 @@ public void normalUserPanel(User u){ list = v.get_SectionsPanelQuery(cmd); if(Objects.equals(list.get(1), "add")){ // add book + String title, auth, desc; + title = list.get(2); + auth = list.get(3); + desc = list.get(4); + if(booksFileHandle.getAuthorsFromFileBook().contains(auth) && booksFileHandle.getTitlesFromFileBook().contains(title) && + booksFileHandle.getDescriptionsFromFileBook().contains(desc)){ + // inc existence + System.out.println("This book is added before."); + int i = booksFileHandle.getAuthorsFromFileBook().indexOf(auth); + String new_exst = String.valueOf(Integer.valueOf(booksFileHandle.getExistsFromFileBook().get(i))+1); + query = booksFileHandle.getIdFromFileBook().get(i) + "," +booksFileHandle.getTitlesFromFileBook().get(i)+","+ + booksFileHandle.getAuthorsFromFileBook()+","+booksFileHandle.getDescriptionsFromFileBook().get(i)+","+ + "available,"+new_exst; + booksFileHandle.editLineInFile(booksFileHandle.lines_of_file().get(i), query); + } + else{ + // add a new book + String id = String.valueOf(booksFileHandle.set_id()+1); + String existence = "1"; + query = id+","+title+","+auth+","+desc+","+"available,"+existence; + booksFileHandle.add_to_file(query); + System.out.println("Book is added successfully."); + } } else if(Objects.equals(list.get(1), "rent")){ // rent a book From 8feec383e09034cfeb6ddeb799da11bfb1fb2588 Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 11 May 2024 15:25:51 +0330 Subject: [PATCH 28/47] One issue came up and it is resolved now about IndexOutOfRange for string exception --- Answers/40230112081/myFileCLass.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index 0257dbc..2ea0494 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -251,8 +251,7 @@ public ArrayList getAuthorsFromFileBook(){ f1 = str.indexOf(","); f2 = str.indexOf(",", f1+1); f3 = str.indexOf(",", f2+1); - authors.add(str.substring(f2+1, f3)); - } + authors.add(str.substring(f2+1, f3));} return authors; } public ArrayList getDescriptionsFromFileBook(){ @@ -299,7 +298,7 @@ public ArrayList getExistsFromFileBook(){ f3 = str.indexOf(",", f2+1); f4 = str.indexOf(",", f3+1); f5 = str.indexOf(",", f4+1); - exists.add(str.substring(f5)); + exists.add(str.substring(f5+1)); } return exists; } From 4cbc003040f509ca0d430fc19c575d60185625ed Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 11 May 2024 16:31:05 +0330 Subject: [PATCH 29/47] Method to change status of book in rent mode in normal user panel is added --- Answers/40230112081/Rentals.txt | 0 Answers/40230112081/myFileCLass.java | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) delete mode 100644 Answers/40230112081/Rentals.txt diff --git a/Answers/40230112081/Rentals.txt b/Answers/40230112081/Rentals.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index 2ea0494..b5c0fcf 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -355,7 +355,25 @@ public ArrayList getRentalsBookID(){ return bookIds; } - + public void change_status_inFileRent(String _id){ // just for book & reduce existence for rent + int f = getIdFromFileBook().indexOf(_id); + String new_query; + String new_status; + if(Objects.equals(getStatsFromFileBook().get(f), "available")){ + new_status = "in-rent"; + } + else{ + System.out.println("Actually book is in rent, Access denied."); + return; + } + String t,a,d,e; + t = getTitlesFromFileBook().get(f); + a = getAuthorsFromFileBook().get(f); + d = getDescriptionsFromFileBook().get(f); + e = String.valueOf(Integer.valueOf(getExistsFromFileBook().get(f)) - 1); + new_query = _id + "," + t + "," + a + "," + d + "," + new_status + "," + e; + editLineInFile(lines_of_file().get(f), new_query); + } } From c658b483bc4bdb50826024e4e3e66ac42620fe6c Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 11 May 2024 16:32:10 +0330 Subject: [PATCH 30/47] Features to rent a book/show user profile/show available book are added --- Answers/40230112081/Library.java | 62 ++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index 56204cd..7ef943d 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -1,14 +1,16 @@ import java.sql.SQLOutput; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Objects; -import java.util.Scanner; +import java.util.*; +import java.text.SimpleDateFormat; +import java.text.Format; public class Library { private String libName; private int libCap; private String oprHours; + public Calendar cal; + public SimpleDateFormat simpleDate; + // repos & registries public myFileCLass usersFileHandle; public myFileCLass adminsFileHandle; @@ -183,6 +185,8 @@ public void show_helpMenuNormalUser(){ System.out.println("to Edit your username : user edit usr current_usr new_usr"); System.out.println("to Edit your password : user edit pss current_pss new_pss"); System.out.println("to Return a book : lib return book_title your_id"); + System.out.println("to Show available books :lib show books"); + System.out.println("to show your info/profile :user show profile"); System.out.println("to logout& close : enter close/exit"); System.out.println("to get back to your panel : Enter back"); while (true){ @@ -196,6 +200,9 @@ public void show_helpMenuNormalUser(){ } } public void normalUserPanel(User u){ + cal = Calendar.getInstance(); + simpleDate = new SimpleDateFormat("dd/MMMM/yyyy"); + String date = simpleDate.format(cal.getTime()); v = new Verifications(); String cmd; String p1,p2, u1,u2, ps1,ps2; @@ -228,7 +235,7 @@ public void normalUserPanel(User u){ int i = booksFileHandle.getAuthorsFromFileBook().indexOf(auth); String new_exst = String.valueOf(Integer.valueOf(booksFileHandle.getExistsFromFileBook().get(i))+1); query = booksFileHandle.getIdFromFileBook().get(i) + "," +booksFileHandle.getTitlesFromFileBook().get(i)+","+ - booksFileHandle.getAuthorsFromFileBook()+","+booksFileHandle.getDescriptionsFromFileBook().get(i)+","+ + booksFileHandle.getAuthorsFromFileBook().get(i)+","+booksFileHandle.getDescriptionsFromFileBook().get(i)+","+ "available,"+new_exst; booksFileHandle.editLineInFile(booksFileHandle.lines_of_file().get(i), query); } @@ -242,7 +249,33 @@ public void normalUserPanel(User u){ } } else if(Objects.equals(list.get(1), "rent")){ - // rent a book + // availability + // reduce in existence + // add to rentals + // rent : date,userID,bookID + String title = list.get(3); + String user_ID = list.get(2); + int i = booksFileHandle.getTitlesFromFileBook().indexOf(title); + if(i != -1){ + if(Objects.equals(booksFileHandle.getStatsFromFileBook().get(i), "in-rent")){ + System.out.println("this book "+title+" is actually in rent try another books."); + System.out.println("To show available books try show books command."); + } + else{ + if(usersFileHandle.getIDInFile().contains(user_ID)){ + query = date + "," + user_ID + "," + booksFileHandle.getIdFromFileBook().get(i); + booksFileHandle.change_status_inFileRent(booksFileHandle.getIdFromFileBook().get(i)); + rentalFileHandle.add_to_file(query); + } + else{ + System.out.println("Wrong ID, there is no id in repository like that. :-|"); + } + } + } + else{ + System.out.println("This book with this title is not available in book repository. :-|"); + System.out.println("Try command with appropriate query. :-)"); + } } else if(Objects.equals(list.get(1), "edit")){ // edit your info @@ -346,6 +379,23 @@ else if(Objects.equals(list.get(1), "return")){ // return a book } + else if(Objects.equals(list.get(1), "show")){ + if(Objects.equals(list.get(2), "profile") || Objects.equals(list.get(2), "Profile")){ + System.out.println("User_id : " + u.getUserID()); + System.out.println("User_name : "+u.getUser_name()); + System.out.println("User_phone : "+u.getPhonenumber()); + System.out.println("Access level : "+u.getRole()); + } + else{ + for(String status : booksFileHandle.getStatsFromFileBook()){ + if(Objects.equals(status, "available")){ + int f = booksFileHandle.getStatsFromFileBook().indexOf(status); + System.out.println(booksFileHandle.getTitlesFromFileBook().get(f)); + } + } + } + } + else{ System.out.println("Wrong format :-|"); } From f311bc1d84056a88bcb34ac5155492c3c425196f Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 11 May 2024 18:32:43 +0330 Subject: [PATCH 31/47] book status issues about rent access for normal user is resolved --- Answers/40230112081/myFileCLass.java | 30 +++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index b5c0fcf..c5a5a75 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -358,21 +358,19 @@ public ArrayList getRentalsBookID(){ public void change_status_inFileRent(String _id){ // just for book & reduce existence for rent int f = getIdFromFileBook().indexOf(_id); String new_query; - String new_status; - if(Objects.equals(getStatsFromFileBook().get(f), "available")){ - new_status = "in-rent"; + int currentExistence = Integer.valueOf(getExistsFromFileBook().get(f)); + if(currentExistence > 1){ + currentExistence--; + new_query = _id + "," + getTitlesFromFileBook().get(f) + "," + getAuthorsFromFileBook().get(f)+ + "," + getDescriptionsFromFileBook().get(f) + "," + "available," + String.valueOf(currentExistence); + editLineInFile(lines_of_file().get(f), new_query); } - else{ - System.out.println("Actually book is in rent, Access denied."); - return; + else { + currentExistence--; + new_query = _id + "," + getTitlesFromFileBook().get(f) + "," + getAuthorsFromFileBook().get(f)+ + "," + getDescriptionsFromFileBook().get(f) + "," + "in-rent," + String.valueOf(currentExistence); + editLineInFile(lines_of_file().get(f), new_query); } - String t,a,d,e; - t = getTitlesFromFileBook().get(f); - a = getAuthorsFromFileBook().get(f); - d = getDescriptionsFromFileBook().get(f); - e = String.valueOf(Integer.valueOf(getExistsFromFileBook().get(f)) - 1); - new_query = _id + "," + t + "," + a + "," + d + "," + new_status + "," + e; - editLineInFile(lines_of_file().get(f), new_query); } @@ -382,4 +380,8 @@ public void change_status_inFileRent(String _id){ // just for book & reduce exis // user : id,username,phonenumber,role,password // book : id,title,author,description,status,existence -// rent : date,userID,bookID \ No newline at end of file +// rent : date,userID,bookID + +/* +int f = booksFileHandle.getStatsFromFileBook().indexOf(status); + */ \ No newline at end of file From a8b4be6ccc3e0e567b193a6005f3adcadd0f113e Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 11 May 2024 18:33:25 +0330 Subject: [PATCH 32/47] Rent access is modified for normal user --- Answers/40230112081/Library.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index 7ef943d..094869f 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -180,7 +180,7 @@ public void show_helpMenuNormalUser(){ String cmd; Scanner scn = new Scanner(System.in); System.out.println("to add a book to library : lib add title author description(nonSpace description & brief)"); - System.out.println("to Rent a book from library : lib rent your_id Book_title"); + System.out.println("to Rent a book from library : lib rent your_id Book_id"); System.out.println("to Edit your phonenumber : user edit ph current_ph new_ph"); System.out.println("to Edit your username : user edit usr current_usr new_usr"); System.out.println("to Edit your password : user edit pss current_pss new_pss"); @@ -253,12 +253,12 @@ else if(Objects.equals(list.get(1), "rent")){ // reduce in existence // add to rentals // rent : date,userID,bookID - String title = list.get(3); + String id = list.get(3); String user_ID = list.get(2); - int i = booksFileHandle.getTitlesFromFileBook().indexOf(title); + int i = booksFileHandle.getIdFromFileBook().indexOf(id); if(i != -1){ if(Objects.equals(booksFileHandle.getStatsFromFileBook().get(i), "in-rent")){ - System.out.println("this book "+title+" is actually in rent try another books."); + System.out.println("this book "+id+" is actually in rent try another books."); System.out.println("To show available books try show books command."); } else{ @@ -387,10 +387,9 @@ else if(Objects.equals(list.get(1), "show")){ System.out.println("Access level : "+u.getRole()); } else{ - for(String status : booksFileHandle.getStatsFromFileBook()){ - if(Objects.equals(status, "available")){ - int f = booksFileHandle.getStatsFromFileBook().indexOf(status); - System.out.println(booksFileHandle.getTitlesFromFileBook().get(f)); + for(int i = 0;i < booksFileHandle.getStatsFromFileBook().size();i++){ + if(Objects.equals(booksFileHandle.getStatsFromFileBook().get(i),"available")){ + System.out.println(booksFileHandle.getTitlesFromFileBook().get(i)); } } } From 7ddde987c4ed2439995aadc88052ce0b4eda34ea Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 11 May 2024 19:07:42 +0330 Subject: [PATCH 33/47] Library works based on its operation time --- Answers/40230112081/Library.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index 094869f..aa7fe57 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -139,6 +139,25 @@ else if (v.userUsernameValidator(user) && usersFileHandle.getUsernameInFile().co normalUserPanel(u); } + public boolean isLibOpen(){ + String[] hoursParts = this.oprHours.split("-"); + cal = Calendar.getInstance(); + simpleDate = new SimpleDateFormat("hh:mm"); + String date = simpleDate.format(cal.getTime()); + char c = hoursParts[1].charAt(0); + int vclose = Integer.valueOf(c) - Integer.valueOf('0'); + int close = vclose + 12; + char s = hoursParts[0].charAt(0); + int vopen =Integer.valueOf(s) - Integer.valueOf('0'); + int start = vopen; + String[] current = date.split(":"); + if(Integer.valueOf(current[0]) >= start && Integer.valueOf(current[0]) < close){ + return true; + } + + + return false; + } public void login_AdminUsers(){ String phone, pass, id, user; v = new Verifications(); @@ -389,7 +408,8 @@ else if(Objects.equals(list.get(1), "show")){ else{ for(int i = 0;i < booksFileHandle.getStatsFromFileBook().size();i++){ if(Objects.equals(booksFileHandle.getStatsFromFileBook().get(i),"available")){ - System.out.println(booksFileHandle.getTitlesFromFileBook().get(i)); + System.out.println(booksFileHandle.getIdFromFileBook().get(i)+ + ", "+booksFileHandle.getTitlesFromFileBook().get(i)); } } } From 3baedcc90f42a661137bb421514972ed2a999c29 Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 11 May 2024 21:36:10 +0330 Subject: [PATCH 34/47] show avalable books is updated --- Answers/40230112081/Library.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index aa7fe57..a1ceaf2 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -203,7 +203,7 @@ public void show_helpMenuNormalUser(){ System.out.println("to Edit your phonenumber : user edit ph current_ph new_ph"); System.out.println("to Edit your username : user edit usr current_usr new_usr"); System.out.println("to Edit your password : user edit pss current_pss new_pss"); - System.out.println("to Return a book : lib return book_title your_id"); + System.out.println("to Return a book : lib return book_id your_id"); System.out.println("to Show available books :lib show books"); System.out.println("to show your info/profile :user show profile"); System.out.println("to logout& close : enter close/exit"); @@ -395,7 +395,16 @@ else if(Objects.equals(list.get(2), "pss")){ } } else if(Objects.equals(list.get(1), "return")){ - // return a book + // lib return book_title your_id + String bookId = list.get(2), user_id = list.get(3); + // edit booksFile : repository // change status if 0 existence or increment existence + // edit rentals + if(rentalFileHandle.getRentalsUserID().contains(user_id) && rentalFileHandle.getRentalsBookID().contains(bookId)){ + + }else{ + System.out.println("No such rental details are available. :-|"); + } + } else if(Objects.equals(list.get(1), "show")){ @@ -409,7 +418,7 @@ else if(Objects.equals(list.get(1), "show")){ for(int i = 0;i < booksFileHandle.getStatsFromFileBook().size();i++){ if(Objects.equals(booksFileHandle.getStatsFromFileBook().get(i),"available")){ System.out.println(booksFileHandle.getIdFromFileBook().get(i)+ - ", "+booksFileHandle.getTitlesFromFileBook().get(i)); + ", "+booksFileHandle.getTitlesFromFileBook().get(i)+" exst : " + booksFileHandle.getExistsFromFileBook().get(i)); } } } From b99984ae1d60a0784396d0ac5f48bc6a047b7076 Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 11 May 2024 21:45:41 +0330 Subject: [PATCH 35/47] Feature to change status of a book in return case for normal users --- Answers/40230112081/myFileCLass.java | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index c5a5a75..7b42434 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -355,24 +355,42 @@ public ArrayList getRentalsBookID(){ return bookIds; } - public void change_status_inFileRent(String _id){ // just for book & reduce existence for rent - int f = getIdFromFileBook().indexOf(_id); + public void change_status_inFileRent(String book_id){ // just for book & reduce existence for rent + int f = getIdFromFileBook().indexOf(book_id); String new_query; int currentExistence = Integer.valueOf(getExistsFromFileBook().get(f)); if(currentExistence > 1){ currentExistence--; - new_query = _id + "," + getTitlesFromFileBook().get(f) + "," + getAuthorsFromFileBook().get(f)+ + new_query = book_id + "," + getTitlesFromFileBook().get(f) + "," + getAuthorsFromFileBook().get(f)+ "," + getDescriptionsFromFileBook().get(f) + "," + "available," + String.valueOf(currentExistence); editLineInFile(lines_of_file().get(f), new_query); } else { currentExistence--; - new_query = _id + "," + getTitlesFromFileBook().get(f) + "," + getAuthorsFromFileBook().get(f)+ + new_query = book_id+ "," + getTitlesFromFileBook().get(f) + "," + getAuthorsFromFileBook().get(f)+ "," + getDescriptionsFromFileBook().get(f) + "," + "in-rent," + String.valueOf(currentExistence); editLineInFile(lines_of_file().get(f), new_query); } } + public void change_status_inFileReturnCase(String book_id){ + int f = getIdFromFileBook().indexOf(book_id); + String new_query; + int currentExistence = Integer.valueOf(getExistsFromFileBook().get(f)); + if(currentExistence > 0){ + currentExistence++; + new_query = book_id + "," + getTitlesFromFileBook().get(f) + "," + getAuthorsFromFileBook().get(f)+ + "," + getDescriptionsFromFileBook().get(f) + "," + "available," + String.valueOf(currentExistence); + editLineInFile(lines_of_file().get(f), new_query); + } + else if(currentExistence == 0){ + currentExistence++; + new_query = book_id+","+ getTitlesFromFileBook().get(f) + "," + getAuthorsFromFileBook().get(f)+ + "," + getDescriptionsFromFileBook().get(f) + "," + "available," + String.valueOf(currentExistence); + editLineInFile(lines_of_file().get(f), new_query); + } + } + } From 83f965afef13858e04fa05a8e75b69a003be56de Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 11 May 2024 21:46:43 +0330 Subject: [PATCH 36/47] Feature, return a book to library is added for normaluser panel --- Answers/40230112081/Library.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index a1ceaf2..4e3ea0d 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -396,10 +396,16 @@ else if(Objects.equals(list.get(2), "pss")){ } else if(Objects.equals(list.get(1), "return")){ // lib return book_title your_id + int flag; String bookId = list.get(2), user_id = list.get(3); // edit booksFile : repository // change status if 0 existence or increment existence // edit rentals if(rentalFileHandle.getRentalsUserID().contains(user_id) && rentalFileHandle.getRentalsBookID().contains(bookId)){ + flag = rentalFileHandle.getRentalsUserID().indexOf(user_id); + String new_query = ""; + String line = rentalFileHandle.lines_of_file().get(flag); + rentalFileHandle.editLineInFile(line, new_query); + booksFileHandle.change_status_inFileReturnCase(bookId); }else{ System.out.println("No such rental details are available. :-|"); From d8f990ea9c532f4fc34c18db642ee332da2ebd37 Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 11 May 2024 23:16:18 +0330 Subject: [PATCH 37/47] Admin panel help menu is added to project --- Answers/40230112081/Library.java | 46 +++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index 4e3ea0d..1023deb 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -193,6 +193,9 @@ else if (v.userUsernameValidator(user) && adminsFileHandle.getUsernameInFile().c continue; } } + User u = new User(user, adminsFileHandle.getIDInFile().get(flag), adminsFileHandle.getPhoneNumbersInFile().get(flag) + , "admin", pass); + adminUserPanel(u); } public void show_helpMenuNormalUser(){ @@ -218,6 +221,31 @@ public void show_helpMenuNormalUser(){ } } } + public void show_helpMenuAdmins(){ + Scanner scn = new Scanner(System.in); + String cmd; + System.out.println("to add book : lib add book_title book_author book_desc"); + System.out.println("to remove user : lib remove user_id user_name user_phone"); + System.out.println("to remove book : lib remove book_title book_author book_desc"); + System.out.println("to remove rent : lib remove rent_date user_id book_id"); + System.out.println("to promote normal user : user promote user_id user_name user_phone"); + System.out.println("to show user : user show user_id"); + System.out.println("to show books : lib show books (-A : all books , -E : only available books , -R : in-rent books)"); + System.out.println("to show rents : lib show rents"); + System.out.println("to exit your panel : enter panel"); + System.out.println("***Attention*** : avoid to enter space more than one , avoid to enter any character, Each command must be space separated"); + System.out.println("for entering space in each field : use underline character '_' "); + System.out.println("to back to your panel from this menu : just enter back"); + while (true){ + cmd = scn.nextLine(); + if (Objects.equals(cmd, "back")){ + break; + } + else{ + System.out.println("Just enter back. :-|"); + } + } + } public void normalUserPanel(User u){ cal = Calendar.getInstance(); simpleDate = new SimpleDateFormat("dd/MMMM/yyyy"); @@ -230,6 +258,7 @@ public void normalUserPanel(User u){ Scanner scn = new Scanner(System.in); System.out.println("*******************************************************************"); System.out.println("Welcome to your panel " + u.getUser_name() + " :"); + System.out.println("Library is open in :" + this.oprHours); while (true) { System.out.println("Print help to get help with your commands :(Normal user privileges)"); System.out.print(">>>"); @@ -443,7 +472,22 @@ else if(Objects.equals(list.get(1), "show")){ } - public void adminUserPanel(){ + public void adminUserPanel(User u){ + System.out.println("Welcome " + u.getUser_name()); + System.out.println("This is your admin panel."); + String cmd; + v = new Verifications(); + Scanner scn = new Scanner(System.in); + int flag; + while (true){ + System.out.println("Enter command (With Space ,Just one space, Please avoid to enter extra characters)"); + System.out.println("Enter help to "); + System.out.print(">>>"); + cmd = scn.nextLine(); + if(Objects.equals(cmd, "help") || Objects.equals(cmd, "Help")){ + show_helpMenuAdmins(); + } + } } From 3e39c46d6d1d3679a25f14195233d6039bd2e0a0 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 12 May 2024 13:45:23 +0330 Subject: [PATCH 38/47] Method to show books for admin users, is added to project --- Answers/40230112081/myFileCLass.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index 7b42434..7430ee8 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -391,6 +391,34 @@ else if(currentExistence == 0){ } } + public void show_booksFile(String type){ + int flag; + if(Objects.equals(type, "-A")){ + for(String line : lines_of_file()){ + System.out.println(line); + } + } + else if(Objects.equals(type, "-E")){ // existed books + for(String line : getStatsFromFileBook()){ + if(Objects.equals(line, "available")){ + flag = getStatsFromFileBook().indexOf(line); + System.out.println(lines_of_file().get(flag)); + } + } + } + else if(Objects.equals(type, "-R")){ // existed books + for(String line : getStatsFromFileBook()){ + if(Objects.equals(line, "in-rent")){ + flag = getStatsFromFileBook().indexOf(line); + System.out.println(lines_of_file().get(flag)); + } + } + } + else{ + System.out.println("Nothing to show. :-| "); + } + + } } From 671dc707ba71c264145a14ca51e4d07e1aa40d87 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 12 May 2024 13:49:18 +0330 Subject: [PATCH 39/47] Feature: show books & rentals & users is available for admins --- Answers/40230112081/Library.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index 1023deb..fab7540 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -475,10 +475,12 @@ else if(Objects.equals(list.get(1), "show")){ public void adminUserPanel(User u){ System.out.println("Welcome " + u.getUser_name()); System.out.println("This is your admin panel."); + ArrayList list = new ArrayList<>(); String cmd; v = new Verifications(); Scanner scn = new Scanner(System.in); int flag; + String type; while (true){ System.out.println("Enter command (With Space ,Just one space, Please avoid to enter extra characters)"); System.out.println("Enter help to "); @@ -487,6 +489,34 @@ public void adminUserPanel(User u){ if(Objects.equals(cmd, "help") || Objects.equals(cmd, "Help")){ show_helpMenuAdmins(); } + else if((cmd.contains("lib") || cmd.contains("user")) && (!cmd.contains(" ") || !cmd.contains("*"))){ + list = v.get_SectionsPanelQuery(cmd); + if(Objects.equals(list.get(1), "show") || Objects.equals(list.get(1), "Show")){ + if(Objects.equals(list.get(2), "books")){ + type = list.get(3); + booksFileHandle.show_booksFile(type); + } + else if(Objects.equals(list.get(2), "users")){ + for(String line : usersFileHandle.lines_of_file()){ + System.out.println(line); + } + } + else if(Objects.equals(list.get(2), "rents")){ + for(String line : usersFileHandle.lines_of_file()){ + System.out.println(line); + } + } + else{ + System.out.println("Try command in correct way."); + } + } + } + else if(Objects.equals(cmd, "exit")){ + break; + } + else{ + System.out.println("wrong command. try again :-|"); + } } } From cfa652bd4437528929c808f708ff134693f05492 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 12 May 2024 14:02:39 +0330 Subject: [PATCH 40/47] One issue in rent for normal users is resolved, about similarity of userID and bookID --- Answers/40230112081/Library.java | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index fab7540..c4e4919 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -304,19 +304,28 @@ else if(Objects.equals(list.get(1), "rent")){ String id = list.get(3); String user_ID = list.get(2); int i = booksFileHandle.getIdFromFileBook().indexOf(id); + int f; if(i != -1){ - if(Objects.equals(booksFileHandle.getStatsFromFileBook().get(i), "in-rent")){ - System.out.println("this book "+id+" is actually in rent try another books."); - System.out.println("To show available books try show books command."); - } - else{ - if(usersFileHandle.getIDInFile().contains(user_ID)){ - query = date + "," + user_ID + "," + booksFileHandle.getIdFromFileBook().get(i); - booksFileHandle.change_status_inFileRent(booksFileHandle.getIdFromFileBook().get(i)); - rentalFileHandle.add_to_file(query); + if(rentalFileHandle.getRentalsUserID().contains(user_ID)){ + f = rentalFileHandle.getRentalsUserID().indexOf(user_ID); + if(!Objects.equals(rentalFileHandle.getRentalsBookID().get(f), id)){ + if(Objects.equals(booksFileHandle.getStatsFromFileBook().get(i), "in-rent")){ + System.out.println("this book "+id+" is actually in rent try another books."); + System.out.println("To show available books try show books command."); + } + else{ + if(usersFileHandle.getIDInFile().contains(user_ID)){ + query = date + "," + user_ID + "," + booksFileHandle.getIdFromFileBook().get(i); + booksFileHandle.change_status_inFileRent(booksFileHandle.getIdFromFileBook().get(i)); + rentalFileHandle.add_to_file(query); + } + else{ + System.out.println("Wrong ID, there is no id in repository like that. :-|"); + } + } } else{ - System.out.println("Wrong ID, there is no id in repository like that. :-|"); + System.out.println("there is rent just like the rent, try another book."); } } } @@ -502,7 +511,7 @@ else if(Objects.equals(list.get(2), "users")){ } } else if(Objects.equals(list.get(2), "rents")){ - for(String line : usersFileHandle.lines_of_file()){ + for(String line : rentalFileHandle.lines_of_file()){ System.out.println(line); } } From 0303d356bdfece3e3506198337ba290392147e12 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 12 May 2024 16:02:50 +0330 Subject: [PATCH 41/47] method to remove empty line of file is added to project --- Answers/40230112081/myFileCLass.java | 54 ++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index 7430ee8..62adde8 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -97,12 +97,12 @@ public void editLineInFile(String lineToEdit, String newLine) { BufferedReader reader = new BufferedReader(new FileReader(f)); String line; StringBuilder fileContent = new StringBuilder(); - + //ArrayList file_content = new ArrayList<>(); // Read each line and replace if it matches while ((line = reader.readLine()) != null) { if (line.equals(lineToEdit)) { fileContent.append(newLine).append("\n"); - } else { + } else if(!line.equals(lineToEdit)){ fileContent.append(line).append("\n"); } } @@ -115,6 +115,7 @@ public void editLineInFile(String lineToEdit, String newLine) { } catch (IOException e) { e.printStackTrace(); } + deleteEmptyLine(); } public int set_id(){ @@ -399,18 +400,16 @@ public void show_booksFile(String type){ } } else if(Objects.equals(type, "-E")){ // existed books - for(String line : getStatsFromFileBook()){ - if(Objects.equals(line, "available")){ - flag = getStatsFromFileBook().indexOf(line); - System.out.println(lines_of_file().get(flag)); + for(int i = 0;i < getStatsFromFileBook().size();i++){ + if(Objects.equals(getStatsFromFileBook().get(i), "available")){ + System.out.println(lines_of_file().get(i)); } } } else if(Objects.equals(type, "-R")){ // existed books - for(String line : getStatsFromFileBook()){ - if(Objects.equals(line, "in-rent")){ - flag = getStatsFromFileBook().indexOf(line); - System.out.println(lines_of_file().get(flag)); + for(int i = 0;i < getStatsFromFileBook().size();i++){ + if(Objects.equals(getStatsFromFileBook().get(i), "in-rent")){ + System.out.println(lines_of_file().get(i)); } } } @@ -420,6 +419,41 @@ else if(Objects.equals(type, "-R")){ // existed books } + public void deleteEmptyLine(){ + File temp; + String line; + try { + f = new File(dir); + temp = new File("temp.txt"); + + BufferedReader reader = new BufferedReader(new FileReader(f)); + BufferedWriter writer = new BufferedWriter(new FileWriter(temp)); + while((line = reader.readLine()) != null){ + if(!line.trim().isEmpty()){ + writer.write(line); + writer.newLine(); + } + } + reader.close(); + writer.close(); + + if(!f.delete()){ + System.out.println("Could not to delete"); + return; + } + if(temp.renameTo(f)){ + //System.out.println("Could not to rename"); + return; + } + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + } From 6055daf4747d16f329ad62fe6980605ad4a4e54d Mon Sep 17 00:00:00 2001 From: Amir Date: Mon, 13 May 2024 11:00:10 +0330 Subject: [PATCH 42/47] Normal user panel & Admin panel have been updated, with correct prompts and try/catch to avoidincorrect way of appling commands --- Answers/40230112081/Library.java | 927 +++++++++++++++++++++++-------- 1 file changed, 686 insertions(+), 241 deletions(-) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index c4e4919..c8a1841 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -1,3 +1,6 @@ +import org.w3c.dom.ls.LSOutput; + +import java.io.ObjectStreamException; import java.sql.SQLOutput; import java.util.*; import java.text.SimpleDateFormat; @@ -37,6 +40,90 @@ public Library(String name, String duration, int cap){ public int getLibCap() { return this.libCap; } public String getOprHours() { return this.oprHours; } + public void adminEditPanel(User u){ + String query; + String id, u_name, u_phone, pass; + id = u.getUserID(); + u_name = u.getUser_name(); + Scanner scn = new Scanner(System.in); + u_phone = u.getPhonenumber(); + pass = u.getPassword(); + String cmd; + v = new Verifications(); + int flag = adminsFileHandle.getUsernameInFile().indexOf(u_name); + System.out.println("1. Username"); + System.out.println("2. Phonenumber"); + System.out.println("3. Password"); + while (true){ + System.out.println("choose to edit :"); + System.out.print(">>>"); + cmd = scn.nextLine(); + if(Objects.equals(cmd, "Username") || Objects.equals(cmd, "1") || Objects.equals(cmd, "user") || Objects.equals(cmd, "usr")){ + while(true){ + System.out.println("Enter your new username :"); + System.out.print(">>>"); + u_name = scn.nextLine(); + if(v.userUsernameValidator(u_name)){ + if(!adminsFileHandle.getUsernameInFile().contains(u_name)) + break; + else{ + System.out.println("This username is already taken"); + }; + } + else{ + System.out.println("Wrong format. try another :-|"); + System.out.println("Username must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + } + } + + + query = u.getUserID()+","+u_name+","+u.getPhonenumber()+","+"admin"+","+u.getPassword(); + adminsFileHandle.editLineInFile(adminsFileHandle.lines_of_file().get(flag), query); + break; + } + else if(Objects.equals(cmd, "Phonenumber") || Objects.equals(cmd, "2") || Objects.equals(cmd, "phone") || Objects.equals(cmd, "ph")){ + while(true){ + System.out.println("Enter your new phonenumber :"); + System.out.print(">>>"); + u_phone = scn.nextLine(); + if(v.userPhonenumberValidator(u_phone)){ + if(!adminsFileHandle.getPhoneNumbersInFile().contains(u_phone)) + break; + else{ + System.out.println("This phonenumber is already taken"); + }; + } + else{ + System.out.println("Wrong format. try another :-|"); + System.out.println("User phonenumber must start with any number instead of 0 with length 10"); + } + } + query = u.getUserID()+","+u.getUser_name()+","+u_phone+","+"admin"+","+u.getPassword(); + adminsFileHandle.editLineInFile(adminsFileHandle.lines_of_file().get(flag), query); + break; + } + else if(Objects.equals(cmd, "Password") || Objects.equals(cmd, "3") || Objects.equals(cmd, "pass") || Objects.equals(cmd, "pss")){ + while(true){ + System.out.println("Enter your new password :"); + System.out.print(">>>"); + pass = scn.nextLine(); + if(v.userPasswordValidator(pass)){ + break; + } + else{ + System.out.println("Wrong format. try another :-|"); + System.out.println("Password must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + } + } + query = u.getUserID()+","+u.getUser_name()+","+u.getPhonenumber()+","+"admin"+","+pass; + adminsFileHandle.editLineInFile(adminsFileHandle.lines_of_file().get(flag), query); + break; + } + else{ + System.out.println("Wrong input"); + } + } + } public void add_normalUser(){ // sign-up just for normal users String id, username, pass, phonenumber; @@ -49,52 +136,61 @@ public void add_normalUser(){ // sign-up just for normal users System.out.println("Your id must be numerical with length between 10 and 15"); while (true){ id = scn.nextLine(); - if(v.userIdValidator(id)) - break; + if(v.userIdValidator(id)){ + if(!usersFileHandle.getIDInFile().contains(id) && !adminsFileHandle.getIDInFile().contains(id)){ + break; + } + else{ + System.out.println("This id is added to repository"); + } + } else{ - System.out.println("Wrong format, try again."); + System.out.println("Try again"); } } - System.out.println("Enter username :"); - System.out.println("Username must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + + System.out.println("Enter user name"); while (true){ username = scn.nextLine(); if(v.userUsernameValidator(username)){ - break; + if(!usersFileHandle.getUsernameInFile().contains(username) && !adminsFileHandle.getUsernameInFile().contains(username)){ + break; + } + else{ + System.out.println("This username is already taken"); + } } else{ - System.out.println("Wrong format, try again."); + System.out.println("Wrong format"); } } - System.out.println("Enter a phonenumber :"); - System.out.println("User phonenumber must start with any number instead of 0 with length 10"); + + System.out.println("Enter a phonenumber"); while (true){ - phonenumber = scn1.nextLine(); + phonenumber = scn.nextLine(); if(v.userPhonenumberValidator(phonenumber)){ - break; + if(!usersFileHandle.getPhoneNumbersInFile().contains(phonenumber)){ + break; + } + else{ + System.out.println("this number is added before"); + } } else{ - System.out.println("Wrong Format, Try again."); + System.out.println("Wrong format."); } } - // now to check file - if(usersFileHandle.getUsernameInFile().contains(username) || usersFileHandle.getIDInFile().contains(id) - || usersFileHandle.getPhoneNumbersInFile().contains(phonenumber)){ - System.out.println("Sorry, We found your id/username/phonenumber , Please goto login panel"); - return; - } - System.out.println("Set a password for yourself :"); - System.out.println("Password must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + System.out.println("Set a password"); while (true){ pass = scn.nextLine(); if(v.userPasswordValidator(pass)){ break; } else{ - System.out.println("Wrong Format, Try Again."); + System.out.println("Wrong format"); } } - u = new User(username, id, phonenumber,"normal", pass); + u = new User(username, id, phonenumber, "normal", pass); usersFileHandle.addUser(u); } @@ -105,38 +201,43 @@ public void login_normalUsers(){ v = new Verifications(); Scanner scn = new Scanner(System.in); int flag; - while(true){ - System.out.println("Enter your Username: (If you forget: type forget)"); - user = scn.nextLine(); - if(Objects.equals(user, "forget")) { - usersFileHandle.show_myUsername(); - continue; - } - else if (v.userUsernameValidator(user) && usersFileHandle.getUsernameInFile().contains(user)) { - flag = usersFileHandle.getUsernameInFile().indexOf(user); - break; + if(usersFileHandle.lines_of_file().size() != 0){ + while(true){ + System.out.println("Enter your Username: (If you forget: type forget)"); + user = scn.nextLine(); + if(Objects.equals(user, "forget")) { + usersFileHandle.show_myUsername(); + continue; + } + else if (v.userUsernameValidator(user) && usersFileHandle.getUsernameInFile().contains(user)) { + flag = usersFileHandle.getUsernameInFile().indexOf(user); + break; + } + else{ + System.out.println("Username not found/wrong format, try again"); + continue; + } } - else{ - System.out.println("Username not found/wrong format, try again"); - continue; + while (true){ + System.out.println("Enter your password :(if you forget , type forget)"); + pass = scn.nextLine(); + if(Objects.equals(pass,"forget")){ + usersFileHandle.show_myPassword(); + continue; + } else if (v.userPasswordValidator(pass) && Objects.equals(pass, usersFileHandle.getUserPassword().get(flag))) { + break; + } + else{ + System.out.println("Password not found/wrong format, try again"); + continue; + } } + User u = new User(user,usersFileHandle.getIDInFile().get(flag),usersFileHandle.getPhoneNumbersInFile().get(flag),"normal",pass); + normalUserPanel(u); } - while (true){ - System.out.println("Enter your password :(if you forget , type forget)"); - pass = scn.nextLine(); - if(Objects.equals(pass,"forget")){ - usersFileHandle.show_myPassword(); - continue; - } else if (v.userPasswordValidator(pass) && Objects.equals(pass, usersFileHandle.getUserPassword().get(flag))) { - break; - } - else{ - System.out.println("Password not found/wrong format, try again"); - continue; - } + else{ + System.out.println("There is no normal user in our repository, First sign up please. Thank you. :-)"); } - User u = new User(user,usersFileHandle.getIDInFile().get(flag),usersFileHandle.getPhoneNumbersInFile().get(flag),"normal",pass); - normalUserPanel(u); } public boolean isLibOpen(){ @@ -163,39 +264,44 @@ public void login_AdminUsers(){ v = new Verifications(); Scanner scn = new Scanner(System.in); int flag; - while(true){ - System.out.println("Enter your Username: (If you forget: type forget)"); - user = scn.nextLine(); - if(Objects.equals(user, "forget")) { - adminsFileHandle.show_myUsername(); - continue; - } - else if (v.userUsernameValidator(user) && adminsFileHandle.getUsernameInFile().contains(user)) { - flag = adminsFileHandle.getUsernameInFile().indexOf(user); - break; + if(adminsFileHandle.lines_of_file().size() != 0){ + while(true){ + System.out.println("Enter your Username: (If you forget: type forget)"); + user = scn.nextLine(); + if(Objects.equals(user, "forget")) { + adminsFileHandle.show_myUsername(); + continue; + } + else if (v.userUsernameValidator(user) && adminsFileHandle.getUsernameInFile().contains(user)) { + flag = adminsFileHandle.getUsernameInFile().indexOf(user); + break; + } + else{ + System.out.println("Username not found/wrong format, try again"); + continue; + } } - else{ - System.out.println("Username not found/wrong format, try again"); - continue; + while (true){ + System.out.println("Enter your password :(if you forget , type forget)"); + pass = scn.nextLine(); + if(Objects.equals(pass,"forget")){ + adminsFileHandle.show_myPassword(); + continue; + } else if (v.userPasswordValidator(pass) && Objects.equals(pass, adminsFileHandle.getUserPassword().get(flag))) { + break; + } + else{ + System.out.println("Password not found/wrong format, try again"); + continue; + } } + User u = new User(user, adminsFileHandle.getIDInFile().get(flag), adminsFileHandle.getPhoneNumbersInFile().get(flag) + , "admin", pass); + adminUserPanel(u); } - while (true){ - System.out.println("Enter your password :(if you forget , type forget)"); - pass = scn.nextLine(); - if(Objects.equals(pass,"forget")){ - adminsFileHandle.show_myPassword(); - continue; - } else if (v.userPasswordValidator(pass) && Objects.equals(pass, adminsFileHandle.getUserPassword().get(flag))) { - break; - } - else{ - System.out.println("Password not found/wrong format, try again"); - continue; - } + else{ + System.out.println("There is no admin in our repository, It means, you have to signup as normal user"); } - User u = new User(user, adminsFileHandle.getIDInFile().get(flag), adminsFileHandle.getPhoneNumbersInFile().get(flag) - , "admin", pass); - adminUserPanel(u); } public void show_helpMenuNormalUser(){ @@ -225,18 +331,21 @@ public void show_helpMenuAdmins(){ Scanner scn = new Scanner(System.in); String cmd; System.out.println("to add book : lib add book_title book_author book_desc"); - System.out.println("to remove user : lib remove user_id user_name user_phone"); - System.out.println("to remove book : lib remove book_title book_author book_desc"); - System.out.println("to remove rent : lib remove rent_date user_id book_id"); - System.out.println("to promote normal user : user promote user_id user_name user_phone"); - System.out.println("to show user : user show user_id"); - System.out.println("to show books : lib show books (-A : all books , -E : only available books , -R : in-rent books)"); - System.out.println("to show rents : lib show rents"); - System.out.println("to exit your panel : enter panel"); + System.out.println("to edit normal user : lib edit (ph/pss/usr) current new_one (usr : username, pss:password, ph : phonenumber"); + System.out.println("to remove user : lib remove user user_id user_name user_phone"); // done + System.out.println("to remove book : lib remove book book_title book_author book_desc"); // done + System.out.println("to remove rent : lib remove rental_date user_id book_id"); + System.out.println("to promote normal user : user promote user_id user_name user_phone"); // done + System.out.println("to show users : lib show users"); // done + System.out.println("to show books : lib show books (-A : all books , -E : only available books , -R : in-rent books)"); // done + System.out.println("to show rents : lib show rents"); // done + System.out.println("to exit your panel : back to your panel"); // done + System.out.println("to edit your profile :lib edit admin"); System.out.println("***Attention*** : avoid to enter space more than one , avoid to enter any character, Each command must be space separated"); System.out.println("for entering space in each field : use underline character '_' "); System.out.println("to back to your panel from this menu : just enter back"); while (true){ + System.out.print(">>>"); cmd = scn.nextLine(); if (Objects.equals(cmd, "back")){ break; @@ -268,203 +377,222 @@ public void normalUserPanel(User u){ } else if (Objects.equals(cmd ,"close") || Objects.equals(cmd, "exit")) { break; - } else if((cmd.contains("lib") || cmd.contains("user")) && (!cmd.contains(" ") || !cmd.contains("*"))){ + } else if((cmd.contains("lib") || cmd.contains("user")) && !cmd.contains("*")){ list = v.get_SectionsPanelQuery(cmd); if(Objects.equals(list.get(1), "add")){ - // add book - String title, auth, desc; - title = list.get(2); - auth = list.get(3); - desc = list.get(4); - if(booksFileHandle.getAuthorsFromFileBook().contains(auth) && booksFileHandle.getTitlesFromFileBook().contains(title) && - booksFileHandle.getDescriptionsFromFileBook().contains(desc)){ - // inc existence - System.out.println("This book is added before."); - int i = booksFileHandle.getAuthorsFromFileBook().indexOf(auth); - String new_exst = String.valueOf(Integer.valueOf(booksFileHandle.getExistsFromFileBook().get(i))+1); - query = booksFileHandle.getIdFromFileBook().get(i) + "," +booksFileHandle.getTitlesFromFileBook().get(i)+","+ - booksFileHandle.getAuthorsFromFileBook().get(i)+","+booksFileHandle.getDescriptionsFromFileBook().get(i)+","+ - "available,"+new_exst; - booksFileHandle.editLineInFile(booksFileHandle.lines_of_file().get(i), query); - } - else{ - // add a new book - String id = String.valueOf(booksFileHandle.set_id()+1); - String existence = "1"; - query = id+","+title+","+auth+","+desc+","+"available,"+existence; - booksFileHandle.add_to_file(query); - System.out.println("Book is added successfully."); + try { + // add book + String title, auth, desc; + title = list.get(2); + auth = list.get(3); + desc = list.get(4); + if(booksFileHandle.getAuthorsFromFileBook().contains(auth) && booksFileHandle.getTitlesFromFileBook().contains(title) && + booksFileHandle.getDescriptionsFromFileBook().contains(desc)){ + // inc existence + System.out.println("This book is added before."); + int i = booksFileHandle.getAuthorsFromFileBook().indexOf(auth); + String new_exst = String.valueOf(Integer.valueOf(booksFileHandle.getExistsFromFileBook().get(i))+1); + query = booksFileHandle.getIdFromFileBook().get(i) + "," +booksFileHandle.getTitlesFromFileBook().get(i)+","+ + booksFileHandle.getAuthorsFromFileBook().get(i)+","+booksFileHandle.getDescriptionsFromFileBook().get(i)+","+ + "available,"+new_exst; + booksFileHandle.editLineInFile(booksFileHandle.lines_of_file().get(i), query); + } + else{ + // add a new book + String id = String.valueOf(booksFileHandle.set_id()+1); + String existence = "1"; + query = id+","+title+","+auth+","+desc+","+"available,"+existence; + booksFileHandle.add_to_file(query); + System.out.println("Book is added successfully."); + } + }catch (Exception e){ + System.out.println("Missing args, Try command in correct way."); } } else if(Objects.equals(list.get(1), "rent")){ - // availability - // reduce in existence - // add to rentals - // rent : date,userID,bookID - String id = list.get(3); - String user_ID = list.get(2); - int i = booksFileHandle.getIdFromFileBook().indexOf(id); - int f; - if(i != -1){ - if(rentalFileHandle.getRentalsUserID().contains(user_ID)){ - f = rentalFileHandle.getRentalsUserID().indexOf(user_ID); - if(!Objects.equals(rentalFileHandle.getRentalsBookID().get(f), id)){ - if(Objects.equals(booksFileHandle.getStatsFromFileBook().get(i), "in-rent")){ - System.out.println("this book "+id+" is actually in rent try another books."); - System.out.println("To show available books try show books command."); + try{ + // layer 1 : check availability user_id + // layer 2 : " " book_id + // layer 3 : " " rentQuery + String id = list.get(3); + String user_ID = list.get(2); + int i = booksFileHandle.getIdFromFileBook().indexOf(id); + int f; + String rentQuery = date + ","+ user_ID+","+id; + if(usersFileHandle.getIDInFile().contains(user_ID)){ + if(booksFileHandle.getIdFromFileBook().contains(id)){ + if(!rentalFileHandle.lines_of_file().contains(rentQuery)){ + rentalFileHandle.add_to_file(rentQuery); + booksFileHandle.change_status_inFileRent(id); + System.out.println("Rent is done !. :-)"); } else{ - if(usersFileHandle.getIDInFile().contains(user_ID)){ - query = date + "," + user_ID + "," + booksFileHandle.getIdFromFileBook().get(i); - booksFileHandle.change_status_inFileRent(booksFileHandle.getIdFromFileBook().get(i)); - rentalFileHandle.add_to_file(query); - } - else{ - System.out.println("Wrong ID, there is no id in repository like that. :-|"); - } + System.out.println("This rent request is active at this time. Try another book."); } } else{ - System.out.println("there is rent just like the rent, try another book."); + System.out.println("This book id is not available in book repository. :-|"); } } + else{ + System.out.println("This user ID is not available in user repository. :-|"); + } + }catch (Exception e){ + System.out.println("Missing args, apply command in correct way."); } - else{ - System.out.println("This book with this title is not available in book repository. :-|"); - System.out.println("Try command with appropriate query. :-)"); - } + + } else if(Objects.equals(list.get(1), "edit")){ // edit your info - if(Objects.equals(list.get(2), "ph")){ - // edit phonenumber - p1 = list.get(3); - p2 = list.get(4); - while(true){ - if(v.userPhonenumberValidator(p2)){ - break; + try{ + if(Objects.equals(list.get(2), "ph")){ + // edit phonenumber + p1 = list.get(3); + p2 = list.get(4); + while(true){ + if(v.userPhonenumberValidator(p2)){ + break; + } + else{ + System.out.println("Enter valid username ."); + System.out.println("User phonenumber must start with any number instead of 0 with length 10"); + p2 = scn.nextLine(); + } } - else{ - System.out.println("Enter valid username ."); - System.out.println("User phonenumber must start with any number instead of 0 with length 10"); - p2 = scn.nextLine(); + while (true){ + if(!usersFileHandle.getPhoneNumbersInFile().contains(p2)) + break; + else{ + System.out.println("This phonenumber is already taken . try another one"); + System.out.print(">>>"); + p2 = scn.nextLine(); + } + } + + int i = usersFileHandle.getPhoneNumbersInFile().indexOf(p1); + if(Objects.equals(p1, u.getPhonenumber())){ + query = usersFileHandle.getIDInFile().get(i)+","+ + usersFileHandle.getUsernameInFile().get(i)+","+p2+",normal,"+usersFileHandle.getUserPassword().get(i); + usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(i), query); + System.out.println("phonenumber has been updated"); } - } - while (true){ - if(!usersFileHandle.getPhoneNumbersInFile().contains(p2)) - break; else{ - System.out.println("This phonenumber is already taken . try another one"); - System.out.print(">>>"); - p2 = scn.nextLine(); + System.out.println("Repeat your command, your current phonenumber is not correct in input. "); } - } - int i = usersFileHandle.getPhoneNumbersInFile().indexOf(p1); - if(Objects.equals(p1, u.getPhonenumber())){ - query = usersFileHandle.getIDInFile().get(i)+","+ - usersFileHandle.getUsernameInFile().get(i)+","+p2+",normal,"+usersFileHandle.getUserPassword().get(i); - usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(i), query); - System.out.println("phonenumber has been updated"); - } - else{ - System.out.println("Repeat your command, your current username is not correct in input. "); } - - } - else if(Objects.equals(list.get(2), "usr")){ - u1 = list.get(3); - u2 = list.get(4); - while(true){ - if(v.userUsernameValidator(u2)){ - break; + else if(Objects.equals(list.get(2), "usr")){ + u1 = list.get(3); + u2 = list.get(4); + while(true){ + if(v.userUsernameValidator(u2)){ + break; + } + else{ + System.out.println("Enter valid username ."); + System.out.println("Username must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + u2 = scn.nextLine(); + } + } + while (true){ + if(!usersFileHandle.getUsernameInFile().contains(u2)) + break; + else{ + System.out.println("This username is already taken . try another one"); + System.out.print(">>>"); + u2 = scn.nextLine(); + } + } + int i = usersFileHandle.getUsernameInFile().indexOf(u1); + if(Objects.equals(u1, u.getUser_name())){ + query = usersFileHandle.getIDInFile().get(i)+","+ + u2+","+usersFileHandle.getPhoneNumbersInFile().get(i)+",normal,"+usersFileHandle.getUserPassword().get(i); + usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(i), query); + u.set_new_username(u2); + System.out.println("Your username has been updated"); } else{ - System.out.println("Enter valid username ."); - System.out.println("Username must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); - u2 = scn.nextLine(); + System.out.println("Repeat your command, your current username is not correct in input. "); } + } - while (true){ - if(!usersFileHandle.getUsernameInFile().contains(u2)) - break; + else if(Objects.equals(list.get(2), "pss")){ + p1 = list.get(3); + p2 = list.get(4); + while (true){ + if(v.userPasswordValidator(p2)){ + break; + } + else{ + System.out.println("Wrong format, try another password."); + } + } + + if(!Objects.equals(p1, u.getPassword())){ + System.out.println("Try command again, current password is not correct."); + } else{ - System.out.println("This username is already taken . try another one"); - System.out.print(">>>"); - u2 = scn.nextLine(); + int i = usersFileHandle.getUserPassword().indexOf(p1); + query = usersFileHandle.getIDInFile().get(i)+"," + usersFileHandle.getUsernameInFile().get(i)+","+ + usersFileHandle.getPhoneNumbersInFile().get(i) + ",normal,"+p2; + usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(i), query); + System.out.println("Your password has been updated."); } - } - int i = usersFileHandle.getUsernameInFile().indexOf(u1); - if(Objects.equals(u1, u.getUser_name())){ - query = usersFileHandle.getIDInFile().get(i)+","+ - u2+","+usersFileHandle.getPhoneNumbersInFile().get(i)+",normal,"+usersFileHandle.getUserPassword().get(i); - usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(i), query); - u.set_new_username(u2); - System.out.println("Your username has been updated"); - } - else{ - System.out.println("Repeat your command, your current username is not correct in input. "); - } + } + }catch (Exception e){ + System.out.println("Missing args, Apply command in correct way."); } - else if(Objects.equals(list.get(2), "pss")){ - p1 = list.get(3); - p2 = list.get(4); - while (true){ - if(v.userPasswordValidator(p2)){ + } + else if(Objects.equals(list.get(1), "return")){ + try { + // lib return id your_id + int flag; + String bookId = list.get(2), user_id = list.get(3); + // edit booksFile : repository // change status if 0 existence or increment existence + // edit rentals + + String rent_Query = ""; + for(String line : rentalFileHandle.lines_of_file()){ + if(line.contains(user_id+","+bookId)){ + rent_Query = rentalFileHandle.getDate_fromSingleLine(line) + "," + user_id+","+bookId; break; } - else{ - System.out.println("Wrong format, try another password."); - } } - if(!Objects.equals(p1, u.getPassword())){ - System.out.println("Try command again, current password is not correct."); + if(!Objects.equals(rent_Query, "")){ + rentalFileHandle.editLineInFile(rent_Query, ""); + booksFileHandle.change_status_inFileReturnCase(bookId); } else{ - int i = usersFileHandle.getUserPassword().indexOf(p1); - query = usersFileHandle.getIDInFile().get(i)+"," + usersFileHandle.getUsernameInFile().get(i)+","+ - usersFileHandle.getPhoneNumbersInFile().get(i) + ",normal,"+p2; - usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(i), query); - System.out.println("Your password has been updated."); + System.out.println("This rental is not available in rents repository. :-|"); } - + }catch (Exception e){ + System.out.println("Missing args, Apply command in correct way."); } - } - else if(Objects.equals(list.get(1), "return")){ - // lib return book_title your_id - int flag; - String bookId = list.get(2), user_id = list.get(3); - // edit booksFile : repository // change status if 0 existence or increment existence - // edit rentals - if(rentalFileHandle.getRentalsUserID().contains(user_id) && rentalFileHandle.getRentalsBookID().contains(bookId)){ - flag = rentalFileHandle.getRentalsUserID().indexOf(user_id); - String new_query = ""; - String line = rentalFileHandle.lines_of_file().get(flag); - rentalFileHandle.editLineInFile(line, new_query); - booksFileHandle.change_status_inFileReturnCase(bookId); - }else{ - System.out.println("No such rental details are available. :-|"); - } } else if(Objects.equals(list.get(1), "show")){ - if(Objects.equals(list.get(2), "profile") || Objects.equals(list.get(2), "Profile")){ - System.out.println("User_id : " + u.getUserID()); - System.out.println("User_name : "+u.getUser_name()); - System.out.println("User_phone : "+u.getPhonenumber()); - System.out.println("Access level : "+u.getRole()); - } - else{ - for(int i = 0;i < booksFileHandle.getStatsFromFileBook().size();i++){ - if(Objects.equals(booksFileHandle.getStatsFromFileBook().get(i),"available")){ - System.out.println(booksFileHandle.getIdFromFileBook().get(i)+ - ", "+booksFileHandle.getTitlesFromFileBook().get(i)+" exst : " + booksFileHandle.getExistsFromFileBook().get(i)); + try{ + if(Objects.equals(list.get(2), "profile") || Objects.equals(list.get(2), "Profile")){ + System.out.println("User_id : " + u.getUserID()); + System.out.println("User_name : "+u.getUser_name()); + System.out.println("User_phone : "+u.getPhonenumber()); + System.out.println("Access level : "+u.getRole()); + } + else if(Objects.equals(list.get(2), "Books") || Objects.equals(list.get(2), "books") || Objects.equals(list.get(2), "book")){ + for(int i = 0;i < booksFileHandle.getStatsFromFileBook().size();i++){ + if(Objects.equals(booksFileHandle.getStatsFromFileBook().get(i),"available")){ + System.out.println(booksFileHandle.getIdFromFileBook().get(i)+ + ", "+booksFileHandle.getTitlesFromFileBook().get(i)+" exst : " + booksFileHandle.getExistsFromFileBook().get(i)); + } } } + }catch (Exception e){ + System.out.println("Missing args, Try command in correct way. "); } } @@ -482,6 +610,7 @@ else if(Objects.equals(list.get(1), "show")){ } public void adminUserPanel(User u){ + String p1, p2, u1, u2; System.out.println("Welcome " + u.getUser_name()); System.out.println("This is your admin panel."); ArrayList list = new ArrayList<>(); @@ -489,6 +618,9 @@ public void adminUserPanel(User u){ v = new Verifications(); Scanner scn = new Scanner(System.in); int flag; + String userID, userName, userPhone; + String book_t; + String query; String type; while (true){ System.out.println("Enter command (With Space ,Just one space, Please avoid to enter extra characters)"); @@ -502,8 +634,13 @@ else if((cmd.contains("lib") || cmd.contains("user")) && (!cmd.contains(" ") || list = v.get_SectionsPanelQuery(cmd); if(Objects.equals(list.get(1), "show") || Objects.equals(list.get(1), "Show")){ if(Objects.equals(list.get(2), "books")){ - type = list.get(3); - booksFileHandle.show_booksFile(type); + try { + type = list.get(3); + booksFileHandle.show_booksFile(type); + } + catch (Exception e){ + System.out.println("Missing Argument,"); + } } else if(Objects.equals(list.get(2), "users")){ for(String line : usersFileHandle.lines_of_file()){ @@ -519,6 +656,214 @@ else if(Objects.equals(list.get(2), "rents")){ System.out.println("Try command in correct way."); } } + else if(Objects.equals(list.get(1), "promote") || Objects.equals(list.get(1), "Promote")){ + try { + userID = list.get(2); + userName = list.get(3); + userPhone = list.get(4); + flag = usersFileHandle.getIDInFile().indexOf(userID); + // user : id,username,phonenumber,role,password + query = userID + "," + userName + "," + userPhone + ",admin," + usersFileHandle.getUserPassword().get(flag); + if(adminsFileHandle.lines_of_file().contains(query)){ + System.out.println("You promote this user before. "); + } + else{ + adminsFileHandle.add_to_file(query); + usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(flag), ""); + System.out.println("Done!"); + } + + } + catch (Exception e){ + System.out.println("Try command in correct way.[Missing Argument or ID/Username not in repository]"); + } + } + else if(Objects.equals(list.get(1), "remove") || Objects.equals(list.get(1), "Remove")){ // remove whole with no change + if(Objects.equals(list.get(2), "user")){ + // to remove user : lib remove user user_id user_name user_phone + userID = list.get(3); + flag = usersFileHandle.getIDInFile().indexOf(userID); + if(flag == -1){ + System.out.println("This id is not in user repository."); + } + else{ + usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(flag), ""); + } + } + else if(Objects.equals(list.get(2), "book")){ + book_t = list.get(3); + flag = booksFileHandle.getTitlesFromFileBook().indexOf(book_t); + if(flag != -1){ + booksFileHandle.editLineInFile(booksFileHandle.lines_of_file().get(flag), ""); + } + else{ + System.out.println("There is no book such this book in books repository"); + } + } + else{ + System.out.println("Missing arguments. "); + } + } + else if(Objects.equals(list.get(1), "edit") || Objects.equals(list.get(1), "Edit")){ + // edit your info + if(Objects.equals(list.get(2), "ph")){ + try { + // edit phonenumber + p1 = list.get(3); + p2 = list.get(4); + while(true){ + if(v.userPhonenumberValidator(p2)){ + break; + } + else{ + System.out.println("Enter valid username ."); + System.out.println("User phonenumber must start with any number instead of 0 with length 10"); + p2 = scn.nextLine(); + } + } + if(adminsFileHandle.getPhoneNumbersInFile().contains(p1)){ + while (true){ + if(!adminsFileHandle.getPhoneNumbersInFile().contains(p2)) + break; + else{ + System.out.println("This phonenumber is already taken . try another one"); + System.out.print(">>>"); + p2 = scn.nextLine(); + } + } + + int i = adminsFileHandle.getPhoneNumbersInFile().indexOf(p1); + if(Objects.equals(p1, u.getPhonenumber())){ + query = adminsFileHandle.getIDInFile().get(i)+","+ + adminsFileHandle.getUsernameInFile().get(i)+","+p2+",normal,"+adminsFileHandle.getUserPassword().get(i); + adminsFileHandle.editLineInFile(adminsFileHandle.lines_of_file().get(i), query); + System.out.println("phonenumber has been updated"); + } + else{ + System.out.println("Repeat your command, your current username is not correct in input. "); + } + + } + else{ + System.out.println("There is no phone number like that in users repository"); + } + } + catch (Exception e){ + System.out.println("Missing Arguments."); + } + } + else if(Objects.equals(list.get(2), "usr")){ + try{ + u1 = list.get(3); + u2 = list.get(4); + while(true){ + if(v.userUsernameValidator(u2)){ + break; + } + else{ + System.out.println("Enter valid username ."); + System.out.println("Username must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + u2 = scn.nextLine(); + } + } + if(adminsFileHandle.getUsernameInFile().contains(u1)){ + while (true){ + if(!adminsFileHandle.getUsernameInFile().contains(u2)) + break; + else{ + System.out.println("This username is already taken . try another one"); + System.out.print(">>>"); + u2 = scn.nextLine(); + } + } + int i = adminsFileHandle.getUsernameInFile().indexOf(u1); + if(Objects.equals(u1, u.getUser_name())){ + query = adminsFileHandle.getIDInFile().get(i)+","+ + u2+","+adminsFileHandle.getPhoneNumbersInFile().get(i)+",normal,"+adminsFileHandle.getUserPassword().get(i); + adminsFileHandle.editLineInFile(adminsFileHandle.lines_of_file().get(i), query); + u.set_new_username(u2); + System.out.println("Your username has been updated"); + } + else{ + System.out.println("Repeat your command, your current username is not correct in input. "); + } + + } + else{ + System.out.println("This username is not in users repository"); + } + } + catch (Exception e){ + System.out.println("Missing Arguments,"); + } + } + else if(Objects.equals(list.get(2), "pss")){ + try{ + p1 = list.get(3); + p2 = list.get(4); + while (true){ + if(v.userPasswordValidator(p2)){ + break; + } + else{ + System.out.println("Wrong format, try another password."); + } + } + + if(!Objects.equals(p1, u.getPassword())){ + System.out.println("Try command again, current password is not correct."); + } + else{ + int i = adminsFileHandle.getUserPassword().indexOf(p1); + query = adminsFileHandle.getIDInFile().get(i)+"," + adminsFileHandle.getUsernameInFile().get(i)+","+ + adminsFileHandle.getPhoneNumbersInFile().get(i) + ",normal,"+p2; + adminsFileHandle.editLineInFile(adminsFileHandle.lines_of_file().get(i), query); + System.out.println("Your password has been updated."); + } + + } + catch (Exception e){ + e.printStackTrace(); + System.out.println("Missing Arguments. "); + } + } + else if(Objects.equals(list.get(2), "admin")){ + adminEditPanel(u); + } + else{ + System.out.println("Try command in correct way. "); + } + + } + else if(Objects.equals(list.get(1), "add") || Objects.equals(list.get(1),"Add")){ + // add book + String title, auth, desc; + title = list.get(2); + auth = list.get(3); + desc = list.get(4); + if(booksFileHandle.getAuthorsFromFileBook().contains(auth) && booksFileHandle.getTitlesFromFileBook().contains(title) && + booksFileHandle.getDescriptionsFromFileBook().contains(desc)){ + // inc existence + System.out.println("This book is added before."); + int i = booksFileHandle.getAuthorsFromFileBook().indexOf(auth); + String new_exst = String.valueOf(Integer.valueOf(booksFileHandle.getExistsFromFileBook().get(i))+1); + query = booksFileHandle.getIdFromFileBook().get(i) + "," +booksFileHandle.getTitlesFromFileBook().get(i)+","+ + booksFileHandle.getAuthorsFromFileBook().get(i)+","+booksFileHandle.getDescriptionsFromFileBook().get(i)+","+ + "available,"+new_exst; + booksFileHandle.editLineInFile(booksFileHandle.lines_of_file().get(i), query); + } + else{ + // add a new book + String id = String.valueOf(booksFileHandle.set_id()+1); + String existence = "1"; + query = id+","+title+","+auth+","+desc+","+"available,"+existence; + booksFileHandle.add_to_file(query); + System.out.println("Book is added successfully."); + } + } + else{ + System.out.println("Try command in a correct way."); + } } else if(Objects.equals(cmd, "exit")){ break; @@ -574,3 +919,103 @@ else if(Objects.equals(cmd, "exit")){ } */ + + +/* +while (true){ + id = scn.nextLine(); + if(v.userIdValidator(id)) + break; + else{ + System.out.println("Wrong format, try again."); + } + } + System.out.println("Enter username :"); + System.out.println("Username must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + while (true){ + username = scn.nextLine(); + if(v.userUsernameValidator(username)){ + break; + } + else{ + System.out.println("Wrong format, try again."); + } + } + System.out.println("Enter a phonenumber :"); + System.out.println("User phonenumber must start with any number instead of 0 with length 10"); + while (true){ + phonenumber = scn1.nextLine(); + if(v.userPhonenumberValidator(phonenumber)){ + break; + } + else{ + System.out.println("Wrong Format, Try again."); + } + } + // now to check file + if(usersFileHandle.getUsernameInFile().contains(username) || usersFileHandle.getIDInFile().contains(id) + || usersFileHandle.getPhoneNumbersInFile().contains(phonenumber)){ + System.out.println("Sorry, We found your id/username/phonenumber , Please goto login panel"); + return; + } + System.out.println("Set a password for yourself :"); + System.out.println("Password must include 0->9 and a->z and A->Z , just underline '_' not dash '-'"); + while (true){ + pass = scn.nextLine(); + if(v.userPasswordValidator(pass)){ + break; + } + else{ + System.out.println("Wrong Format, Try Again."); + } + } + u = new User(username, id, phonenumber,"normal", pass); + usersFileHandle.addUser(u); + */ + +/* +if(i != -1){ + if(rentalFileHandle.getRentalsUserID().contains(user_ID)){ + f = rentalFileHandle.getRentalsUserID().indexOf(user_ID); + if(!Objects.equals(rentalFileHandle.getRentalsBookID().get(f), id)){ + if(Objects.equals(booksFileHandle.getStatsFromFileBook().get(i), "in-rent")){ + System.out.println("this book "+id+" is actually in rent try another books."); + System.out.println("To show available books try show books command."); + } + else{ + if(usersFileHandle.getIDInFile().contains(user_ID)){ + query = date + "," + user_ID + "," + booksFileHandle.getIdFromFileBook().get(i); + booksFileHandle.change_status_inFileRent(booksFileHandle.getIdFromFileBook().get(i)); + rentalFileHandle.add_to_file(query); + } + else{ + System.out.println("Wrong ID, there is no id in repository like that. :-|"); + } + } + } + else{ + System.out.println("there is rent just like the rent, try another book."); + } + } + else{ + + } + } + else{ + System.out.println("This book with this id is not available in book repository. :-|"); + System.out.println("Try command with appropriate query. :-)"); + } + */ + +/* +if(true){ + flag = rentalFileHandle.getRentalsUserID().indexOf(user_id); + String new_query = ""; + String line = rentalFileHandle.lines_of_file().get(flag); + rentalFileHandle.editLineInFile(line, new_query); + booksFileHandle.change_status_inFileReturnCase(bookId); + + }else{ + System.out.println("No such rental details are available. :-|"); + } + */ \ No newline at end of file From ece68572aae3c852de03d9c3e8a0d77020120055 Mon Sep 17 00:00:00 2001 From: Amir Date: Mon, 13 May 2024 11:49:38 +0330 Subject: [PATCH 43/47] Remove rent method is added to project --- Answers/40230112081/myFileCLass.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Answers/40230112081/myFileCLass.java b/Answers/40230112081/myFileCLass.java index 62adde8..ae59134 100644 --- a/Answers/40230112081/myFileCLass.java +++ b/Answers/40230112081/myFileCLass.java @@ -419,6 +419,13 @@ else if(Objects.equals(type, "-R")){ // existed books } + public String getDate_fromSingleLine(String line){ // rentals + String date; + int f1 = line.indexOf(","); + date = line.substring(0, f1); + return date; + } + public void deleteEmptyLine(){ File temp; String line; @@ -453,7 +460,23 @@ public void deleteEmptyLine(){ } } + public void removeRents(String userID){ // remove all rents with this userID in case of remove user for admin + for(String line : lines_of_file()){ + if(line.contains(userID)){ + editLineInFile(line, ""); + } + } + } + public boolean removeRentByQuery(String query){ // remove rent by query = date+userID+bookID + for(String line : lines_of_file()){ + if(Objects.equals(line, query)){ + editLineInFile(line, ""); + return true; + } + } + return false; + } } From b7ec5f4f036c92f1b7759db7a6a7feacc08e0aed Mon Sep 17 00:00:00 2001 From: Amir Date: Mon, 13 May 2024 11:50:11 +0330 Subject: [PATCH 44/47] Date verifications is added to file --- Answers/40230112081/Verifications.java | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Answers/40230112081/Verifications.java b/Answers/40230112081/Verifications.java index b8eb14e..aa6b9ad 100644 --- a/Answers/40230112081/Verifications.java +++ b/Answers/40230112081/Verifications.java @@ -1,4 +1,6 @@ +import java.lang.reflect.Array; import java.util.ArrayList; +import java.util.HashMap; public class Verifications { @@ -44,6 +46,31 @@ public boolean userUsernameValidator(String _username_){ return true; } + public boolean userPasswordValidator(String _password_){ + // Password must include 0->9 and a->z and A->Z , just underline '_' not dash '-' + ArrayList valid_chars = new ArrayList<>(); + String upperAlph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + String Alph = upperAlph.toLowerCase(); + String numbers = "0123456789"; + + for(Character ch : upperAlph.toCharArray()){ + valid_chars.add(ch); + } + for(Character ch : Alph.toCharArray()){ + valid_chars.add(ch); + } + for(Character ch : numbers.toCharArray()){ + valid_chars.add(ch); + } + valid_chars.add('_'); + for(Character ch : _password_.toCharArray()){ + if(!valid_chars.contains(ch)) + return false; + } + + return true; + } + public boolean userPhonenumberValidator(String _phonenumber_){ // User phonenumber must start with any number instead of 0 // length must be 10 @@ -59,4 +86,25 @@ public boolean userPhonenumberValidator(String _phonenumber_){ } return true; } + + public ArrayList get_SectionsPanelQuery(String query){ + ArrayList str = new ArrayList<>(); + for(String word : query.split(" +")){ + str.add(word); + } + return str; + } + + public boolean dateValidation(String date){ + if(!date.contains("/")){ + return false; + } + int f1, f2; + f1 = date.indexOf("/", 0); + f2 = date.indexOf("/", f1+1); + if(date.substring(f1+1,f2).matches("[0-9]")){ + return false; + } + return true; + } } From 2c74591e5c7a3fbebb58146c7fef755e9e9fe2fc Mon Sep 17 00:00:00 2001 From: Amir Date: Mon, 13 May 2024 11:50:57 +0330 Subject: [PATCH 45/47] Feature to remove rents, is ready for admin panel --- Answers/40230112081/Library.java | 120 +++++++++++++++++++++---------- 1 file changed, 81 insertions(+), 39 deletions(-) diff --git a/Answers/40230112081/Library.java b/Answers/40230112081/Library.java index c8a1841..b314da9 100644 --- a/Answers/40230112081/Library.java +++ b/Answers/40230112081/Library.java @@ -330,17 +330,17 @@ public void show_helpMenuNormalUser(){ public void show_helpMenuAdmins(){ Scanner scn = new Scanner(System.in); String cmd; - System.out.println("to add book : lib add book_title book_author book_desc"); - System.out.println("to edit normal user : lib edit (ph/pss/usr) current new_one (usr : username, pss:password, ph : phonenumber"); + System.out.println("to add book : lib add book_title book_author book_desc"); // done + System.out.println("to edit normal user : lib edit (ph/pss/usr) current new_one (usr : username, pss:password, ph : phonenumber"); // done System.out.println("to remove user : lib remove user user_id user_name user_phone"); // done System.out.println("to remove book : lib remove book book_title book_author book_desc"); // done - System.out.println("to remove rent : lib remove rental_date user_id book_id"); + System.out.println("to remove rent : lib remove rental_date user_id book_id (Attention : enter date in day/Month/year , use month full_name)"); System.out.println("to promote normal user : user promote user_id user_name user_phone"); // done System.out.println("to show users : lib show users"); // done System.out.println("to show books : lib show books (-A : all books , -E : only available books , -R : in-rent books)"); // done System.out.println("to show rents : lib show rents"); // done System.out.println("to exit your panel : back to your panel"); // done - System.out.println("to edit your profile :lib edit admin"); + System.out.println("to edit your profile :lib edit admin"); // done System.out.println("***Attention*** : avoid to enter space more than one , avoid to enter any character, Each command must be space separated"); System.out.println("for entering space in each field : use underline character '_' "); System.out.println("to back to your panel from this menu : just enter back"); @@ -617,6 +617,7 @@ public void adminUserPanel(User u){ String cmd; v = new Verifications(); Scanner scn = new Scanner(System.in); + String date; int flag; String userID, userName, userPhone; String book_t; @@ -624,7 +625,7 @@ public void adminUserPanel(User u){ String type; while (true){ System.out.println("Enter command (With Space ,Just one space, Please avoid to enter extra characters)"); - System.out.println("Enter help to "); + System.out.println("Enter help to see help menu. "); System.out.print(">>>"); cmd = scn.nextLine(); if(Objects.equals(cmd, "help") || Objects.equals(cmd, "Help")){ @@ -633,27 +634,31 @@ public void adminUserPanel(User u){ else if((cmd.contains("lib") || cmd.contains("user")) && (!cmd.contains(" ") || !cmd.contains("*"))){ list = v.get_SectionsPanelQuery(cmd); if(Objects.equals(list.get(1), "show") || Objects.equals(list.get(1), "Show")){ - if(Objects.equals(list.get(2), "books")){ - try { - type = list.get(3); - booksFileHandle.show_booksFile(type); + try { + if(Objects.equals(list.get(2), "books")){ + try { + type = list.get(3); + booksFileHandle.show_booksFile(type); + } + catch (Exception e){ + System.out.println("Missing Argument,"); + } } - catch (Exception e){ - System.out.println("Missing Argument,"); + else if(Objects.equals(list.get(2), "users")){ + for(String line : usersFileHandle.lines_of_file()){ + System.out.println(line); + } } - } - else if(Objects.equals(list.get(2), "users")){ - for(String line : usersFileHandle.lines_of_file()){ - System.out.println(line); + else if(Objects.equals(list.get(2), "rents")){ + for(String line : rentalFileHandle.lines_of_file()){ + System.out.println(line); + } } - } - else if(Objects.equals(list.get(2), "rents")){ - for(String line : rentalFileHandle.lines_of_file()){ - System.out.println(line); + else{ + System.out.println("Try command in correct way."); } - } - else{ - System.out.println("Try command in correct way."); + } catch (Exception e){ + System.out.println("Missing args. :-|"); } } else if(Objects.equals(list.get(1), "promote") || Objects.equals(list.get(1), "Promote")){ @@ -679,29 +684,66 @@ else if(Objects.equals(list.get(1), "promote") || Objects.equals(list.get(1), "P } } else if(Objects.equals(list.get(1), "remove") || Objects.equals(list.get(1), "Remove")){ // remove whole with no change - if(Objects.equals(list.get(2), "user")){ - // to remove user : lib remove user user_id user_name user_phone - userID = list.get(3); - flag = usersFileHandle.getIDInFile().indexOf(userID); - if(flag == -1){ - System.out.println("This id is not in user repository."); + try { + if(Objects.equals(list.get(2), "user")){ + try { + // to remove user : lib remove user user_id user_name user_phone + userID = list.get(3); + flag = usersFileHandle.getIDInFile().indexOf(userID); + if(flag == -1){ + System.out.println("This user_id is not in user repository."); + } + else{ + usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(flag), ""); + rentalFileHandle.removeRents(userID); + } + }catch (Exception e){ + System.out.println("Missing args. :-|"); + } } - else{ - usersFileHandle.editLineInFile(usersFileHandle.lines_of_file().get(flag), ""); + else if(Objects.equals(list.get(2), "book")){ + try { + book_t = list.get(3); + flag = booksFileHandle.getTitlesFromFileBook().indexOf(book_t); + if(flag != -1){ + booksFileHandle.editLineInFile(booksFileHandle.lines_of_file().get(flag), ""); + } + else{ + System.out.println("There is no book such this book in books repository"); + } + }catch (Exception e){ + System.out.println("Missing args. :-|"); + } } - } - else if(Objects.equals(list.get(2), "book")){ - book_t = list.get(3); - flag = booksFileHandle.getTitlesFromFileBook().indexOf(book_t); - if(flag != -1){ - booksFileHandle.editLineInFile(booksFileHandle.lines_of_file().get(flag), ""); + else if(Objects.equals(list.get(2), "rent")){ + try{ + date = list.get(3); + userID = list.get(4); + book_t = list.get(5); + if(!v.dateValidation(date) || !v.userIdValidator(userID)){ + System.out.println("Wrong date/id format try again."); + } + else{ + query = date + "," + userID + "," + book_t; + if(rentalFileHandle.removeRentByQuery(query)){ + System.out.println("Done ! :-)"); + } + else{ + System.out.println("There is no rent like that."); + } + } + //query = date + "," + userID + "," + book_t; + + }catch (Exception e){ + System.out.println("Missing args. :-|"); + } } else{ - System.out.println("There is no book such this book in books repository"); + System.out.println("Missing arguments. "); } } - else{ - System.out.println("Missing arguments. "); + catch (Exception e){ + System.out.println("Missing Args, Try command in correct way."); } } else if(Objects.equals(list.get(1), "edit") || Objects.equals(list.get(1), "Edit")){ From aa9452e6a53e04cf1f62315d2c40091a7f8e4246 Mon Sep 17 00:00:00 2001 From: Amir Date: Mon, 13 May 2024 11:51:43 +0330 Subject: [PATCH 46/47] Each file has been updated, during program running. --- Answers/40230112081/Admins.txt | 3 + Answers/40230112081/Books.txt | 2 + Answers/40230112081/MyApp.java | 75 +++++++---- Answers/40230112081/Rental.txt | 0 Answers/40230112081/User.java | 4 + Answers/40230112081/Users.txt | 1 + .../40230112081/.idea/uiDesigner.xml | 124 ++++++++++++++++++ .../out/production/40230112081/Admins.txt | 3 + .../out/production/40230112081/Book.class | Bin 0 -> 1329 bytes .../out/production/40230112081/Books.txt | 2 + .../out/production/40230112081/Library.class | Bin 0 -> 23543 bytes .../out/production/40230112081/MyApp.class | Bin 358 -> 2720 bytes .../out/production/40230112081/Rent.class | Bin 0 -> 775 bytes .../out/production/40230112081/Rental.txt | 0 .../out/production/40230112081/User.class | Bin 886 -> 1166 bytes .../out/production/40230112081/Users.txt | 1 + .../40230112081/Verifications.class | Bin 0 -> 3428 bytes .../production/40230112081/myFileCLass.class | Bin 5067 -> 14670 bytes .../out/production/40230112081/test.class | Bin 1861 -> 0 bytes 19 files changed, 187 insertions(+), 28 deletions(-) create mode 100644 Answers/40230112081/Rental.txt create mode 100644 Answers/40230112081/out/production/40230112081/.idea/uiDesigner.xml create mode 100644 Answers/40230112081/out/production/40230112081/Admins.txt create mode 100644 Answers/40230112081/out/production/40230112081/Book.class create mode 100644 Answers/40230112081/out/production/40230112081/Books.txt create mode 100644 Answers/40230112081/out/production/40230112081/Library.class create mode 100644 Answers/40230112081/out/production/40230112081/Rent.class create mode 100644 Answers/40230112081/out/production/40230112081/Rental.txt create mode 100644 Answers/40230112081/out/production/40230112081/Users.txt create mode 100644 Answers/40230112081/out/production/40230112081/Verifications.class delete mode 100644 Answers/40230112081/out/production/40230112081/test.class diff --git a/Answers/40230112081/Admins.txt b/Answers/40230112081/Admins.txt index e69de29..25610e6 100644 --- a/Answers/40230112081/Admins.txt +++ b/Answers/40230112081/Admins.txt @@ -0,0 +1,3 @@ +40230112081,Masoud,9121231234,admin,Masoud +40230112081,Amir1,9120719012,admin,1234 +1234512345,krm,9112342345,admin,1234 diff --git a/Answers/40230112081/Books.txt b/Answers/40230112081/Books.txt index e69de29..516bdd1 100644 --- a/Answers/40230112081/Books.txt +++ b/Answers/40230112081/Books.txt @@ -0,0 +1,2 @@ +1,Math,Salehi,Calc,available,1 +3,Book1,Author1,Desc1,available,1 diff --git a/Answers/40230112081/MyApp.java b/Answers/40230112081/MyApp.java index ba37f30..c7fde2b 100644 --- a/Answers/40230112081/MyApp.java +++ b/Answers/40230112081/MyApp.java @@ -4,40 +4,59 @@ public class MyApp { public static void main(String[] args) throws IOException, InterruptedException { - Library lib = new Library("Nit central library", "7a.m.to7p.m.",100); + Library lib = new Library("Nit central library", "7a.m.-7p.m.",100); Scanner scn = new Scanner(System.in); String cmd; - while (true){ - System.out.print("\033[H\033[2J"); - System.out.println("***************************************************"); - System.out.println("Welcome to "+ lib.getLibName()); - System.out.println("Each commands start with lib : Example below."); - System.out.println("to add book : lib add etc. "); - System.out.println("to login : lib login"); - System.out.println("to sign up as normal user : lib signup"); - System.out.print(">>>"); - cmd = scn.nextLine(); - if(!cmd.contains("lib")){ - System.out.println("Wrong format, try again."); - } - else{ - if(Objects.equals(cmd, "lib signup")){ - System.out.print("\033[H\033[2J"); - lib.add_normalUser(); - } - else if (Objects.equals(cmd, "lib login")) { - System.out.print("\033[H\033[2J"); - System.out.println("Login as Admin / Normal user (type admin or normal):"); - System.out.print(">>>"); - cmd = scn.nextLine(); - if(Objects.equals(cmd, "admin") || Objects.equals(cmd,"Admin")){ - lib.login_AdminUsers(); + if(lib.isLibOpen()){ + while (true){ + System.out.print("\033[H\033[2J"); + System.out.println("***************************************************"); + System.out.println("Welcome to "+ lib.getLibName()); + System.out.println("Each commands start with lib : Instructions below."); + System.out.println("to login : lib login"); + System.out.println("to sign up as normal user : lib signup"); + System.out.println("to exit : just enter exit"); + System.out.print(">>>"); + cmd = scn.nextLine(); + if(cmd.contains("lib")){ + if(Objects.equals(cmd, "lib signup")){ + System.out.print("\033[H\033[2J"); + lib.add_normalUser(); } - else{ - lib.login_normalUsers(); + else if (Objects.equals(cmd, "lib login")) { + System.out.print("\033[H\033[2J"); + System.out.println("Login as Admin / Normal user (type admin or normal or exit to return to main menu):"); + while (true){ + System.out.print(">>>"); + cmd = scn.nextLine(); + if(Objects.equals(cmd, "exit")){ + break; + } + else if(Objects.equals(cmd, "admin") || Objects.equals(cmd,"normal")) + break; + else{ + System.out.println("Wrong input :-|"); + } + + } + if(Objects.equals(cmd, "admin") || Objects.equals(cmd,"Admin")){ + lib.login_AdminUsers(); + } + else if(Objects.equals(cmd, "normal") || Objects.equals(cmd, "Normal")){ + lib.login_normalUsers(); + } } } + else if(Objects.equals(cmd, "exit")){ + break; + } + else{ + System.out.println("Wrong format: try again"); + } } } + else{ + System.out.println("Thanks for choosing "+lib.getLibName()+", Library is closed"); + } } } diff --git a/Answers/40230112081/Rental.txt b/Answers/40230112081/Rental.txt new file mode 100644 index 0000000..e69de29 diff --git a/Answers/40230112081/User.java b/Answers/40230112081/User.java index 9a99419..7c6ea96 100644 --- a/Answers/40230112081/User.java +++ b/Answers/40230112081/User.java @@ -21,4 +21,8 @@ public User(String userName, String userId, String phoneNumber, String role, Str public String getPhonenumber() { return this.phonenumber; } public String getRole() { return this.role; } public String getPassword() { return this.password; } + + public void set_new_username(String new_user){ + this.user_name = new_user; + } } diff --git a/Answers/40230112081/Users.txt b/Answers/40230112081/Users.txt index e69de29..0f6bf68 100644 --- a/Answers/40230112081/Users.txt +++ b/Answers/40230112081/Users.txt @@ -0,0 +1 @@ +4990214560,Amir,9114434321,normal,Amir_1123 diff --git a/Answers/40230112081/out/production/40230112081/.idea/uiDesigner.xml b/Answers/40230112081/out/production/40230112081/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/Answers/40230112081/out/production/40230112081/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112081/out/production/40230112081/Admins.txt b/Answers/40230112081/out/production/40230112081/Admins.txt new file mode 100644 index 0000000..25610e6 --- /dev/null +++ b/Answers/40230112081/out/production/40230112081/Admins.txt @@ -0,0 +1,3 @@ +40230112081,Masoud,9121231234,admin,Masoud +40230112081,Amir1,9120719012,admin,1234 +1234512345,krm,9112342345,admin,1234 diff --git a/Answers/40230112081/out/production/40230112081/Book.class b/Answers/40230112081/out/production/40230112081/Book.class new file mode 100644 index 0000000000000000000000000000000000000000..ec3052e5ff194a317bd2610f73a5a38fa7b73a18 GIT binary patch literal 1329 zcmb_cT~8BH5IwhSx3t|tp{1~Zf{55IAJs>LlK2@(8hn6|_#!UL1{UkCX}9W6^1%m9 zXiR+Y2l%6mXYMu>%Rc&YXYTBrnYrgo_V=HkzW_YK{Q@!=%fYaag{e?JcR#w#wi}){ zUmc(OUaVj~48kDZQ5dT?4)YjCK8J#ZA}j^tNff9%A~SeTU5 zY#hXGUm{Z$rX^y!z4$EZNT_OIMnc6Czw32^4{;EM5}&m&r&GJJ8~3^rnzyikMTNZo zIq1fI==ln2SK&?ldjJ0w*=-#1txuy9_L^)3p}*IAf9!V-+~YPQ)2+yJ+lOu^kozEL z#AiX5Z)^!e+kF11AMcW-YQ1rNDur==J`jTVFuIR5GYS**pA9KVKJIHS6fAyxJ|uzi zkcN_XM)CZkgfNAf6k6mpm+EOaoJV*d;@Vv>}7vgfXYt9cSXT6V{v(ZP%+3ch2*hU`}$IkXq zb7ssw?C-kH63-R(2TCw7!HSbS%cx)q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x21yP=qY9^j?nyYcp77|zsd%}t*HHA|Kl9%S=2Z#LAMSzb6cO;u??j7Z-v zd5Jru<9z}1kn8jQa#g1b9Ut;pJ2)+anb>Ay+0Jwr#(dXovCD20%l2a1@x$0<&COBu zj*a*-j@?+p8G#+kIJsP^8qO}M&XVLBtnesgyzq&7f^WO}wXn7My7L=zHNa7DT-kRK z;>&b9;a6=_h&sP!V}1fBxmtx&m?a2}TXs>S6%aRn2ko%6%39r7zKAu&@6dVpD_9rN zJ+|`#de4c~Utz1Y?E-eFk)i@e4%dE*8-Q$S-P{-l8{@5wakw$wLGxV~aOZfz+IInW zpTlPbYwR0LoP)K1PRIx6=Fb$Yhm?H&^nzTCN0!4poLaZdVOzm^l=Ji0RInaf5Vk9; zDO%0V|Fp1g7OZl*Z_w4_bMreh{qx|4r#9w$xG^&~ZxyUd=$jQ#pn(4QlhZ8kTAH`w zdj%BV?_e9h{96PaJuqOC^&HmVT1sw52kzz*G=VN&+!l`UPe%po;A1`OvjNXyBVI)} zPGb|!pckLw3Ve<&_ySw;HIcq&@qZ-#&)AM%`2PQjKKzEA_#FjdpkH)hx7ftDZ8L5X zIX$c-Rq35wyw6-f52$Ri_~eO?n`)uc&~BQg4gkeLgegC;=PxCKfp(n8C-viPjC)B F{{jWc$A|y` delta 172 zcmZ1=`izO|)W2Q(7#J9A8AK*>nM{^tO`klURd%u+n?yZ>A_F@E6Htx;NHQ|8GOz(j zP9RSoNHYRyR;}#}j2pqyTtE^e%>cyQK#~Wd07&x!d7KP<4E#V5kY;VL8lXCKjVwqS S85sl^cm=^Kg@7azgD?PD=nc;R diff --git a/Answers/40230112081/out/production/40230112081/Rent.class b/Answers/40230112081/out/production/40230112081/Rent.class new file mode 100644 index 0000000000000000000000000000000000000000..4dd3fc47a6a827b804e35b8477442ba85c7fa44f GIT binary patch literal 775 zcmZvZ-A>y;5QWbsPMjDM0+|2OHf@2#&_?QQXfFUEAw{iJXzrcFN==O|8K=)xBmz<| z`T%{Xs%O>)Du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>3zGC&oKV3sV9#RO)_0a?so7B`T^0+g3$PypFHS&&&w9b^w1 zSdSpsOo)C~sF{omicqzF%wqKjwL)0cDnZl&P1FaP2yzFj))ofd4L}COLlBFEv1(Sv Us+k>0vl7@y5v;mZz;>tt0Q+YhQvd(} diff --git a/Answers/40230112081/out/production/40230112081/Users.txt b/Answers/40230112081/out/production/40230112081/Users.txt new file mode 100644 index 0000000..0f6bf68 --- /dev/null +++ b/Answers/40230112081/out/production/40230112081/Users.txt @@ -0,0 +1 @@ +4990214560,Amir,9114434321,normal,Amir_1123 diff --git a/Answers/40230112081/out/production/40230112081/Verifications.class b/Answers/40230112081/out/production/40230112081/Verifications.class new file mode 100644 index 0000000000000000000000000000000000000000..274a1fb0f993e7b836d2c87dcdbd066825aad52b GIT binary patch literal 3428 zcmd^C%X3p@6#w1i=Fv2LkdpL8c~zuoQu?5TwrPWHfD)QMXi5uI47bT`b4!|pJV5rW z-MLT~4vdZ)7P<+Jk1ia>g`?xjVO+X!;eWt53jV&EG)?;{T0S7b*yUcd!HOCS zYhlG2*9SvxdP@7K&6H0bGn^kU0kh|Q=K^q)svS6dE!gq3L*oIELV!;tRUd7QZ7&=QLB_)wUjzj*jQ1s3(888JC1NVrX&}YtR~*en{qy(F<3)*hq(M?GDeX~ z#L!U4so79`QAuiXC7)&`<){{qig?cngCdROmDu%ZC8Ni;V1bdA8O150T;$)BvY}SR za#jV|76R236$gYfZ>ptqcx8<2i^NMucFLTHYYLf+njKGO2wW~LmXuBa54m<~9 zfOofOqr0LC@De?bIVG37mCjakVvAVD`g8yNFYs@4$UNhRNziw4i^Y>p1UrX9nurnEQm>$J|GiD|Y`O6~k)?<1)l zB=Z0UNv5CcI1WSM*Db*{g(G;2U%0oqzK1S+2sa+`WAz#d6Qkav}SCB>B@J;IV+BrBs`!ey4A7T@9u_l(5#HI`|~ME4b5r)9!b-X#=W z@_&Q=qP%BN^OS)3uMmd?RtuW-Ck_5#!GXu>)Z2#hzo8e%a<(QjiXGO^E0(qThzb?IS%&q90{q>lOAr>6dsrHNaW1cEa5EnZU>`g1XvXed8&9x6v z9cedxI(dUiRN~7pQ0esnP6;uPt@K~hdwsi`#ZIE!&22C|6%)Ivo3&CCx8gb@8jxg^ zjY@Ie=Z!M=`#p{mMV!=!9!+BrBV%0m$=7HFJX|}92skE+IQ@U5ohJSlB8?1Tb+CLlXc_gPWQC#jcXSfDgscub_XpM= Bx7+{# literal 0 HcmV?d00001 diff --git a/Answers/40230112081/out/production/40230112081/myFileCLass.class b/Answers/40230112081/out/production/40230112081/myFileCLass.class index b6d2b754649e04f6f84e6a5792ad4e3029d39790..7b9ec2df49f13e882c5bdc7fe40d06acfd768c8b 100644 GIT binary patch literal 14670 zcmcIr34B!5x&OXoX6|HiF(D9OSVI6ME664$5FsHzFbO*tK*NwsU?7=^GZP?+iilWo z2T`Fd)-~3p6{`Wk)~%&3?dwkMX7{&rU*3Byt(y1$&OP_eOeVEbeLrR9+;h(T&N=^Y z`G4n}$s6yT`~nfp&qb1+l>g zBu3Zb?Kjtn?9nvFps^;6qXMS!N=z6XTDAnDv0!}4%6K5$8i=;mSkG9Ad-bY?&9j+C zTGL4GtUF;%g*3sSi6%{=^HZR-7R}_{9E?|Y$AgeJR?li6K}GAUWdV~-DxzWxy(1cm z2k||5eRa_qFO>oipL8fUX^JS#-O?V31r558X^4$T-O}2fEy2!sC=&M3RGMzm4C$KF z3HSk0pk>>tXrKiz&9YxoN>6%eCQUc!V!O2~9%`R5KN<~m*N0+pAI%o4nFDm~0Y&R8 zf`Qgx)JK(6CE#DeG`Ju5VnOqnhS_gbceS+zqrq1D&3RNKZ!W;Fi8rmr%Az$snnw#w zT11P1CG^}{9|{AQp_7Z!El8%g#H3599%dM5ZS7}gmUUMat&`c7i{SDsT1LwaT4B;k zT9vB5?pQq70XdN_I7GfU6{$_Ry%CsG%7Odn>r zfm#GaEO|r%#N;l5sl%i&MX-)gxHY(QDV#RNwQb1jWSlEaipn^HG0y5(Fd7bY1g$YdQrx62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 zkI?!P15v?)N^oiPa$C4+c>Kn3t>yvF@1G$FCSj3F=E$EXIXgelY?4zGT@}{^S6mxs zj|#W~0hb5O1a~*Nx+&zozKfh>viVXpK2{#pL`P5}u3s%lk2v6IN?Ojm_CdZdFL=<`&Mm5harm{KH zaV$3q9i18s12G)hgOc5>dR9pxU^@!^nTDrbPR%)$nwRxl%PdXl(9kXMdlZI}2bxIW zUWLxm=B!<`W-?~Asw0kI1Op1uTGeu^linjQ%Do{22@EsayzMH)eYi$J3}-uQQyNAU zdUr~==DOx)#;$rgMi7)rjv6?I&x*uN3kKh%y z$CoSXWygx(wYGs@GVPmA)=fS~<<1GU-;?YA70dmZe<@<^DhJjhp z_EWnkWiQl9s~mA$-6kvJwmi5fs#=Kc+v`E84&S$nG%wQ2EonidS6fm#w2kx2XV08Vgtl-Y-I>r6oprqN*ihd+|30DDaXH-~ Date: Tue, 2 Jul 2024 12:54:50 +0330 Subject: [PATCH 47/47] I forget this file, Sorry:_) --- Answers/40230112081/MyApp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Answers/40230112081/MyApp.java b/Answers/40230112081/MyApp.java index c7fde2b..a521ee3 100644 --- a/Answers/40230112081/MyApp.java +++ b/Answers/40230112081/MyApp.java @@ -7,7 +7,7 @@ public static void main(String[] args) throws IOException, InterruptedException Library lib = new Library("Nit central library", "7a.m.-7p.m.",100); Scanner scn = new Scanner(System.in); String cmd; - if(lib.isLibOpen()){ + if(!lib.isLibOpen()){ while (true){ System.out.print("\033[H\033[2J"); System.out.println("***************************************************");