├── Project ├── nbproject │ ├── private │ │ ├── config.properties │ │ ├── private.properties │ │ └── private.xml │ ├── genfiles.properties │ ├── project.xml │ └── project.properties ├── build │ └── classes │ │ ├── .netbeans_automatic_build │ │ ├── .netbeans_update_resources │ │ └── LMS │ │ ├── Book.class │ │ ├── Clerk.class │ │ ├── Loan.class │ │ ├── Main.class │ │ ├── Staff.class │ │ ├── Borrower.class │ │ ├── Library.class │ │ ├── Person.class │ │ ├── Librarian.class │ │ └── HoldRequest.class ├── derby.properties ├── manifest.mf ├── derbyclient-10.2.2.0.jar ├── src │ └── LMS │ │ ├── Staff.java │ │ ├── HoldRequestOperations.java │ │ ├── Clerk.java │ │ ├── HoldRequest.java │ │ ├── Librarian.java │ │ ├── Person.java │ │ ├── Loan.java │ │ ├── Borrower.java │ │ ├── Book.java │ │ ├── Main.java │ │ └── Library.java ├── build.xml └── derby.log ├── .gitattributes ├── Database ├── derby.properties ├── LMS │ ├── log │ │ ├── log.ctrl │ │ ├── log1.dat │ │ ├── logmirror.ctrl │ │ └── README_DO_NOT_TOUCH_FILES.txt │ ├── seg0 │ │ ├── c10.dat │ │ ├── c20.dat │ │ ├── c31.dat │ │ ├── c41.dat │ │ ├── c51.dat │ │ ├── c60.dat │ │ ├── c71.dat │ │ ├── c81.dat │ │ ├── c90.dat │ │ ├── ca1.dat │ │ ├── cb1.dat │ │ ├── cc0.dat │ │ ├── cd1.dat │ │ ├── ce1.dat │ │ ├── cf0.dat │ │ ├── c101.dat │ │ ├── c111.dat │ │ ├── c121.dat │ │ ├── c130.dat │ │ ├── c141.dat │ │ ├── c150.dat │ │ ├── c161.dat │ │ ├── c171.dat │ │ ├── c180.dat │ │ ├── c191.dat │ │ ├── c1a1.dat │ │ ├── c1b1.dat │ │ ├── c1c0.dat │ │ ├── c1d1.dat │ │ ├── c1e0.dat │ │ ├── c1f1.dat │ │ ├── c200.dat │ │ ├── c211.dat │ │ ├── c221.dat │ │ ├── c230.dat │ │ ├── c241.dat │ │ ├── c251.dat │ │ ├── c260.dat │ │ ├── c271.dat │ │ ├── c281.dat │ │ ├── c290.dat │ │ ├── c2a1.dat │ │ ├── c2b1.dat │ │ ├── c2c1.dat │ │ ├── c2d0.dat │ │ ├── c2e1.dat │ │ ├── c2f0.dat │ │ ├── c300.dat │ │ ├── c311.dat │ │ ├── c321.dat │ │ ├── c331.dat │ │ ├── c340.dat │ │ ├── c351.dat │ │ ├── c361.dat │ │ ├── c371.dat │ │ ├── c380.dat │ │ ├── c391.dat │ │ ├── c3a1.dat │ │ ├── c3b1.dat │ │ ├── c3c0.dat │ │ ├── c3d1.dat │ │ ├── c3e1.dat │ │ ├── c3f1.dat │ │ ├── c400.dat │ │ ├── c411.dat │ │ ├── c421.dat │ │ ├── c430.dat │ │ ├── c441.dat │ │ ├── c451.dat │ │ ├── c461.dat │ │ ├── c470.dat │ │ ├── c481.dat │ │ ├── c490.dat │ │ ├── c4a1.dat │ │ ├── c4b0.dat │ │ ├── c4c1.dat │ │ ├── c4d0.dat │ │ ├── c4e1.dat │ │ ├── c4f0.dat │ │ ├── c501.dat │ │ ├── c510.dat │ │ ├── c521.dat │ │ ├── c530.dat │ │ ├── c541.dat │ │ ├── c550.dat │ │ ├── c561.dat │ │ ├── c570.dat │ │ ├── c581.dat │ │ ├── c590.dat │ │ ├── c5a1.dat │ │ ├── c5b1.dat │ │ ├── c5c1.dat │ │ ├── c5d1.dat │ │ ├── c5e1.dat │ │ ├── c5f1.dat │ │ └── README_DO_NOT_TOUCH_FILES.txt │ ├── README_DO_NOT_TOUCH_FILES.txt │ └── service.properties └── derby.log ├── images ├── final.png ├── step1.PNG ├── step2.PNG ├── step3.PNG ├── diagram.PNG ├── interface.PNG └── interface2.PNG ├── .github └── FUNDING.yml ├── LICENSE ├── Database Schema.txt └── README.md /Project/nbproject/private/config.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Project/build/classes/.netbeans_automatic_build: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Project/build/classes/.netbeans_update_resources: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Database/derby.properties: -------------------------------------------------------------------------------- 1 | #Java DB Properties File 2 | #Mon Jul 02 20:52:21 PKT 2018 3 | -------------------------------------------------------------------------------- /Project/derby.properties: -------------------------------------------------------------------------------- 1 | #Java DB Properties File 2 | #Mon Jul 02 20:33:30 PKT 2018 3 | -------------------------------------------------------------------------------- /Project/manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /images/final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/images/final.png -------------------------------------------------------------------------------- /images/step1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/images/step1.PNG -------------------------------------------------------------------------------- /images/step2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/images/step2.PNG -------------------------------------------------------------------------------- /images/step3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/images/step3.PNG -------------------------------------------------------------------------------- /images/diagram.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/images/diagram.PNG -------------------------------------------------------------------------------- /images/interface.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/images/interface.PNG -------------------------------------------------------------------------------- /images/interface2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/images/interface2.PNG -------------------------------------------------------------------------------- /Database/LMS/log/log.ctrl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/log/log.ctrl -------------------------------------------------------------------------------- /Database/LMS/log/log1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/log/log1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c10.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c10.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c20.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c20.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c31.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c31.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c41.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c41.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c51.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c51.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c60.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c60.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c71.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c71.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c81.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c81.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c90.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c90.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/ca1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/ca1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/cb1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/cb1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/cc0.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/cc0.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/cd1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/cd1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/ce1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/ce1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/cf0.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/cf0.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c101.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c101.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c111.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c111.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c121.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c121.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c130.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c130.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c141.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c141.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c150.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c150.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c161.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c161.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c171.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c171.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c180.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c180.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c191.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c191.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c1a1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c1a1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c1b1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c1b1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c1c0.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c1c0.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c1d1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c1d1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c1e0.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c1e0.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c1f1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c1f1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c200.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c200.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c211.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c211.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c221.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c221.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c230.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c230.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c241.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c241.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c251.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c251.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c260.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c260.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c271.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c271.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c281.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c281.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c290.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c290.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c2a1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c2a1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c2b1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c2b1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c2c1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c2c1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c2d0.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c2d0.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c2e1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c2e1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c2f0.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c2f0.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c300.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c300.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c311.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c311.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c321.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c321.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c331.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c331.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c340.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c340.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c351.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c351.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c361.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c361.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c371.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c371.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c380.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c380.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c391.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c391.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c3a1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c3a1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c3b1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c3b1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c3c0.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c3c0.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c3d1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c3d1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c3e1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c3e1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c3f1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c3f1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c400.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c400.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c411.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c411.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c421.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c421.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c430.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c430.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c441.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c441.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c451.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c451.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c461.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c461.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c470.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c470.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c481.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c481.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c490.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c490.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c4a1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c4a1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c4b0.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c4b0.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c4c1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c4c1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c4d0.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c4d0.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c4e1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c4e1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c4f0.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c4f0.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c501.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c501.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c510.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c510.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c521.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c521.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c530.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c530.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c541.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c541.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c550.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c550.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c561.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c561.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c570.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c570.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c581.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c581.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c590.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c590.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c5a1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c5a1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c5b1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c5b1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c5c1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c5c1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c5d1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c5d1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c5e1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c5e1.dat -------------------------------------------------------------------------------- /Database/LMS/seg0/c5f1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/seg0/c5f1.dat -------------------------------------------------------------------------------- /Database/LMS/log/logmirror.ctrl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Database/LMS/log/logmirror.ctrl -------------------------------------------------------------------------------- /Project/derbyclient-10.2.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Project/derbyclient-10.2.2.0.jar -------------------------------------------------------------------------------- /Project/build/classes/LMS/Book.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Project/build/classes/LMS/Book.class -------------------------------------------------------------------------------- /Project/build/classes/LMS/Clerk.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Project/build/classes/LMS/Clerk.class -------------------------------------------------------------------------------- /Project/build/classes/LMS/Loan.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Project/build/classes/LMS/Loan.class -------------------------------------------------------------------------------- /Project/build/classes/LMS/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Project/build/classes/LMS/Main.class -------------------------------------------------------------------------------- /Project/build/classes/LMS/Staff.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Project/build/classes/LMS/Staff.class -------------------------------------------------------------------------------- /Project/build/classes/LMS/Borrower.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Project/build/classes/LMS/Borrower.class -------------------------------------------------------------------------------- /Project/build/classes/LMS/Library.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Project/build/classes/LMS/Library.class -------------------------------------------------------------------------------- /Project/build/classes/LMS/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Project/build/classes/LMS/Person.class -------------------------------------------------------------------------------- /Project/build/classes/LMS/Librarian.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Project/build/classes/LMS/Librarian.class -------------------------------------------------------------------------------- /Project/build/classes/LMS/HoldRequest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harismuneer/Library-Management-System-JAVA/HEAD/Project/build/classes/LMS/HoldRequest.class -------------------------------------------------------------------------------- /Project/nbproject/private/private.properties: -------------------------------------------------------------------------------- 1 | compile.on.save=true 2 | do.depend=false 3 | do.jar=true 4 | javac.debug=true 5 | javadoc.preview=true 6 | user.properties.file=C:\\Users\\PAKLAP.pk\\AppData\\Roaming\\NetBeans\\8.2\\build.properties 7 | -------------------------------------------------------------------------------- /Project/nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=507ddfa4 2 | build.xml.script.CRC32=5d5937f5 3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=507ddfa4 7 | nbproject/build-impl.xml.script.CRC32=0ebf329b 8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 9 | -------------------------------------------------------------------------------- /Project/src/LMS/Staff.java: -------------------------------------------------------------------------------- 1 | 2 | package LMS; 3 | 4 | public class Staff extends Person 5 | { 6 | protected double salary; 7 | 8 | public Staff(int id, String n, String a,int p, double s) 9 | { 10 | super(id,n,a,p); 11 | salary = s; 12 | } 13 | 14 | @Override 15 | public void printInfo() 16 | { 17 | super.printInfo(); 18 | System.out.println("Salary: " + salary + "\n"); 19 | } 20 | 21 | public double getSalary() 22 | { 23 | return salary; 24 | } 25 | } -------------------------------------------------------------------------------- /Database/LMS/log/README_DO_NOT_TOUCH_FILES.txt: -------------------------------------------------------------------------------- 1 | 2 | # ************************************************************************* 3 | # *** DO NOT TOUCH FILES IN THIS DIRECTORY! *** 4 | # *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE RECOVERY *** 5 | # *** SYSTEM. EDITING, ADDING, OR DELETING FILES IN THIS DIRECTORY *** 6 | # *** WILL CAUSE THE DERBY RECOVERY SYSTEM TO FAIL, LEADING TO *** 7 | # *** NON-RECOVERABLE CORRUPT DATABASES. *** 8 | # ************************************************************************* -------------------------------------------------------------------------------- /Database/LMS/seg0/README_DO_NOT_TOUCH_FILES.txt: -------------------------------------------------------------------------------- 1 | 2 | # ************************************************************************* 3 | # *** DO NOT TOUCH FILES IN THIS DIRECTORY! *** 4 | # *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE TO STORE *** 5 | # *** USER AND SYSTEM DATA. EDITING, ADDING, OR DELETING FILES IN THIS *** 6 | # *** DIRECTORY WILL CORRUPT THE ASSOCIATED DERBY DATABASE AND MAKE *** 7 | # *** IT NON-RECOVERABLE. *** 8 | # ************************************************************************* -------------------------------------------------------------------------------- /Project/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | Library Management System 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Project/nbproject/private/private.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | file:/D:/FAST/5th%20Semester%20%20%20%20(Fall%202017)/Object%20Oriented%20Analysis%20and%20Design/Assignments/Assignment%201/Library%20Management%20System/Project/src/LMS/Main.java 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Project/src/LMS/HoldRequestOperations.java: -------------------------------------------------------------------------------- 1 | package LMS; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class HoldRequestOperations { 6 | 7 | static ArrayList holdRequests; 8 | 9 | public HoldRequestOperations() 10 | { 11 | holdRequests= new ArrayList<>(); 12 | } 13 | // adding a hold req. 14 | public void addHoldRequest(HoldRequest hr) 15 | { 16 | holdRequests.add(hr); 17 | } 18 | // removing a hold req. 19 | public void removeHoldRequest() 20 | { 21 | if(!holdRequests.isEmpty()) 22 | { 23 | holdRequests.remove(0); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Database/LMS/README_DO_NOT_TOUCH_FILES.txt: -------------------------------------------------------------------------------- 1 | 2 | # ************************************************************************* 3 | # *** DO NOT TOUCH FILES IN THIS DIRECTORY! *** 4 | # *** FILES IN THIS DIRECTORY AND SUBDIRECTORIES CONSTITUTE A DERBY *** 5 | # *** DATABASE, WHICH INCLUDES THE DATA (USER AND SYSTEM) AND THE *** 6 | # *** FILES NECESSARY FOR DATABASE RECOVERY. *** 7 | # *** EDITING, ADDING, OR DELETING ANY OF THESE FILES MAY CAUSE DATA *** 8 | # *** CORRUPTION AND LEAVE THE DATABASE IN A NON-RECOVERABLE STATE. *** 9 | # ************************************************************************* -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ['https://www.cyfylabs.com'] 13 | -------------------------------------------------------------------------------- /Project/src/LMS/Clerk.java: -------------------------------------------------------------------------------- 1 | 2 | package LMS; 3 | 4 | public class Clerk extends Staff { 5 | 6 | int deskNo; //Desk Number of the Clerk 7 | public static int currentdeskNumber = 0; 8 | 9 | public Clerk(int id, String n, String a,int ph, double s,int dk) // para cons. 10 | { 11 | super(id,n,a,ph,s); 12 | 13 | if(dk == -1) 14 | { 15 | deskNo = currentdeskNumber; 16 | } 17 | else 18 | { 19 | deskNo=dk; 20 | } 21 | 22 | currentdeskNumber++; 23 | } 24 | 25 | // Printing Clerk's Info 26 | @Override 27 | public void printInfo() 28 | { 29 | super.printInfo(); 30 | System.out.println("Desk Number: " + deskNo); 31 | } 32 | 33 | } // Clerk's Class Closed -------------------------------------------------------------------------------- /Project/src/LMS/HoldRequest.java: -------------------------------------------------------------------------------- 1 | package LMS; 2 | 3 | import java.util.Date; 4 | 5 | public class HoldRequest { 6 | 7 | Borrower borrower; 8 | Book book; 9 | Date requestDate; 10 | 11 | public HoldRequest(Borrower bor, Book b, Date reqDate) // para cons. 12 | { 13 | borrower = bor; 14 | book = b; 15 | requestDate = reqDate; 16 | } 17 | 18 | /*----- Getter FUNCs.--------*/ 19 | public Borrower getBorrower() 20 | { 21 | return borrower; 22 | } 23 | 24 | public Book getBook() 25 | { 26 | return book; 27 | } 28 | 29 | public Date getRequestDate() 30 | { 31 | return requestDate; 32 | } 33 | /*--------------------------*/ 34 | 35 | // Print Hold Request Info 36 | public void print() 37 | { 38 | System.out.print(book.getTitle() + "\t\t\t\t" + borrower.getName() + "\t\t\t\t" + requestDate + "\n"); 39 | } 40 | }// HoldRequest Class Closed 41 | -------------------------------------------------------------------------------- /Database/LMS/service.properties: -------------------------------------------------------------------------------- 1 | #D:\FAST\5th Semester (Fall 2017)\Object Oriented Analysis and Design\Assignments\Assignment 1\Library Management System\Database\LMS 2 | # ******************************************************************** 3 | # *** Please do NOT edit this file. *** 4 | # *** CHANGING THE CONTENT OF THIS FILE MAY CAUSE DATA CORRUPTION. *** 5 | # ******************************************************************** 6 | #Mon Jul 02 20:52:30 PKT 2018 7 | SysschemasIndex2Identifier=225 8 | SyscolumnsIdentifier=144 9 | SysconglomeratesIndex1Identifier=49 10 | SysconglomeratesIdentifier=32 11 | SyscolumnsIndex2Identifier=177 12 | SysschemasIndex1Identifier=209 13 | SysconglomeratesIndex3Identifier=81 14 | SystablesIndex2Identifier=129 15 | SyscolumnsIndex1Identifier=161 16 | derby.serviceProtocol=org.apache.derby.database.Database 17 | SysschemasIdentifier=192 18 | derby.storage.propertiesId=16 19 | SysconglomeratesIndex2Identifier=65 20 | derby.serviceLocale=en_US 21 | SystablesIdentifier=96 22 | SystablesIndex1Identifier=113 23 | #--- last line, don't put anything after this line --- 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 harismuneer, MahamAmjad 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Project/src/LMS/Librarian.java: -------------------------------------------------------------------------------- 1 | 2 | package LMS; 3 | 4 | import static LMS.Library.librarian; 5 | import static LMS.Library.persons; 6 | 7 | public class Librarian extends Staff { 8 | 9 | int officeNo; //Office Number of the Librarian 10 | public static int currentOfficeNumber = 0; 11 | 12 | public Librarian(int id, String n, String a, int p, double s, int of) // para cons. 13 | { 14 | super(id, n, a, p, s); 15 | 16 | if (of == -1) 17 | officeNo = currentOfficeNumber; 18 | else 19 | officeNo = of; 20 | 21 | currentOfficeNumber++; 22 | } 23 | 24 | // Printing Librarian's Info 25 | @Override 26 | public void printInfo() { 27 | super.printInfo(); 28 | System.out.println("Office Number: " + officeNo); 29 | } 30 | 31 | public static boolean addLibrarian(Librarian lib) { 32 | //One Library can have only one Librarian 33 | if (librarian == null) { 34 | librarian = lib; 35 | persons.add(librarian); 36 | return true; 37 | } else 38 | System.out.println("\nSorry, the library already has one librarian. New Librarian can't be created."); 39 | return false; 40 | } 41 | } -------------------------------------------------------------------------------- /Database/derby.log: -------------------------------------------------------------------------------- 1 | Mon Jul 02 21:05:14 PKT 2018 : Apache Derby Network Server - 10.11.1.2 - (1629631) started and ready to accept connections on port 1527 2 | ---------------------------------------------------------------- 3 | Mon Jul 02 21:05:14 PKT 2018: 4 | Booting Derby version The Apache Software Foundation - Apache Derby - 10.11.1.2 - (1629631): instance a816c00e-0164-5bbd-9799-ffffa03760cf 5 | on database directory D:\FAST\5th Semester (Fall 2017)\Object Oriented Analysis and Design\Assignments\Assignment 1\Library Management System\Database\LMS with class loader sun.misc.Launcher$AppClassLoader@1d44bcfa 6 | Loaded from file:/C:/Program%20Files/Java/jdk1.8.0_171/db/lib/derby.jar 7 | java.vendor=Oracle Corporation 8 | java.runtime.version=1.8.0_171-b11 9 | user.dir=C:\Program Files\Java\jdk1.8.0_171\db 10 | os.name=Windows 10 11 | os.arch=amd64 12 | os.version=10.0 13 | derby.system.home=D:\FAST\5th Semester (Fall 2017)\Object Oriented Analysis and Design\Assignments\Assignment 1\Library Management System\Database 14 | Database Class Loader started - derby.database.classpath='' 15 | ---------------------------------------------------------------- 16 | Mon Jul 02 23:13:50 PKT 2018: Shutting down Derby engine 17 | ---------------------------------------------------------------- 18 | Mon Jul 02 23:13:50 PKT 2018: 19 | Shutting down instance a816c00e-0164-5bbd-9799-ffffa03760cf on database directory D:\FAST\5th Semester (Fall 2017)\Object Oriented Analysis and Design\Assignments\Assignment 1\Library Management System\Database\LMS with class loader sun.misc.Launcher$AppClassLoader@1d44bcfa 20 | ---------------------------------------------------------------- 21 | -------------------------------------------------------------------------------- /Project/src/LMS/Person.java: -------------------------------------------------------------------------------- 1 | 2 | package LMS; 3 | 4 | public abstract class Person 5 | { 6 | protected int id; // ID of every person related to library 7 | protected String password; // Password of every person related to library 8 | protected String name; // Name of every person related to library 9 | protected String address; // Address of every person related to library 10 | protected int phoneNo; // PhoneNo of every person related to library 11 | 12 | static int currentIdNumber = 0; //This will be unique for every person, since it will be incremented when everytime 13 | //when a person is created 14 | 15 | public Person(int idNum, String name, String address, int phoneNum) // para cons. 16 | { 17 | currentIdNumber++; 18 | 19 | if(idNum==-1) 20 | { 21 | id = currentIdNumber; 22 | } 23 | else 24 | id = idNum; 25 | 26 | password = Integer.toString(id); 27 | this.name = name; 28 | this.address = address; 29 | phoneNo = phoneNum; 30 | } 31 | 32 | // Printing Info of a Person 33 | public void printInfo() 34 | { 35 | System.out.println("-----------------------------------------"); 36 | System.out.println("\nThe details are: \n"); 37 | System.out.println("ID: " + id); 38 | System.out.println("Name: " + name); 39 | System.out.println("Address: " + address); 40 | System.out.println("Phone No: " + phoneNo + "\n"); 41 | } 42 | 43 | /*---------Setter FUNCs.---------*/ 44 | public void setAddress(String a) 45 | { 46 | address = a; 47 | } 48 | 49 | public void setPhone(int p) 50 | { 51 | phoneNo = p; 52 | } 53 | 54 | public void setName(String n) 55 | { 56 | name = n; 57 | } 58 | /*----------------------------*/ 59 | 60 | /*-------Getter FUNCs.--------*/ 61 | public String getName() 62 | { 63 | return name; 64 | } 65 | 66 | public String getPassword() 67 | { 68 | return password; 69 | } 70 | 71 | public String getAddress() 72 | { 73 | return address; 74 | } 75 | 76 | public int getPhoneNumber() 77 | { 78 | return phoneNo; 79 | } 80 | public int getID() 81 | { 82 | return id; 83 | } 84 | /*---------------------------*/ 85 | 86 | public static void setIDCount(int n) 87 | { 88 | currentIdNumber=n; 89 | } 90 | 91 | } // Person Class Closed 92 | -------------------------------------------------------------------------------- /Database Schema.txt: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE PERSON 3 | ( 4 | "ID" INTEGER not null PRIMARY KEY, 5 | "PNAME" VARCHAR(30) not null, 6 | "PASSWORD" VARCHAR(10) not null, 7 | "ADDRESS" VARCHAR(30) not null, 8 | "PHONE_NO" INTEGER not null 9 | ); 10 | 11 | 12 | CREATE TABLE BOOK 13 | ( 14 | "ID" INTEGER not null PRIMARY KEY, 15 | "TITLE" VARCHAR(30) not null, 16 | "AUTHOR" VARCHAR(20) not null, 17 | "SUBJECT" VARCHAR(20) not null, 18 | "IS_ISSUED" BOOLEAN not null 19 | 20 | ); 21 | 22 | CREATE TABLE STAFF 23 | ( 24 | "S_ID" INTEGER not null PRIMARY KEY, 25 | "TYPE" VARCHAR(10) not null, 26 | "SALARY" DOUBLE 27 | ); 28 | 29 | CREATE TABLE CLERK 30 | ( 31 | "C_ID" INTEGER not null PRIMARY KEY, 32 | "DESK_NO" INTEGER not null 33 | ); 34 | 35 | CREATE TABLE LIBRARIAN 36 | ( 37 | "L_ID" INTEGER not null PRIMARY KEY, 38 | "OFFICE_NO" INTEGER not null 39 | ); 40 | 41 | 42 | CREATE TABLE BORROWER 43 | ( 44 | "B_ID" INTEGER not null PRIMARY KEY 45 | 46 | ); 47 | 48 | CREATE TABLE BORROWED_BOOK 49 | ( 50 | "BOOK" INTEGER not null PRIMARY KEY, 51 | "BORROWER" INTEGER not null 52 | ); 53 | 54 | CREATE TABLE LOAN 55 | ( 56 | "L_ID" INTEGER not null PRIMARY KEY, 57 | "BORROWER" INTEGER not null, 58 | "BOOK" INTEGER not null, 59 | "ISSUER" INTEGER not null, 60 | "ISS_DATE" TIMESTAMP not null, 61 | "RECEIVER" INTEGER , 62 | "RET_DATE" TIMESTAMP , 63 | "FINE_PAID" BOOLEAN 64 | ); 65 | 66 | CREATE TABLE ON_HOLD_BOOK 67 | ( 68 | "REQ_ID" INTEGER not null PRIMARY KEY, 69 | "BOOK" INTEGER not null, 70 | "BORROWER" INTEGER not null, 71 | "REQ_DATE" DATE not null 72 | ); 73 | 74 | ----------------------------------------FOREIGN KEY CONSTRAINTS---------------------------- 75 | 76 | ALTER TABLE BORROWED_BOOK 77 | ADD 78 | FOREIGN KEY (BORROWER)REFERENCES BORROWER(B_ID); 79 | 80 | 81 | ALTER TABLE LOAN 82 | ADD 83 | FOREIGN KEY (BORROWER)REFERENCES BORROWER(B_ID); 84 | 85 | ALTER TABLE LOAN 86 | ADD 87 | FOREIGN KEY (ISSUER)REFERENCES STAFF(S_ID); 88 | 89 | ALTER TABLE LOAN 90 | ADD 91 | FOREIGN KEY (RECEIVER)REFERENCES STAFF(S_ID); 92 | 93 | 94 | ALTER TABLE ON_HOLD_BOOK 95 | ADD 96 | FOREIGN KEY (BORROWER)REFERENCES BORROWER(B_ID); 97 | 98 | ALTER TABLE LIBRARIAN 99 | ADD 100 | FOREIGN KEY (L_ID)REFERENCES STAFF(S_ID); 101 | 102 | ALTER TABLE CLERK 103 | ADD 104 | FOREIGN KEY (C_ID)REFERENCES STAFF(S_ID); 105 | 106 | ALTER TABLE STAFF 107 | ADD 108 | FOREIGN KEY (S_ID)REFERENCES PERSON(ID); 109 | 110 | ALTER TABLE BORROWER 111 | ADD 112 | FOREIGN KEY (B_ID)REFERENCES PERSON(ID); 113 | 114 | ------------------------------------------------------------- 115 | 116 | 117 | -------------------------------------------------------------------------------- /Project/nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processors.list= 4 | annotation.processing.run.all.processors=true 5 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 6 | application.title=Library Management System 7 | application.vendor=PAKLAP.pk 8 | build.classes.dir=${build.dir}/classes 9 | build.classes.excludes=**/*.java,**/*.form 10 | # This directory is removed when the project is cleaned: 11 | build.dir=build 12 | build.generated.dir=${build.dir}/generated 13 | build.generated.sources.dir=${build.dir}/generated-sources 14 | # Only compile against the classpath explicitly listed here: 15 | build.sysclasspath=ignore 16 | build.test.classes.dir=${build.dir}/test/classes 17 | build.test.results.dir=${build.dir}/test/results 18 | # Uncomment to specify the preferred debugger connection transport: 19 | #debug.transport=dt_socket 20 | debug.classpath=\ 21 | ${run.classpath} 22 | debug.test.classpath=\ 23 | ${run.test.classpath} 24 | # Files in build.classes.dir which should be excluded from distribution jar 25 | dist.archive.excludes= 26 | # This directory is removed when the project is cleaned: 27 | dist.dir=dist 28 | dist.jar=${dist.dir}/Library_Management_System.jar 29 | dist.javadoc.dir=${dist.dir}/javadoc 30 | endorsed.classpath= 31 | excludes= 32 | file.reference.derbyclient-10.2.2.0.jar=derbyclient-10.2.2.0.jar 33 | includes=** 34 | jar.compress=false 35 | javac.classpath=\ 36 | ${file.reference.derbyclient-10.2.2.0.jar} 37 | # Space-separated list of extra javac options 38 | javac.compilerargs= 39 | javac.deprecation=false 40 | javac.external.vm=true 41 | javac.processorpath=\ 42 | ${javac.classpath} 43 | javac.source=1.8 44 | javac.target=1.8 45 | javac.test.classpath=\ 46 | ${javac.classpath}:\ 47 | ${build.classes.dir} 48 | javac.test.processorpath=\ 49 | ${javac.test.classpath} 50 | javadoc.additionalparam= 51 | javadoc.author=false 52 | javadoc.encoding=${source.encoding} 53 | javadoc.noindex=false 54 | javadoc.nonavbar=false 55 | javadoc.notree=false 56 | javadoc.private=false 57 | javadoc.splitindex=true 58 | javadoc.use=true 59 | javadoc.version=false 60 | javadoc.windowtitle= 61 | main.class=LMS.Main 62 | manifest.file=manifest.mf 63 | meta.inf.dir=${src.dir}/META-INF 64 | mkdist.disabled=false 65 | platform.active=default_platform 66 | run.classpath=\ 67 | ${javac.classpath}:\ 68 | ${build.classes.dir} 69 | # Space-separated list of JVM arguments used when running the project. 70 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. 71 | # To set system properties for unit tests define test-sys-prop.name=value: 72 | run.jvmargs= 73 | run.test.classpath=\ 74 | ${javac.test.classpath}:\ 75 | ${build.test.classes.dir} 76 | source.encoding=UTF-8 77 | src.dir=src 78 | test.src.dir=test 79 | -------------------------------------------------------------------------------- /Project/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Builds, tests, and runs the project Library Management System. 12 | 13 | 73 | 74 | -------------------------------------------------------------------------------- /Project/src/LMS/Loan.java: -------------------------------------------------------------------------------- 1 | 2 | package LMS; 3 | 4 | import java.time.temporal.ChronoUnit; 5 | import java.util.Date; 6 | import java.util.Scanner; 7 | 8 | public class Loan 9 | { 10 | private Borrower borrower; 11 | private Book book; 12 | 13 | private Staff issuer; 14 | private Date issuedDate; 15 | 16 | private Date dateReturned; 17 | private Staff receiver; 18 | 19 | private boolean finePaid; 20 | 21 | public Loan(Borrower bor, Book b, Staff i, Staff r, Date iDate, Date rDate, boolean fPaid) // Para cons. 22 | { 23 | borrower = bor; 24 | book = b; 25 | issuer = i; 26 | receiver = r; 27 | issuedDate = iDate; 28 | dateReturned = rDate; 29 | 30 | finePaid = fPaid; 31 | } 32 | 33 | /*----- Getter FUNCs.------------*/ 34 | 35 | public Book getBook() //Returns the book 36 | { 37 | return book; 38 | } 39 | 40 | public Staff getIssuer() //Returns the Staff Member who issued the book 41 | { 42 | return issuer; 43 | } 44 | 45 | public Staff getReceiver() //Returns the Staff Member to whom book is returned 46 | { 47 | return receiver; 48 | } 49 | 50 | public Date getIssuedDate() //Returns the date on which this particular book was issued 51 | { 52 | return issuedDate; 53 | } 54 | 55 | public Date getReturnDate() //Returns the date on which this particular book was returned 56 | { 57 | return dateReturned; 58 | } 59 | 60 | public Borrower getBorrower() //Returns the Borrower to whom the book was issued 61 | { 62 | return borrower; 63 | } 64 | 65 | public boolean getFineStatus() // Returns status of fine 66 | { 67 | return finePaid; 68 | } 69 | /*---------------------------------------------*/ 70 | 71 | 72 | /*----------Setter FUNCs.---------------------*/ 73 | public void setReturnedDate(Date dReturned) 74 | { 75 | dateReturned = dReturned; 76 | } 77 | 78 | public void setFineStatus(boolean fStatus) 79 | { 80 | finePaid = fStatus; 81 | } 82 | 83 | public void setReceiver(Staff r) 84 | { 85 | receiver = r; 86 | } 87 | /*-------------------------------------------*/ 88 | 89 | 90 | 91 | 92 | //Computes fine for a particular loan only 93 | public double computeFine1() 94 | { 95 | 96 | //-----------Computing Fine----------- 97 | double totalFine = 0; 98 | 99 | if (!finePaid) 100 | { 101 | Date iDate = issuedDate; 102 | Date rDate = new Date(); 103 | 104 | long days = ChronoUnit.DAYS.between(rDate.toInstant(), iDate.toInstant()); 105 | days=0-days; 106 | 107 | days = days - Library.getInstance().book_return_deadline; 108 | 109 | if(days>0) 110 | totalFine = days * Library.getInstance().per_day_fine; 111 | else 112 | totalFine=0; 113 | } 114 | return totalFine; 115 | } 116 | 117 | 118 | public void payFine() 119 | { 120 | //-----------Computing Fine-----------// 121 | 122 | double totalFine = computeFine1(); 123 | 124 | if (totalFine > 0) 125 | { 126 | System.out.println("\nTotal Fine generated: Rs " + totalFine); 127 | 128 | System.out.println("Do you want to pay? (y/n)"); 129 | 130 | Scanner input = new Scanner(System.in); 131 | 132 | String choice = input.next(); 133 | 134 | if(choice.equals("y") || choice.equals("Y")) 135 | finePaid = true; 136 | 137 | if(choice.equals("n") || choice.equals("N")) 138 | finePaid = false; 139 | } 140 | else 141 | { 142 | System.out.println("\nNo fine is generated."); 143 | finePaid = true; 144 | } 145 | } 146 | 147 | 148 | // Extending issued Date 149 | public void renewIssuedBook(Date iDate) 150 | { 151 | issuedDate = iDate; 152 | 153 | System.out.println("\nThe deadline of the book " + getBook().getTitle() + " has been extended."); 154 | System.out.println("Issued Book is successfully renewed!\n"); 155 | } 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | } // Loan class Closed 170 | -------------------------------------------------------------------------------- /Project/src/LMS/Borrower.java: -------------------------------------------------------------------------------- 1 | 2 | package LMS; 3 | 4 | import java.io.*; 5 | import java.util.*; 6 | 7 | public class Borrower extends Person 8 | { 9 | private ArrayList borrowedBooks; //Those books which are currently borrowed by this borrower 10 | private ArrayList onHoldBooks; //Those books which are currently requested by this borrower to be on hold 11 | 12 | 13 | 14 | public Borrower(int id,String name, String address, int phoneNum) // para. cons 15 | { 16 | super(id,name,address,phoneNum); 17 | 18 | borrowedBooks = new ArrayList(); 19 | onHoldBooks = new ArrayList(); 20 | } 21 | 22 | 23 | // Printing Borrower's Info 24 | @Override 25 | public void printInfo() 26 | { 27 | super.printInfo(); 28 | 29 | printBorrowedBooks(); 30 | printOnHoldBooks(); 31 | } 32 | 33 | // Printing Book's Info Borrowed by Borrower 34 | public void printBorrowedBooks() 35 | { 36 | if (!borrowedBooks.isEmpty()) 37 | { 38 | System.out.println("\nBorrowed Books are: "); 39 | 40 | System.out.println("------------------------------------------------------------------------------"); 41 | System.out.println("No.\t\tTitle\t\t\tAuthor\t\t\tSubject"); 42 | System.out.println("------------------------------------------------------------------------------"); 43 | 44 | for (int i = 0; i < borrowedBooks.size(); i++) 45 | { 46 | System.out.print(i + "-" + "\t\t"); 47 | borrowedBooks.get(i).getBook().printInfo(); 48 | System.out.print("\n"); 49 | } 50 | } 51 | else 52 | System.out.println("\nNo borrowed books."); 53 | } 54 | 55 | // Printing Book's Info kept on Hold by Borrower 56 | public void printOnHoldBooks() 57 | { 58 | if (!onHoldBooks.isEmpty()) 59 | { 60 | System.out.println("\nOn Hold Books are: "); 61 | 62 | System.out.println("------------------------------------------------------------------------------"); 63 | System.out.println("No.\t\tTitle\t\t\tAuthor\t\t\tSubject"); 64 | System.out.println("------------------------------------------------------------------------------"); 65 | 66 | for (int i = 0; i < onHoldBooks.size(); i++) 67 | { 68 | System.out.print(i + "-" + "\t\t"); 69 | onHoldBooks.get(i).getBook().printInfo(); 70 | System.out.print("\n"); 71 | } 72 | } 73 | else 74 | System.out.println("\nNo On Hold books."); 75 | } 76 | 77 | // Updating Borrower's Info 78 | public void updateBorrowerInfo() throws IOException 79 | { 80 | String choice; 81 | 82 | Scanner sc = new Scanner(System.in); 83 | BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 84 | 85 | 86 | System.out.println("\nDo you want to update " + getName() + "'s Name ? (y/n)"); 87 | choice = sc.next(); 88 | 89 | updateBorrowerName(choice, reader); 90 | 91 | 92 | System.out.println("\nDo you want to update " + getName() + "'s Address ? (y/n)"); 93 | choice = sc.next(); 94 | 95 | updateBorrowerAddress(choice, reader); 96 | 97 | System.out.println("\nDo you want to update " + getName() + "'s Phone Number ? (y/n)"); 98 | choice = sc.next(); 99 | 100 | updateBorrowerPhoneNumber(choice, sc); 101 | 102 | System.out.println("\nBorrower is successfully updated."); 103 | 104 | } 105 | 106 | private void updateBorrowerPhoneNumber(String choice, Scanner sc) { 107 | if(choice.equals("y")) 108 | { 109 | System.out.println("\nType New Phone Number: "); 110 | setPhone(sc.nextInt()); 111 | System.out.println("\nThe phone number is successfully updated."); 112 | } 113 | } 114 | 115 | private void updateBorrowerAddress(String choice, BufferedReader reader) throws IOException { 116 | if(choice.equals("y")) 117 | { 118 | System.out.println("\nType New Address: "); 119 | setAddress(reader.readLine()); 120 | System.out.println("\nThe address is successfully updated."); 121 | } 122 | } 123 | 124 | private void updateBorrowerName(String choice, BufferedReader reader) throws IOException { 125 | if(choice.equals("y")) 126 | { 127 | System.out.println("\nType New Name: "); 128 | setName(reader.readLine()); 129 | System.out.println("\nThe name is successfully updated."); 130 | } 131 | } 132 | 133 | /*-- Adding and Removing from Borrowed Books---*/ 134 | public void addBorrowedBook(Loan iBook) 135 | { 136 | borrowedBooks.add(iBook); 137 | } 138 | 139 | public void removeBorrowedBook(Loan iBook) 140 | { 141 | borrowedBooks.remove(iBook); 142 | } 143 | 144 | /*-------------------------------------------*/ 145 | 146 | /*-- Adding and Removing from On Hold Books---*/ 147 | public void addHoldRequest(HoldRequest hr) 148 | { 149 | onHoldBooks.add(hr); 150 | } 151 | 152 | public void removeHoldRequest(HoldRequest hr) 153 | { 154 | onHoldBooks.remove(hr); 155 | } 156 | 157 | /*-------------------------------------------*/ 158 | 159 | /*-----------Getter FUNCs. ------------------*/ 160 | public ArrayList getBorrowedBooks() 161 | { 162 | return borrowedBooks; 163 | } 164 | 165 | public ArrayList getOnHoldBooks() 166 | { 167 | return onHoldBooks; 168 | } 169 | /*-------------------------------------------*/ 170 | } 171 | -------------------------------------------------------------------------------- /Project/derby.log: -------------------------------------------------------------------------------- 1 | Mon Jul 02 20:43:27 PKT 2018 : Apache Derby Network Server - 10.11.1.2 - (1629631) started and ready to accept connections on port 1527 2 | ---------------------------------------------------------------- 3 | Mon Jul 02 20:43:28 PKT 2018: 4 | Booting Derby version The Apache Software Foundation - Apache Derby - 10.11.1.2 - (1629631): instance a816c00e-0164-5ba9-a8a5-00007b18d1a8 5 | on database directory D:\FAST\5th Semester (Fall 2017)\Object Oriented Analysis and Design\Assignments\Library Management System\Library Management System with class loader sun.misc.Launcher$AppClassLoader@1d44bcfa 6 | Loaded from file:/C:/Program%20Files/Java/jdk1.8.0_171/db/lib/derby.jar 7 | java.vendor=Oracle Corporation 8 | java.runtime.version=1.8.0_171-b11 9 | user.dir=C:\Program Files\Java\jdk1.8.0_171\db 10 | os.name=Windows 10 11 | os.arch=amd64 12 | os.version=10.0 13 | derby.system.home=D:\FAST\5th Semester (Fall 2017)\Object Oriented Analysis and Design\Assignments\Library Management System 14 | Database Class Loader started - derby.database.classpath='' 15 | Mon Jul 02 20:43:28 PKT 2018 Thread[DRDAConnThread_2,5,main] (XID = 408), (SESSIONID = 0), (DATABASE = Library Management System), (DRDAID = {1}), Cleanup action starting 16 | java.sql.SQLNonTransientConnectionException: Connection authentication failure occurred. Reason: Invalid authentication.. 17 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) 18 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) 19 | at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) 20 | at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) 21 | at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source) 22 | at org.apache.derby.impl.jdbc.EmbedConnection.checkUserCredentials(Unknown Source) 23 | at org.apache.derby.impl.jdbc.EmbedConnection.(Unknown Source) 24 | at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source) 25 | at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) 26 | at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) 27 | at org.apache.derby.jdbc.EmbeddedDriver.connect(Unknown Source) 28 | at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source) 29 | at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source) 30 | at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source) 31 | at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source) 32 | at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source) 33 | at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source) 34 | at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source) 35 | Caused by: ERROR 08004: Connection authentication failure occurred. Reason: Invalid authentication.. 36 | at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) 37 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source) 38 | ... 18 more 39 | ============= begin nested exception, level (1) =========== 40 | ERROR 08004: Connection authentication failure occurred. Reason: Invalid authentication.. 41 | at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) 42 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source) 43 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) 44 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) 45 | at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) 46 | at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) 47 | at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source) 48 | at org.apache.derby.impl.jdbc.EmbedConnection.checkUserCredentials(Unknown Source) 49 | at org.apache.derby.impl.jdbc.EmbedConnection.(Unknown Source) 50 | at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source) 51 | at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) 52 | at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) 53 | at org.apache.derby.jdbc.EmbeddedDriver.connect(Unknown Source) 54 | at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source) 55 | at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source) 56 | at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source) 57 | at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source) 58 | at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source) 59 | at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source) 60 | at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source) 61 | ============= end nested exception, level (1) =========== 62 | Cleanup action completed 63 | Mon Jul 02 20:43:28 PKT 2018 Thread[DRDAConnThread_2,5,main] (DATABASE = Library Management System), (DRDAID = {1}), Connection authentication failure occurred. Reason: Invalid authentication.. 64 | Mon Jul 02 20:43:38 PKT 2018 Thread[DRDAConnThread_2,5,main] (XID = 409), (SESSIONID = 1), (DATABASE = Library Management System), (DRDAID = {2}), Cleanup action starting 65 | java.sql.SQLNonTransientConnectionException: Connection authentication failure occurred. Reason: Invalid authentication.. 66 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) 67 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) 68 | at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) 69 | at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) 70 | at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source) 71 | at org.apache.derby.impl.jdbc.EmbedConnection.checkUserCredentials(Unknown Source) 72 | at org.apache.derby.impl.jdbc.EmbedConnection.(Unknown Source) 73 | at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source) 74 | at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) 75 | at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) 76 | at org.apache.derby.jdbc.EmbeddedDriver.connect(Unknown Source) 77 | at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source) 78 | at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source) 79 | at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source) 80 | at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source) 81 | at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source) 82 | at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source) 83 | at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source) 84 | Caused by: ERROR 08004: Connection authentication failure occurred. Reason: Invalid authentication.. 85 | at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) 86 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source) 87 | ... 18 more 88 | ============= begin nested exception, level (1) =========== 89 | ERROR 08004: Connection authentication failure occurred. Reason: Invalid authentication.. 90 | at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) 91 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source) 92 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) 93 | at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) 94 | at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) 95 | at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) 96 | at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source) 97 | at org.apache.derby.impl.jdbc.EmbedConnection.checkUserCredentials(Unknown Source) 98 | at org.apache.derby.impl.jdbc.EmbedConnection.(Unknown Source) 99 | at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source) 100 | at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) 101 | at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) 102 | at org.apache.derby.jdbc.EmbeddedDriver.connect(Unknown Source) 103 | at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source) 104 | at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source) 105 | at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source) 106 | at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source) 107 | at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source) 108 | at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source) 109 | at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source) 110 | ============= end nested exception, level (1) =========== 111 | Cleanup action completed 112 | Mon Jul 02 20:43:38 PKT 2018 Thread[DRDAConnThread_2,5,main] (DATABASE = Library Management System), (DRDAID = {2}), Connection authentication failure occurred. Reason: Invalid authentication.. 113 | ---------------------------------------------------------------- 114 | Mon Jul 02 20:44:22 PKT 2018: Shutting down Derby engine 115 | ---------------------------------------------------------------- 116 | Mon Jul 02 20:44:22 PKT 2018: 117 | Shutting down instance a816c00e-0164-5ba9-a8a5-00007b18d1a8 on database directory D:\FAST\5th Semester (Fall 2017)\Object Oriented Analysis and Design\Assignments\Library Management System\Library Management System with class loader sun.misc.Launcher$AppClassLoader@1d44bcfa 118 | ---------------------------------------------------------------- 119 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 📚 Library Management System -Java 2 | 3 | 4 | views 5 | [![Open Source Love svg1](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](#) 6 | [![GitHub Forks](https://img.shields.io/github/forks/harismuneer/Library-Management-System-JAVA.svg?style=social&label=Fork&maxAge=2592000)](https://www.github.com/harismuneer/Library-Management-System-JAVA/fork) 7 | [![GitHub Issues](https://img.shields.io/github/issues/harismuneer/Library-Management-System-JAVA.svg?style=flat&label=Issues&maxAge=2592000)](https://www.github.com/harismuneer/Library-Management-System-JAVA/issues) 8 | [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat&label=Contributions&colorA=red&colorB=black )](#) 9 | 10 | 11 | A Library Management System made using the concepts of Object Oriented Analysis and Design. Minimal Code is written in the GUI and the entities are decoupled as well. The interface is console based. This project was designed during the course "Object Oriented Analysis and Design CS309". 12 | 13 | The **Class Diagram** of the project is also provided along with the **Database Schema** file. The class diagram file can be opened using [Star UML](http://staruml.io/). 14 | 15 | ## Class Diagram 16 | ![class diagram](../master/images/diagram.PNG) 17 | 18 | **Note**: After Refactoring, new Class "HoldRequestOperations" is added to the above structure which lies in between the HoldRequest class and Book class. 19 | This class removes the bidirectional dependency between HoldRequest and Book. More details mentioned [here](https://github.com/OSSpk/Library-Management-System-JAVA/issues/9) 20 | 21 | ## Interface 22 |

23 | 24 | 25 |

26 | 27 | ## Actors: 28 | The actors include the following: 29 | * Librarian 30 | * Checkout Clerk 31 | * Borrower 32 | * Administrator 33 | 34 | ## Use Cases: 35 | After determining the actors, the second step in use case analysis is to determine the tasks that each actor will need to do with the system. Each task is called a use case because it represents one particular way the system will be used. 36 | 37 | **In other words, only those use cases are listed that actors will need to do when they are using the system to solve the customer’s problem.** 38 | 39 | ### Borrower: 40 | * ❏ Search for items by title. 41 | * ❏ ... by author. 42 | * ❏ ... by subject. 43 | * ❏ Place a book on hold if it is on loan to somebody else. 44 | * ❏ Check the borrower’s personal information and list of books currently 45 | borrowed. 46 | 47 | ### Checkout Clerk: 48 | * ❏ All the Borrower use cases, plus 49 | * ❏ Check out an item for a borrower. 50 | * ❏ Check in an item that has been returned. 51 | * ❏ Renew an item. 52 | * ❏ Record that a fine has been paid. 53 | * ❏ Add a new borrower. 54 | * ❏ Update a borrower’s personal information (address, telephone number etc.). 55 | 56 | ### Librarian: 57 | * ❏ All of the Borrower and Checkout Clerk use cases, plus 58 | * ❏ Add a new item to the collection. 59 | * ❏ Delete an item from the collection. 60 | * ❏ Change the information the system has recorded about an item. 61 | 62 | ### Administrator: 63 | * ❏ Add Clerk. 64 | * ❏ Add Librarian. 65 | * ❏ View Issued Books History. 66 | * ❏ View All Books in Library. 67 | 68 | 69 | ## How to Run 70 | 1- Install these: 71 | * [Java SE Development Kit 8 (JDK 8)](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) 72 | * After installing JDK 8, install [NetBeans IDE](https://netbeans.org/downloads/) 73 | 74 | 2- Open NetBeans IDE. Click on File -> Open Project and browse to the downloaded folder named "Project" and select it. It will load the NetBeans project. 75 | 76 | 3- Now everything is setup except the Java DB (Derby) Database of NetBeans. So, follow these steps to setup the database: 77 | 78 | **Step 1:** In the Netbeans Window, there is a tab named "Services" on the left. Select it. Then right click on JavaDB > Properties and change database location to "Database" folder downloaded with this repository (its placed besides the "Project" folder). 79 | 80 | ![step1](../master/images/step1.PNG) 81 | 82 | **Step 2:** After that a database named LMS will show up under JavaDB tab. Now Right Click Databases > New Connection and select Java DB Network and click Next. 83 | 84 | ![step2](../master/images/step2.PNG) 85 | 86 | **Step 3:** Provide the following database crendentials in the next popup and click Next. 87 | ``` 88 | Host: localhost 89 | Port: 1527 90 | Database: LMS 91 | User Name: haris 92 | Password: 123 93 | ``` 94 | ![step3](../master/images/step3.PNG) 95 | 96 | **Step 4:** 97 | Now just click Next for the rest of the windows. After all this the database connection is made. Make sure that you connect with the database before running the project by right clicking on the connection and selecting connect. Now you are ready to run the project! 98 | 99 | ![final](../master/images/final.png) 100 | 101 | ## Note 102 | The password for Administrative Functions is *lib*. The admin adds new clerks and librarian, then they both do the rest of the functions. 103 | 104 |
105 | 106 | ## Authors 👋 107 | 108 | You can get in touch with us on our LinkedIn Profiles: 109 | 110 | #### Haris Muneer 111 | 112 | [![LinkedIn Link](https://img.shields.io/badge/Connect-harismuneer-blue.svg?logo=linkedin&longCache=true&style=social&label=Follow)](https://www.linkedin.com/in/harismuneer) 113 | 114 | You can also follow my GitHub Profile to stay updated about my latest projects: [![GitHub Follow](https://img.shields.io/badge/Connect-harismuneer-blue.svg?logo=Github&longCache=true&style=social&label=Follow)](https://github.com/harismuneer) 115 | 116 | #### Maham Amjad 117 | 118 | [![LinkedIn Link](https://img.shields.io/badge/Connect-maham--amjad-blue.svg?logo=linkedin&longCache=true&style=social&label=Connect)](https://www.linkedin.com/in/maham-amjad-40796b177/) 119 | 120 | You can also follow my GitHub Profile to stay updated about my latest projects: [![GitHub Follow](https://img.shields.io/badge/Connect-maham--amjad-blue.svg?logo=Github&longCache=true&style=social&label=Follow)](https://github.com/MahamAmjad) 121 | 122 | If you liked the repo then kindly support it by giving it a star ⭐ and share in your circles so more people can benefit from the effort. 123 | 124 | ## Contributions Welcome 125 | [![GitHub Issues](https://img.shields.io/github/issues/harismuneer/Library-Management-System-JAVA.svg?style=flat&label=Issues&maxAge=2592000)](https://www.github.com/harismuneer/Library-Management-System-JAVA/issues) 126 | 127 | If you find any bugs, have suggestions, or face issues: 128 | 129 | - Open an Issue in the Issues Tab to discuss them. 130 | - Submit a Pull Request to propose fixes or improvements. 131 | - Review Pull Requests from other contributors to help maintain the project's quality and progress. 132 | 133 | This project thrives on community collaboration! Members are encouraged to take the initiative, support one another, and actively engage in all aspects of the project. Whether it’s debugging, fixing issues, or brainstorming new ideas, your contributions are what keep this project moving forward. 134 | 135 | With modern AI tools like ChatGPT, solving challenges and contributing effectively is easier than ever. Let’s work together to make this project the best it can be! 🚀 136 | 137 | ## License 138 | [![MIT](https://img.shields.io/cocoapods/l/AFNetworking.svg?style=style&label=License&maxAge=2592000)](../master/LICENSE) 139 | 140 | Copyright (c) 2018-present, harismuneer, MahamAmjad 141 | 142 | 143 | 144 |
145 | 146 |

Waving hand 147 | Hey there, I'm Haris Muneer 👨🏻‍💻 148 |

149 | 150 | 151 | Total Github Stars 152 | Total Github Followers 153 | 154 |
155 | 156 | - 🛠️ Product Builder: Agile Product Manager with 5+ years of hands-on experience delivering SaaS solutions across sales, recruiting, AI, social media, and public sector domains. Background in Computer Science, with a proven track record of scaling products from inception to $XXM+ ARR, launching 3 top-ranking tools on Product Hunt, and developing solutions adopted by 250+ B2B clients in 40+ countries. 157 | 158 | - 🌟 Open Source Advocate: Passionate about making technology accessible, I’ve developed and open-sourced several software projects for web, mobile, desktop, and AI on my GitHub profile. These projects have been used by thousands of learners worldwide to enhance their skills and knowledge. 159 | 160 | - 📫 How to Reach Me: To learn more about my skills and work, visit my LinkedIn profile. For collaboration or inquiries, feel free to reach out via email. 161 | 162 |
163 | 164 |

🤝 Follow my journey

165 |

166 | 167 | 168 | 169 | 170 |

171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /Project/src/LMS/Book.java: -------------------------------------------------------------------------------- 1 | 2 | package LMS; 3 | 4 | import java.io.*; 5 | import java.time.temporal.ChronoUnit; 6 | import java.util.*; 7 | 8 | public class Book { 9 | 10 | private int bookID; // ID given by a library to a book to make it distinguishable from other books 11 | private String title; // Title of a book 12 | private String subject; // Subject to which a book is related! 13 | private String author; // Author of book! 14 | private boolean isIssued; // this will be true if the book is currently issued to some borrower. 15 | private HoldRequestOperations holdRequestsOperations =new HoldRequestOperations(); 16 | static int currentIdNumber = 0; //This will be unique for every book, since it will be incremented when everytime 17 | //when a book is created 18 | 19 | 20 | public Book(int id,String t, String s, String a, boolean issued) // Parameterise cons. 21 | { 22 | currentIdNumber++; 23 | if(id==-1) 24 | { 25 | bookID = currentIdNumber; 26 | } 27 | else 28 | bookID=id; 29 | 30 | title = t; 31 | subject = s; 32 | author = a; 33 | isIssued = issued; 34 | 35 | } 36 | 37 | 38 | // printing all hold req on a book. 39 | public void printHoldRequests() 40 | { 41 | if (!holdRequestsOperations.holdRequests.isEmpty()) 42 | { 43 | System.out.println("\nHold Requests are: "); 44 | 45 | System.out.println("---------------------------------------------------------------------------------------------------------------------------------------"); 46 | System.out.println("No.\t\tBook's Title\t\t\tBorrower's Name\t\t\tRequest Date"); 47 | System.out.println("---------------------------------------------------------------------------------------------------------------------------------------"); 48 | 49 | for (int i = 0; i < holdRequestsOperations.holdRequests.size(); i++) 50 | { 51 | System.out.print(i + "-" + "\t\t"); 52 | holdRequestsOperations.holdRequests.get(i).print(); 53 | } 54 | } 55 | else 56 | System.out.println("\nNo Hold Requests."); 57 | } 58 | 59 | // printing book's Info 60 | public void printInfo() 61 | { 62 | System.out.println(title + "\t\t\t" + author + "\t\t\t" + subject); 63 | } 64 | 65 | // changign Info of a Book 66 | public void changeBookInfo() throws IOException 67 | { 68 | Scanner scanner = new Scanner(System.in); 69 | String input; 70 | 71 | BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 72 | 73 | System.out.println("\nUpdate Author? (y/n)"); 74 | input = scanner.next(); 75 | 76 | if(input.equals("y")) 77 | { 78 | System.out.println("\nEnter new Author: "); 79 | author = reader.readLine(); 80 | } 81 | 82 | System.out.println("\nUpdate Subject? (y/n)"); 83 | input = scanner.next(); 84 | 85 | if(input.equals("y")) 86 | { 87 | System.out.println("\nEnter new Subject: "); 88 | subject = reader.readLine(); 89 | } 90 | 91 | System.out.println("\nUpdate Title? (y/n)"); 92 | input = scanner.next(); 93 | 94 | if(input.equals("y")) 95 | { 96 | System.out.println("\nEnter new Title: "); 97 | title = reader.readLine(); 98 | } 99 | 100 | System.out.println("\nBook is successfully updated."); 101 | 102 | } 103 | 104 | /*------------Getter FUNCs.---------*/ 105 | 106 | public String getTitle() 107 | { 108 | return title; 109 | } 110 | 111 | public String getSubject() 112 | { 113 | return subject; 114 | } 115 | 116 | public String getAuthor() 117 | { 118 | return author; 119 | } 120 | 121 | public boolean getIssuedStatus() 122 | { 123 | return isIssued; 124 | } 125 | 126 | public void setIssuedStatus(boolean s) 127 | { 128 | isIssued = s; 129 | } 130 | 131 | public int getID() 132 | { 133 | return bookID; 134 | } 135 | 136 | public ArrayList getHoldRequests() 137 | { 138 | return holdRequestsOperations.holdRequests; 139 | } 140 | /*-----------------------------------*/ 141 | 142 | // Setter Static Func. 143 | public static void setIDCount(int n) 144 | { 145 | currentIdNumber = n; 146 | } 147 | 148 | 149 | 150 | 151 | //-------------------------------------------------------------------// 152 | 153 | // Placing book on Hold 154 | public void placeBookOnHold(Borrower bor) 155 | { 156 | HoldRequest hr = new HoldRequest(bor,this, new Date()); 157 | 158 | holdRequestsOperations.addHoldRequest(hr); //Add this hold request to holdRequests queue of this book 159 | bor.addHoldRequest(hr); //Add this hold request to that particular borrower's class as well 160 | 161 | System.out.println("\nThe book " + title + " has been successfully placed on hold by borrower " + bor.getName() + ".\n"); 162 | } 163 | 164 | 165 | 166 | 167 | // Request for Holding a Book 168 | public void makeHoldRequest(Borrower borrower) 169 | { 170 | boolean makeRequest = true; 171 | 172 | //If that borrower has already borrowed that particular book. Then he isn't allowed to make request for that book. He will have to renew the issued book in order to extend the return deadline. 173 | for(int i=0;i hRequests = holdRequestsOperations.holdRequests; 218 | 219 | for (int i = 0; i < hRequests.size(); i++) 220 | { 221 | HoldRequest hr = hRequests.get(i); 222 | 223 | //Remove that hold request which has expired 224 | long days = ChronoUnit.DAYS.between(today.toInstant(), hr.getRequestDate().toInstant()); 225 | days = 0-days; 226 | 227 | if(days>Library.getInstance().getHoldRequestExpiry()) 228 | { 229 | holdRequestsOperations.removeHoldRequest(); 230 | hr.getBorrower().removeHoldRequest(hr); 231 | } 232 | } 233 | 234 | if (isIssued) 235 | { 236 | System.out.println("\nThe book " + title + " is already issued."); 237 | System.out.println("Would you like to place the book on hold? (y/n)"); 238 | 239 | Scanner sc = new Scanner(System.in); 240 | String choice = sc.next(); 241 | 242 | if (choice.equals("y")) 243 | { 244 | makeHoldRequest(borrower); 245 | } 246 | } 247 | 248 | else 249 | { 250 | if (!holdRequestsOperations.holdRequests.isEmpty()) 251 | { 252 | boolean hasRequest = false; 253 | 254 | for (int i = 0; i < holdRequestsOperations.holdRequests.size() && !hasRequest;i++) 255 | { 256 | if (holdRequestsOperations.holdRequests.get(i).getBorrower() == borrower) 257 | hasRequest = true; 258 | 259 | } 260 | 261 | if (hasRequest) 262 | { 263 | //If this particular borrower has the earliest request for this book 264 | if (holdRequestsOperations.holdRequests.get(0).getBorrower() == borrower) 265 | serviceHoldRequest(holdRequestsOperations.holdRequests.get(0)); 266 | 267 | else 268 | { 269 | System.out.println("\nSorry some other users have requested for this book earlier than you. So you have to wait until their hold requests are processed."); 270 | return; 271 | } 272 | } 273 | else 274 | { 275 | System.out.println("\nSome users have already placed this book on request and you haven't, so the book can't be issued to you."); 276 | 277 | System.out.println("Would you like to place the book on hold? (y/n)"); 278 | 279 | Scanner sc = new Scanner(System.in); 280 | String choice = sc.next(); 281 | 282 | if (choice.equals("y")) 283 | { 284 | makeHoldRequest(borrower); 285 | } 286 | 287 | return; 288 | } 289 | } 290 | 291 | //If there are no hold requests for this book, then simply issue the book. 292 | setIssuedStatus(true); 293 | 294 | Loan iHistory = new Loan(borrower,this,staff,null,new Date(),null,false); 295 | 296 | Library.getInstance().addLoan(iHistory); 297 | borrower.addBorrowedBook(iHistory); 298 | 299 | System.out.println("\nThe book " + title + " is successfully issued to " + borrower.getName() + "."); 300 | System.out.println("\nIssued by: " + staff.getName()); 301 | } 302 | } 303 | 304 | 305 | // Returning a Book 306 | public void returnBook(Borrower borrower, Loan l, Staff staff) 307 | { 308 | l.getBook().setIssuedStatus(false); 309 | l.setReturnedDate(new Date()); 310 | l.setReceiver(staff); 311 | 312 | borrower.removeBorrowedBook(l); 313 | 314 | l.payFine(); 315 | 316 | System.out.println("\nThe book " + l.getBook().getTitle() + " is successfully returned by " + borrower.getName() + "."); 317 | System.out.println("\nReceived by: " + staff.getName()); 318 | } 319 | 320 | } // Book Class Closed -------------------------------------------------------------------------------- /Project/src/LMS/Main.java: -------------------------------------------------------------------------------- 1 | 2 | package LMS; 3 | 4 | // Including Header Files. 5 | import java.io.*; 6 | import java.util.*; 7 | import java.sql.*; 8 | 9 | public class Main 10 | { 11 | // Clearing Required Area of Screen 12 | public static void clrscr() 13 | { 14 | for (int i = 0; i < 20; i++) 15 | System.out.println(); 16 | } 17 | 18 | // Asking for Input as Choice 19 | public static int takeInput(int min, int max) 20 | { 21 | String choice; 22 | Scanner input = new Scanner(System.in); 23 | 24 | while(true) 25 | { 26 | System.out.println("\nEnter Choice: "); 27 | 28 | choice = input.next(); 29 | 30 | if((!choice.matches(".*[a-zA-Z]+.*")) && (Integer.parseInt(choice) > min && Integer.parseInt(choice) < max)) 31 | { 32 | return Integer.parseInt(choice); 33 | } 34 | 35 | else 36 | System.out.println("\nInvalid Input."); 37 | } 38 | 39 | } 40 | 41 | // Functionalities of all Persons 42 | public static void allFunctionalities(Person person, int choice) throws IOException 43 | { 44 | Library lib = Library.getInstance(); 45 | 46 | Scanner scanner = new Scanner(System.in); 47 | int input = 0; 48 | 49 | //Search Book 50 | if (choice == 1) 51 | { 52 | lib.searchForBooks(); 53 | } 54 | 55 | //Do Hold Request 56 | else if (choice == 2) 57 | { 58 | ArrayList books = lib.searchForBooks(); 59 | 60 | if (books != null) 61 | { 62 | input = takeInput(-1,books.size()); 63 | 64 | Book b = books.get(input); 65 | 66 | if("Clerk".equals(person.getClass().getSimpleName()) || "Librarian".equals(person.getClass().getSimpleName())) 67 | { 68 | Borrower bor = lib.findBorrower(); 69 | 70 | if (bor != null) 71 | b.makeHoldRequest(bor); 72 | } 73 | else 74 | b.makeHoldRequest((Borrower)person); 75 | } 76 | } 77 | 78 | //View borrower's personal information 79 | else if (choice == 3) 80 | { 81 | if("Clerk".equals(person.getClass().getSimpleName()) || "Librarian".equals(person.getClass().getSimpleName())) 82 | { 83 | Borrower bor = lib.findBorrower(); 84 | 85 | if(bor!=null) 86 | bor.printInfo(); 87 | } 88 | else 89 | person.printInfo(); 90 | } 91 | 92 | //Compute Fine of a Borrower 93 | else if (choice == 4) 94 | { 95 | if("Clerk".equals(person.getClass().getSimpleName()) || "Librarian".equals(person.getClass().getSimpleName())) 96 | { 97 | Borrower bor = lib.findBorrower(); 98 | 99 | if(bor!=null) 100 | { 101 | double totalFine = lib.computeFine2(bor); 102 | System.out.println("\nYour Total Fine is : Rs " + totalFine ); 103 | } 104 | } 105 | else 106 | { 107 | double totalFine = lib.computeFine2((Borrower)person); 108 | System.out.println("\nYour Total Fine is : Rs " + totalFine ); 109 | } 110 | } 111 | 112 | //Check hold request queue of a book 113 | else if (choice == 5) 114 | { 115 | ArrayList books = lib.searchForBooks(); 116 | 117 | if (books != null) 118 | { 119 | input = takeInput(-1,books.size()); 120 | books.get(input).printHoldRequests(); 121 | } 122 | } 123 | 124 | //Issue a Book 125 | else if (choice == 6) 126 | { 127 | ArrayList books = lib.searchForBooks(); 128 | 129 | if (books != null) 130 | { 131 | input = takeInput(-1,books.size()); 132 | Book b = books.get(input); 133 | 134 | Borrower bor = lib.findBorrower(); 135 | 136 | if(bor!=null) 137 | { 138 | b.issueBook(bor, (Staff)person); 139 | } 140 | } 141 | } 142 | 143 | //Return a Book 144 | else if (choice == 7) 145 | { 146 | Borrower bor = lib.findBorrower(); 147 | 148 | if(bor!=null) 149 | { 150 | bor.printBorrowedBooks(); 151 | ArrayList loans = bor.getBorrowedBooks(); 152 | 153 | if (!loans.isEmpty()) 154 | { 155 | input = takeInput(-1,loans.size()); 156 | Loan l = loans.get(input); 157 | 158 | l.getBook().returnBook(bor, l, (Staff)person); 159 | } 160 | else 161 | System.out.println("\nThis borrower " + bor.getName() + " has no book to return."); 162 | } 163 | } 164 | 165 | //Renew a Book 166 | else if (choice == 8) 167 | { 168 | Borrower bor = lib.findBorrower(); 169 | 170 | if(bor!=null) 171 | { 172 | bor.printBorrowedBooks(); 173 | ArrayList loans = bor.getBorrowedBooks(); 174 | 175 | if (!loans.isEmpty()) 176 | { 177 | input = takeInput(-1,loans.size()); 178 | 179 | loans.get(input).renewIssuedBook(new java.util.Date()); 180 | } 181 | else 182 | System.out.println("\nThis borrower " + bor.getName() + " has no issued book which can be renewed."); 183 | } 184 | } 185 | 186 | //Add new Borrower 187 | else if (choice == 9) 188 | { 189 | lib.createPerson('b'); 190 | } 191 | 192 | //Update Borrower's Personal Info 193 | else if (choice == 10) 194 | { 195 | Borrower bor = lib.findBorrower(); 196 | 197 | if(bor != null) 198 | bor.updateBorrowerInfo(); 199 | } 200 | 201 | //Add new Book 202 | else if (choice == 11) 203 | { 204 | BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 205 | 206 | System.out.println("\nEnter Title:"); 207 | String title = reader.readLine(); 208 | 209 | System.out.println("\nEnter Subject:"); 210 | String subject = reader.readLine(); 211 | 212 | System.out.println("\nEnter Author:"); 213 | String author = reader.readLine(); 214 | 215 | lib.createBook(title, subject, author); 216 | } 217 | 218 | //Remove a Book 219 | else if (choice == 12) 220 | { 221 | ArrayList books = lib.searchForBooks(); 222 | 223 | if (books != null) 224 | { 225 | input = takeInput(-1,books.size()); 226 | 227 | lib.removeBookfromLibrary(books.get(input)); 228 | } 229 | } 230 | 231 | //Change a Book's Info 232 | else if (choice == 13) 233 | { 234 | ArrayList books = lib.searchForBooks(); 235 | 236 | if (books!=null) 237 | { 238 | input = takeInput(-1,books.size()); 239 | 240 | books.get(input).changeBookInfo(); 241 | } 242 | } 243 | 244 | //View clerk's personal information 245 | else if (choice == 14) 246 | { 247 | Clerk clerk = lib.findClerk(); 248 | 249 | if(clerk!=null) 250 | clerk.printInfo(); 251 | } 252 | 253 | // Functionality Performed. 254 | System.out.println("\nPress any key to continue..\n"); 255 | scanner.next(); 256 | } 257 | 258 | 259 | 260 | 261 | 262 | 263 | /*-------------------------------------MAIN---------------------------------------------------*/ 264 | 265 | public static void main(String[] args) 266 | { 267 | Scanner admin = new Scanner(System.in); 268 | 269 | //-------------------INTERFACE---------------------------// 270 | 271 | Library lib = Library.getInstance(); 272 | 273 | // Setting some by default information like name of library ,fine, deadline and limit of hold request 274 | lib.setFine(20); 275 | lib.setRequestExpiry(7); 276 | lib.setReturnDeadline(5); 277 | lib.setName("FAST Library"); 278 | 279 | // Making connection with Database. 280 | Connection con = lib.makeConnection(); 281 | 282 | if (con == null) // Oops can't connnect ! 283 | { 284 | System.out.println("\nError connecting to Database. Exiting."); 285 | return; 286 | } 287 | 288 | try { 289 | 290 | lib.populateLibrary(con); // Populating Library with all Records 291 | 292 | boolean stop = false; 293 | while(!stop) 294 | { 295 | clrscr(); 296 | 297 | // FRONT END // 298 | System.out.println("--------------------------------------------------------"); 299 | System.out.println("\tWelcome to Library Management System"); 300 | System.out.println("--------------------------------------------------------"); 301 | 302 | System.out.println("Following Functionalities are available: \n"); 303 | System.out.println("1- Login"); 304 | System.out.println("2- Exit"); 305 | System.out.println("3- Admininstrative Functions"); // Administration has access only 306 | 307 | System.out.println("-----------------------------------------\n"); 308 | 309 | int choice = 0; 310 | 311 | choice = takeInput(0,4); 312 | 313 | if (choice == 3) 314 | { 315 | System.out.println("\nEnter Password: "); 316 | String aPass = admin.next(); 317 | 318 | if(aPass.equals("lib")) 319 | { 320 | while (true) // Way to Admin Portal 321 | { 322 | clrscr(); 323 | 324 | System.out.println("--------------------------------------------------------"); 325 | System.out.println("\tWelcome to Admin's Portal"); 326 | System.out.println("--------------------------------------------------------"); 327 | System.out.println("Following Functionalities are available: \n"); 328 | 329 | System.out.println("1- Add Clerk"); 330 | System.out.println("2- Add Librarian"); 331 | System.out.println("3- View Issued Books History"); 332 | System.out.println("4- View All Books in Library"); 333 | System.out.println("5- Logout"); 334 | 335 | System.out.println("---------------------------------------------"); 336 | 337 | choice = takeInput(0,6); 338 | 339 | if (choice == 5) 340 | break; 341 | 342 | if (choice == 1) 343 | lib.createPerson('c'); 344 | else if (choice == 2) 345 | lib.createPerson('l'); 346 | 347 | else if (choice == 3) 348 | lib.viewHistory(); 349 | 350 | else if (choice == 4) 351 | lib.viewAllBooks(); 352 | 353 | System.out.println("\nPress any key to continue..\n"); 354 | admin.next(); 355 | } 356 | } 357 | else 358 | System.out.println("\nSorry! Wrong Password."); 359 | } 360 | 361 | else if (choice == 1) 362 | { 363 | Person person = lib.login(); 364 | 365 | if (person == null){} 366 | 367 | else if (person.getClass().getSimpleName().equals("Borrower")) 368 | { 369 | while (true) // Way to Borrower's Portal 370 | { 371 | clrscr(); 372 | 373 | System.out.println("--------------------------------------------------------"); 374 | System.out.println("\tWelcome to Borrower's Portal"); 375 | System.out.println("--------------------------------------------------------"); 376 | System.out.println("Following Functionalities are available: \n"); 377 | System.out.println("1- Search a Book"); 378 | System.out.println("2- Place a Book on hold"); 379 | System.out.println("3- Check Personal Info of Borrower"); 380 | System.out.println("4- Check Total Fine of Borrower"); 381 | System.out.println("5- Check Hold Requests Queue of a Book"); 382 | System.out.println("6- Logout"); 383 | System.out.println("--------------------------------------------------------"); 384 | 385 | choice = takeInput(0,7); 386 | 387 | if (choice == 6) 388 | break; 389 | 390 | allFunctionalities(person,choice); 391 | } 392 | } 393 | 394 | else if (person.getClass().getSimpleName().equals("Clerk")) 395 | { 396 | while(true) // Way to Clerk's Portal 397 | { 398 | clrscr(); 399 | 400 | System.out.println("--------------------------------------------------------"); 401 | System.out.println("\tWelcome to Clerk's Portal"); 402 | System.out.println("--------------------------------------------------------"); 403 | System.out.println("Following Functionalities are available: \n"); 404 | System.out.println("1- Search a Book"); 405 | System.out.println("2- Place a Book on hold"); 406 | System.out.println("3- Check Personal Info of Borrower"); 407 | System.out.println("4- Check Total Fine of Borrower"); 408 | System.out.println("5- Check Hold Requests Queue of a Book"); 409 | System.out.println("6- Check out a Book"); 410 | System.out.println("7- Check in a Book"); 411 | System.out.println("8- Renew a Book"); 412 | System.out.println("9- Add a new Borrower"); 413 | System.out.println("10- Update a Borrower's Info"); 414 | System.out.println("11- Logout"); 415 | System.out.println("--------------------------------------------------------"); 416 | 417 | choice = takeInput(0,12); 418 | 419 | if (choice == 11) 420 | break; 421 | 422 | allFunctionalities(person,choice); 423 | } 424 | } 425 | 426 | else if (person.getClass().getSimpleName().equals("Librarian")) 427 | { 428 | while(true) // Way to Librarian Portal 429 | { 430 | clrscr(); 431 | 432 | System.out.println("--------------------------------------------------------"); 433 | System.out.println("\tWelcome to Librarian's Portal"); 434 | System.out.println("--------------------------------------------------------"); 435 | System.out.println("Following Functionalities are available: \n"); 436 | System.out.println("1- Search a Book"); 437 | System.out.println("2- Place a Book on hold"); 438 | System.out.println("3- Check Personal Info of Borrower"); 439 | System.out.println("4- Check Total Fine of Borrower"); 440 | System.out.println("5- Check Hold Requests Queue of a Book"); 441 | System.out.println("6- Check out a Book"); 442 | System.out.println("7- Check in a Book"); 443 | System.out.println("8- Renew a Book"); 444 | System.out.println("9- Add a new Borrower"); 445 | System.out.println("10- Update a Borrower's Info"); 446 | System.out.println("11- Add new Book"); 447 | System.out.println("12- Remove a Book"); 448 | System.out.println("13- Change a Book's Info"); 449 | System.out.println("14- Check Personal Info of Clerk"); 450 | System.out.println("15- Logout"); 451 | System.out.println("--------------------------------------------------------"); 452 | 453 | choice = takeInput(0,16); 454 | 455 | if (choice == 15) 456 | break; 457 | 458 | allFunctionalities(person,choice); 459 | } 460 | } 461 | 462 | } 463 | 464 | else 465 | stop = true; 466 | 467 | System.out.println("\nPress any key to continue..\n"); 468 | Scanner scanner = new Scanner(System.in); 469 | scanner.next(); 470 | } 471 | 472 | //Loading back all the records in database 473 | lib.fillItBack(con); 474 | } 475 | catch(Exception e) 476 | { 477 | System.out.println("\nExiting...\n"); 478 | } // System Closed! 479 | 480 | } // Main Closed 481 | 482 | } // Class closed. 483 | 484 | -------------------------------------------------------------------------------- /Project/src/LMS/Library.java: -------------------------------------------------------------------------------- 1 | 2 | package LMS; 3 | 4 | 5 | // Including Header Files. 6 | import java.io.*; 7 | import java.sql.Connection; 8 | import java.sql.DriverManager; 9 | import java.sql.PreparedStatement; 10 | import java.sql.ResultSet; 11 | import java.sql.SQLException; 12 | import java.sql.SQLIntegrityConstraintViolationException; 13 | import java.sql.Statement; 14 | import java.sql.Types; 15 | import java.util.*; 16 | import java.util.logging.Level; 17 | import java.util.logging.Logger; 18 | 19 | 20 | public class Library { 21 | 22 | private String name; // name of library 23 | public static Librarian librarian; // object of Librarian (only one) 24 | public static ArrayList persons; // all clerks and borrowers 25 | private ArrayList booksInLibrary; // all books in library are here! 26 | 27 | private ArrayList loans; // history of all books which have been issued 28 | 29 | public int book_return_deadline; //return deadline after which fine will be generated each day 30 | public double per_day_fine; 31 | 32 | public int hold_request_expiry; //number of days after which a hold request will expire 33 | //Created object of the hold request operations 34 | private HoldRequestOperations holdRequestsOperations =new HoldRequestOperations(); 35 | 36 | 37 | /*----Following Singleton Design Pattern (Lazy Instantiation)------------*/ 38 | private static Library obj; 39 | 40 | public static Library getInstance() 41 | { 42 | if(obj==null) 43 | { 44 | obj = new Library(); 45 | } 46 | 47 | return obj; 48 | } 49 | /*---------------------------------------------------------------------*/ 50 | 51 | private Library() // default cons. 52 | { 53 | name = null; 54 | librarian = null; 55 | persons = new ArrayList(); 56 | 57 | booksInLibrary = new ArrayList(); 58 | loans = new ArrayList(); 59 | } 60 | 61 | 62 | /*------------Setter FUNCs.------------*/ 63 | 64 | public void setReturnDeadline(int deadline) 65 | { 66 | book_return_deadline = deadline; 67 | } 68 | 69 | public void setFine(double perDayFine) 70 | { 71 | per_day_fine = perDayFine; 72 | } 73 | 74 | public void setRequestExpiry(int hrExpiry) 75 | { 76 | hold_request_expiry = hrExpiry; 77 | } 78 | /*--------------------------------------*/ 79 | 80 | 81 | 82 | // Setter Func. 83 | public void setName(String n) 84 | { 85 | name = n; 86 | } 87 | 88 | /*-----------Getter FUNCs.------------*/ 89 | 90 | public int getHoldRequestExpiry() 91 | { 92 | return hold_request_expiry; 93 | } 94 | 95 | public ArrayList getPersons() 96 | { 97 | return persons; 98 | } 99 | 100 | public Librarian getLibrarian() 101 | { 102 | return librarian; 103 | } 104 | 105 | public String getLibraryName() 106 | { 107 | return name; 108 | } 109 | 110 | public ArrayList getBooks() 111 | { 112 | return booksInLibrary; 113 | } 114 | 115 | /*---------------------------------------*/ 116 | 117 | /*-----Adding other People in Library----*/ 118 | 119 | public void addClerk(Clerk c) 120 | { 121 | persons.add(c); 122 | } 123 | 124 | public void addBorrower(Borrower b) 125 | { 126 | persons.add(b); 127 | } 128 | 129 | 130 | public void addLoan(Loan l) 131 | { 132 | loans.add(l); 133 | } 134 | 135 | /*----------------------------------------------*/ 136 | 137 | /*-----------Finding People in Library--------------*/ 138 | public Borrower findBorrower() 139 | { 140 | System.out.println("\nEnter Borrower's ID: "); 141 | 142 | int id = 0; 143 | 144 | Scanner scanner = new Scanner(System.in); 145 | 146 | try{ 147 | id = scanner.nextInt(); 148 | } 149 | catch (java.util.InputMismatchException e) 150 | { 151 | System.out.println("\nInvalid Input"); 152 | } 153 | 154 | for (int i = 0; i < persons.size(); i++) 155 | { 156 | if (persons.get(i).getID() == id && persons.get(i).getClass().getSimpleName().equals("Borrower")) 157 | return (Borrower)(persons.get(i)); 158 | } 159 | 160 | System.out.println("\nSorry this ID didn't match any Borrower's ID."); 161 | return null; 162 | } 163 | 164 | public Clerk findClerk() 165 | { 166 | System.out.println("\nEnter Clerk's ID: "); 167 | 168 | int id = 0; 169 | 170 | Scanner scanner = new Scanner(System.in); 171 | 172 | try{ 173 | id = scanner.nextInt(); 174 | } 175 | catch (java.util.InputMismatchException e) 176 | { 177 | System.out.println("\nInvalid Input"); 178 | } 179 | 180 | for (int i = 0; i < persons.size(); i++) 181 | { 182 | if (persons.get(i).getID() == id && persons.get(i).getClass().getSimpleName().equals("Clerk")) 183 | return (Clerk)(persons.get(i)); 184 | } 185 | 186 | System.out.println("\nSorry this ID didn't match any Clerk's ID."); 187 | return null; 188 | } 189 | 190 | /*------- FUNCS. on Books In Library--------------*/ 191 | public void addBookinLibrary(Book b) 192 | { 193 | booksInLibrary.add(b); 194 | } 195 | 196 | //When this function is called, only the pointer of the book placed in booksInLibrary is removed. But the real object of book 197 | //is still there in memory because pointers of that book placed in IssuedBooks and ReturnedBooks are still pointing to that book. And we 198 | //are maintaining those pointers so that we can maintain history. 199 | //But if we donot want to maintain history then we can delete those pointers placed in IssuedBooks and ReturnedBooks as well which are 200 | //pointing to that book. In this way the book will be really removed from memory. 201 | public void removeBookfromLibrary(Book b) 202 | { 203 | boolean delete = true; 204 | 205 | //Checking if this book is currently borrowed by some borrower 206 | for (int i = 0; i < persons.size() && delete; i++) 207 | { 208 | if (persons.get(i).getClass().getSimpleName().equals("Borrower")) 209 | { 210 | ArrayList borBooks = ((Borrower)(persons.get(i))).getBorrowedBooks(); 211 | 212 | for (int j = 0; j < borBooks.size() && delete; j++) 213 | { 214 | if (borBooks.get(j).getBook() == b) 215 | { 216 | delete = false; 217 | System.out.println("This particular book is currently borrowed by some borrower."); 218 | } 219 | } 220 | } 221 | } 222 | 223 | if (delete) 224 | { 225 | System.out.println("\nCurrently this book is not borrowed by anyone."); 226 | ArrayList hRequests = b.getHoldRequests(); 227 | 228 | if(!hRequests.isEmpty()) 229 | { 230 | System.out.println("\nThis book might be on hold requests by some borrowers. Deleting this book will delete the relevant hold requests too."); 231 | System.out.println("Do you still want to delete the book? (y/n)"); 232 | 233 | Scanner sc = new Scanner(System.in); 234 | 235 | while (true) 236 | { 237 | String choice = sc.next(); 238 | 239 | if(choice.equals("y") || choice.equals("n")) 240 | { 241 | if(choice.equals("n")) 242 | { 243 | System.out.println("\nDelete Unsuccessful."); 244 | return; 245 | } 246 | else 247 | { 248 | //Empty the books hold request array 249 | //Delete the hold request from the borrowers too 250 | for (int i = 0; i < hRequests.size() && delete; i++) 251 | { 252 | HoldRequest hr = hRequests.get(i); 253 | hr.getBorrower().removeHoldRequest(hr); 254 | holdRequestsOperations.removeHoldRequest(); 255 | } 256 | } 257 | } 258 | else 259 | System.out.println("Invalid Input. Enter (y/n): "); 260 | } 261 | 262 | } 263 | else 264 | System.out.println("This book has no hold requests."); 265 | 266 | booksInLibrary.remove(b); 267 | System.out.println("The book is successfully removed."); 268 | } 269 | else 270 | System.out.println("\nDelete Unsuccessful."); 271 | } 272 | 273 | 274 | 275 | // Searching Books on basis of title, Subject or Author 276 | public ArrayList searchForBooks() throws IOException 277 | { 278 | String choice; 279 | String title = "", subject = "", author = ""; 280 | 281 | Scanner sc = new Scanner(System.in); 282 | BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 283 | 284 | while (true) 285 | { 286 | System.out.println("\nEnter either '1' or '2' or '3' for search by Title, Subject or Author of Book respectively: "); 287 | choice = sc.next(); 288 | 289 | if (choice.equals("1") || choice.equals("2") || choice.equals("3")) 290 | break; 291 | else 292 | System.out.println("\nWrong Input!"); 293 | } 294 | 295 | if (choice.equals("1")) 296 | { 297 | System.out.println("\nEnter the Title of the Book: "); 298 | title = reader.readLine(); 299 | } 300 | 301 | else if (choice.equals("2")) 302 | { 303 | System.out.println("\nEnter the Subject of the Book: "); 304 | subject = reader.readLine(); 305 | } 306 | 307 | else 308 | { 309 | System.out.println("\nEnter the Author of the Book: "); 310 | author = reader.readLine(); 311 | } 312 | 313 | ArrayList matchedBooks = new ArrayList(); 314 | 315 | //Retrieving all the books which matched the user's search query 316 | for(int i = 0; i < booksInLibrary.size(); i++) 317 | { 318 | Book b = booksInLibrary.get(i); 319 | 320 | if (choice.equals("1")) 321 | { 322 | if (b.getTitle().equals(title)) 323 | matchedBooks.add(b); 324 | } 325 | else if (choice.equals("2")) 326 | { 327 | if (b.getSubject().equals(subject)) 328 | matchedBooks.add(b); 329 | } 330 | else 331 | { 332 | if (b.getAuthor().equals(author)) 333 | matchedBooks.add(b); 334 | } 335 | } 336 | 337 | //Printing all the matched Books 338 | if (!matchedBooks.isEmpty()) 339 | { 340 | System.out.println("\nThese books are found: \n"); 341 | 342 | System.out.println("------------------------------------------------------------------------------"); 343 | System.out.println("No.\t\tTitle\t\t\tAuthor\t\t\tSubject"); 344 | System.out.println("------------------------------------------------------------------------------"); 345 | 346 | for (int i = 0; i < matchedBooks.size(); i++) 347 | { 348 | System.out.print(i + "-" + "\t\t"); 349 | matchedBooks.get(i).printInfo(); 350 | System.out.print("\n"); 351 | } 352 | 353 | return matchedBooks; 354 | } 355 | else 356 | { 357 | System.out.println("\nSorry. No Books were found related to your query."); 358 | return null; 359 | } 360 | } 361 | 362 | 363 | 364 | // View Info of all Books in Library 365 | public void viewAllBooks() 366 | { 367 | if (!booksInLibrary.isEmpty()) 368 | { 369 | System.out.println("\nBooks are: "); 370 | 371 | System.out.println("------------------------------------------------------------------------------"); 372 | System.out.println("No.\t\tTitle\t\t\tAuthor\t\t\tSubject"); 373 | System.out.println("------------------------------------------------------------------------------"); 374 | 375 | for (int i = 0; i < booksInLibrary.size(); i++) 376 | { 377 | System.out.print(i + "-" + "\t\t"); 378 | booksInLibrary.get(i).printInfo(); 379 | System.out.print("\n"); 380 | } 381 | } 382 | else 383 | System.out.println("\nCurrently, Library has no books."); 384 | } 385 | 386 | 387 | //Computes total fine for all loans of a borrower 388 | public double computeFine2(Borrower borrower) 389 | { 390 | System.out.println("---------------------------------------------------------------------------------------------------------------------------------------------------------------------"); 391 | System.out.println("No.\t\tBook's Title\t\tBorrower's Name\t\t\tIssued Date\t\t\tReturned Date\t\t\t\tFine(Rs)"); 392 | System.out.println("-------------------------------------------------------------------------------------------------------------------------------------------------------------------"); 393 | 394 | double totalFine = 0; 395 | double per_loan_fine = 0; 396 | 397 | for (int i = 0; i < loans.size(); i++) 398 | { 399 | Loan l = loans.get(i); 400 | 401 | if ((l.getBorrower() == borrower)) 402 | { 403 | per_loan_fine = l.computeFine1(); 404 | System.out.print(i + "-" + "\t\t" + loans.get(i).getBook().getTitle() + "\t\t\t" + loans.get(i).getBorrower().getName() + "\t\t" + loans.get(i).getIssuedDate() + "\t\t\t" + loans.get(i).getReturnDate() + "\t\t\t\t" + per_loan_fine + "\n"); 405 | 406 | totalFine += per_loan_fine; 407 | } 408 | } 409 | 410 | return totalFine; 411 | } 412 | 413 | 414 | public void createPerson(char x) 415 | { 416 | Scanner sc = new Scanner(System.in); 417 | BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 418 | 419 | System.out.println("\nEnter Name: "); 420 | String n = ""; 421 | try { 422 | n = reader.readLine(); 423 | } catch (IOException ex) { 424 | Logger.getLogger(Library.class.getName()).log(Level.SEVERE, null, ex); 425 | } 426 | System.out.println("Enter Address: "); 427 | String address = ""; 428 | try { 429 | address = reader.readLine(); 430 | } catch (IOException ex) { 431 | Logger.getLogger(Library.class.getName()).log(Level.SEVERE, null, ex); 432 | } 433 | 434 | int phone = 0; 435 | 436 | try{ 437 | System.out.println("Enter Phone Number: "); 438 | phone = sc.nextInt(); 439 | } 440 | catch (java.util.InputMismatchException e) 441 | { 442 | System.out.println("\nInvalid Input."); 443 | } 444 | 445 | //If clerk is to be created 446 | if (x == 'c') 447 | { 448 | double salary = 0; 449 | 450 | try{ 451 | System.out.println("Enter Salary: "); 452 | salary = sc.nextDouble(); 453 | } 454 | catch (java.util.InputMismatchException e) 455 | { 456 | System.out.println("\nInvalid Input."); 457 | } 458 | 459 | Clerk c = new Clerk(-1,n,address,phone,salary,-1); 460 | addClerk(c); 461 | 462 | System.out.println("\nClerk with name " + n + " created successfully."); 463 | System.out.println("\nYour ID is : " + c.getID()); 464 | System.out.println("Your Password is : " + c.getPassword()); 465 | } 466 | 467 | //If librarian is to be created 468 | else if (x == 'l') 469 | { 470 | double salary = 0; 471 | try{ 472 | System.out.println("Enter Salary: "); 473 | salary = sc.nextDouble(); 474 | } 475 | catch (java.util.InputMismatchException e) 476 | { 477 | System.out.println("\nInvalid Input."); 478 | } 479 | 480 | Librarian l = new Librarian(-1,n,address,phone,salary,-1); 481 | if(Librarian.addLibrarian(l)) 482 | { 483 | System.out.println("\nLibrarian with name " + n + " created successfully."); 484 | System.out.println("\nYour ID is : " + l.getID()); 485 | System.out.println("Your Password is : " + l.getPassword()); 486 | } 487 | } 488 | 489 | //If borrower is to be created 490 | else 491 | { 492 | Borrower b = new Borrower(-1,n,address,phone); 493 | addBorrower(b); 494 | System.out.println("\nBorrower with name " + n + " created successfully."); 495 | 496 | System.out.println("\nYour ID is : " + b.getID()); 497 | System.out.println("Your Password is : " + b.getPassword()); 498 | } 499 | } 500 | 501 | 502 | 503 | public void createBook(String title, String subject, String author) 504 | { 505 | Book b = new Book(-1,title,subject,author,false); 506 | 507 | addBookinLibrary(b); 508 | 509 | System.out.println("\nBook with Title " + b.getTitle() + " is successfully created."); 510 | } 511 | 512 | 513 | 514 | // Called when want an access to Portal 515 | public Person login() 516 | { 517 | Scanner input = new Scanner(System.in); 518 | 519 | int id = 0; 520 | String password = ""; 521 | 522 | System.out.println("\nEnter ID: "); 523 | 524 | try{ 525 | id = input.nextInt(); 526 | } 527 | catch (java.util.InputMismatchException e) 528 | { 529 | System.out.println("\nInvalid Input"); 530 | } 531 | 532 | System.out.println("Enter Password: "); 533 | password = input.next(); 534 | 535 | for (int i = 0; i < persons.size(); i++) 536 | { 537 | if (persons.get(i).getID() == id && persons.get(i).getPassword().equals(password)) 538 | { 539 | System.out.println("\nLogin Successful"); 540 | return persons.get(i); 541 | } 542 | } 543 | 544 | if(librarian!=null) 545 | { 546 | if (librarian.getID() == id && librarian.getPassword().equals(password)) 547 | { 548 | System.out.println("\nLogin Successful"); 549 | return librarian; 550 | } 551 | } 552 | 553 | System.out.println("\nSorry! Wrong ID or Password"); 554 | return null; 555 | } 556 | 557 | 558 | // History when a Book was Issued and was Returned! 559 | public void viewHistory() 560 | { 561 | if (!loans.isEmpty()) 562 | { 563 | System.out.println("\nIssued Books are: "); 564 | 565 | System.out.println("------------------------------------------------------------------------------------------------------------------------------------------------------"); 566 | System.out.println("No.\tBook's Title\tBorrower's Name\t Issuer's Name\t\tIssued Date\t\t\tReceiver's Name\t\tReturned Date\t\tFine Paid"); 567 | System.out.println("------------------------------------------------------------------------------------------------------------------------------------------------------"); 568 | 569 | for (int i = 0; i < loans.size(); i++) 570 | { 571 | if(loans.get(i).getIssuer()!=null) 572 | System.out.print(i + "-" + "\t" + loans.get(i).getBook().getTitle() + "\t\t\t" + loans.get(i).getBorrower().getName() + "\t\t" + loans.get(i).getIssuer().getName() + "\t " + loans.get(i).getIssuedDate()); 573 | 574 | if (loans.get(i).getReceiver() != null) 575 | { 576 | System.out.print("\t" + loans.get(i).getReceiver().getName() + "\t\t" + loans.get(i).getReturnDate() +"\t " + loans.get(i).getFineStatus() + "\n"); 577 | } 578 | else 579 | System.out.print("\t\t" + "--" + "\t\t\t" + "--" + "\t\t" + "--" + "\n"); 580 | } 581 | } 582 | else 583 | System.out.println("\nNo issued books."); 584 | } 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | //---------------------------------------------------------------------------------------// 595 | /*--------------------------------IN- COLLABORATION WITH DATA BASE------------------------------------------*/ 596 | 597 | // Making Connection With Database 598 | public Connection makeConnection() 599 | { 600 | try 601 | { 602 | String host = "jdbc:derby://localhost:1527/LMS"; 603 | String uName = "haris"; 604 | String uPass= "123"; 605 | Connection con = DriverManager.getConnection( host, uName, uPass ); 606 | return con; 607 | } 608 | catch ( SQLException err ) 609 | { 610 | System.out.println( err.getMessage( ) ); 611 | return null; 612 | } 613 | } 614 | 615 | 616 | // Loading all info in code via Database. 617 | public void populateLibrary(Connection con) throws SQLException, IOException 618 | { 619 | Library lib = this; 620 | Statement stmt = con.createStatement( ); 621 | 622 | /* --- Populating Book ----*/ 623 | String SQL = "SELECT * FROM BOOK"; 624 | ResultSet rs = stmt.executeQuery( SQL ); 625 | 626 | if(!rs.next()) 627 | { 628 | System.out.println("\nNo Books Found in Library"); 629 | } 630 | else 631 | { 632 | int maxID = 0; 633 | 634 | do 635 | { 636 | if(rs.getString("TITLE") !=null && rs.getString("AUTHOR")!=null && rs.getString("SUBJECT")!=null && rs.getInt("ID")!=0) 637 | { 638 | String title=rs.getString("TITLE"); 639 | String author=rs.getString("AUTHOR"); 640 | String subject=rs.getString("SUBJECT"); 641 | int id= rs.getInt("ID"); 642 | boolean issue=rs.getBoolean("IS_ISSUED"); 643 | Book b = new Book(id,title,subject,author,issue); 644 | addBookinLibrary(b); 645 | 646 | if (maxID < id) 647 | maxID = id; 648 | } 649 | }while(rs.next()); 650 | 651 | // setting Book Count 652 | Book.setIDCount(maxID); 653 | } 654 | 655 | /* ----Populating Clerks----*/ 656 | 657 | SQL="SELECT ID,PNAME,ADDRESS,PASSWORD,PHONE_NO,SALARY,DESK_NO FROM PERSON INNER JOIN CLERK ON ID=C_ID INNER JOIN STAFF ON S_ID=C_ID"; 658 | 659 | rs=stmt.executeQuery(SQL); 660 | 661 | if(!rs.next()) 662 | { 663 | System.out.println("No clerks Found in Library"); 664 | } 665 | else 666 | { 667 | do 668 | { 669 | int id=rs.getInt("ID"); 670 | String cname=rs.getString("PNAME"); 671 | String adrs=rs.getString("ADDRESS"); 672 | int phn=rs.getInt("PHONE_NO"); 673 | double sal=rs.getDouble("SALARY"); 674 | int desk=rs.getInt("DESK_NO"); 675 | Clerk c = new Clerk(id,cname,adrs,phn,sal,desk); 676 | 677 | addClerk(c); 678 | } 679 | while(rs.next()); 680 | 681 | } 682 | 683 | /*-----Populating Librarian---*/ 684 | SQL="SELECT ID,PNAME,ADDRESS,PASSWORD,PHONE_NO,SALARY,OFFICE_NO FROM PERSON INNER JOIN LIBRARIAN ON ID=L_ID INNER JOIN STAFF ON S_ID=L_ID"; 685 | 686 | rs=stmt.executeQuery(SQL); 687 | if(!rs.next()) 688 | { 689 | System.out.println("No Librarian Found in Library"); 690 | } 691 | else 692 | { 693 | do 694 | { 695 | int id=rs.getInt("ID"); 696 | String lname=rs.getString("PNAME"); 697 | String adrs=rs.getString("ADDRESS"); 698 | int phn=rs.getInt("PHONE_NO"); 699 | double sal=rs.getDouble("SALARY"); 700 | int off=rs.getInt("OFFICE_NO"); 701 | Librarian l= new Librarian(id,lname,adrs,phn,sal,off); 702 | 703 | Librarian.addLibrarian(l); 704 | 705 | }while(rs.next()); 706 | 707 | } 708 | 709 | /*---Populating Borrowers (partially)!!!!!!--------*/ 710 | 711 | SQL="SELECT ID,PNAME,ADDRESS,PASSWORD,PHONE_NO FROM PERSON INNER JOIN BORROWER ON ID=B_ID"; 712 | 713 | rs=stmt.executeQuery(SQL); 714 | 715 | if(!rs.next()) 716 | { 717 | System.out.println("No Borrower Found in Library"); 718 | } 719 | else 720 | { 721 | do 722 | { 723 | int id=rs.getInt("ID"); 724 | String name=rs.getString("PNAME"); 725 | String adrs=rs.getString("ADDRESS"); 726 | int phn=rs.getInt("PHONE_NO"); 727 | 728 | Borrower b= new Borrower(id,name,adrs,phn); 729 | addBorrower(b); 730 | 731 | }while(rs.next()); 732 | 733 | } 734 | 735 | /*----Populating Loan----*/ 736 | 737 | SQL="SELECT * FROM LOAN"; 738 | 739 | rs=stmt.executeQuery(SQL); 740 | if(!rs.next()) 741 | { 742 | System.out.println("No Books Issued Yet!"); 743 | } 744 | else 745 | { 746 | do 747 | { 748 | int borid=rs.getInt("BORROWER"); 749 | int bokid=rs.getInt("BOOK"); 750 | int iid=rs.getInt("ISSUER"); 751 | Integer rid=(Integer)rs.getObject("RECEIVER"); 752 | int rd=0; 753 | Date rdate; 754 | 755 | Date idate=new Date (rs.getTimestamp("ISS_DATE").getTime()); 756 | 757 | if(rid!=null) // if there is a receiver 758 | { 759 | rdate=new Date (rs.getTimestamp("RET_DATE").getTime()); 760 | rd=(int)rid; 761 | } 762 | else 763 | { 764 | rdate=null; 765 | } 766 | 767 | boolean fineStatus = rs.getBoolean("FINE_PAID"); 768 | 769 | boolean set=true; 770 | 771 | Borrower bb = null; 772 | 773 | 774 | for(int i=0;i books = getBooks(); 831 | 832 | for(int k=0;k persons = lib.getPersons(); 866 | 867 | for(int i=0;i books = lib.getBooks(); 879 | 880 | for(int i=0;i books = loans; 931 | 932 | for(int i=0;i persons = lib.getPersons(); 946 | 947 | /* Setting Person ID Count */ 948 | int max=0; 949 | 950 | for(int i=0;i books = lib.getBooks(); 1103 | 1104 | /*Filling Book's Table*/ 1105 | for(int i=0;i