Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Answers/Yas_HasssanPour_40231712003/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
3 changes: 3 additions & 0 deletions Answers/Yas_HasssanPour_40231712003/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Answers/Yas_HasssanPour_40231712003/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Answers/Yas_HasssanPour_40231712003/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Answers/Yas_HasssanPour_40231712003/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Answers/Yas_HasssanPour_40231712003/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>Yas_HasssanPour_40231712003</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.example;

public class Admin extends User{
public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

private String password;
public Admin (String name, int ID, int phoneNuM, String password)
{
super(name, ID, phoneNuM);
this.password= password;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.example;

import java.util.HashMap;

public class Book {
private int Unique_bookID;
private String title;
private String author;
private boolean Availability_status;
String Description;

public int getUnique_bookID() {
return Unique_bookID;
}

public void setUnique_bookID(int unique_bookID) {
Unique_bookID = unique_bookID;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getAuthor() {
return author;
}

public void setAuthor(String author) {
this.author = author;
}

public boolean isAvailability_status() {
return Availability_status;
}

public void setAvailability_status(boolean availability_status) {
Availability_status = availability_status;
}


public Book (String title, int bookID, String author, String description) {
Unique_bookID = bookID;
this.title = title;
this.author = author;
this.Availability_status = true;
this.Description= description;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.example;

import java.util.Scanner;

public class CLI {
Scanner scanner = new Scanner(System.in);
System.out.println("Welcom to our library! What can we do for you?\n lib add book<name><authos><subtitle>: add a new book to the library\n lib get hrs: Retrieve library opening hours\n lib rent<bookName>: Rent a book from the library\nlib add member<studentID> <password>: Add a new member to the library (admin privilege reqiuered\nlib rent ");
String input = scanner.nextLine();

while (true) {
System.out.println("Enter a command (type 'help' for available commands):");
String command = scanner.nextLine();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.example;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Library {
public String getLibraryName() {
return LibraryName;
}

public void setLibraryName(String libraryName) {
LibraryName = libraryName;
}

public int getCapacity() {
return capacity;
}

public void setCapacity(int capacity) {
this.capacity = capacity;
}

public int getOperatingHours() {
return operatingHours;
}

public void setOperatingHours(int operatingHours) {
this.operatingHours = operatingHours;
}

private String LibraryName;
private int capacity;
private int operatingHours;
private ArrayList<Book>bookRepo;
private List<User>userRegistries;
private List<Rent>rentalRegistries;
public Library (String LibraryName,int capacity, int operatingHours)
{
this.LibraryName= LibraryName;
this.capacity= capacity;
this.operatingHours= operatingHours;
this.bookRepo= new ArrayList<>();
this.userRegistries= new ArrayList<>();
this.rentalRegistries= new ArrayList<>();
}
public void addBook(Book book)
{
bookRepo.add(book);
}
public void addUser(User user)
{
userRegistries.add(user);
}
public void rentBook(Book book, NormalUser user, int rentalID, Date rentalDate)
{
Rent rent = new Rent(book, user, rentalID, rentalDate);
rentalRegistries.add(rent);
book.setAvailability_status(false);
}
public void returnBook(Book book)
{
book.setAvailability_status(true);
}
public void removeUser (User user)
{
userRegistries.remove(user);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.example;

import java.util.Date;

public class MyApp {
public static void main(String[] args) {

Library library = new Library("My Library", 100, 9_5);

Book book1 = new Book("Book2", 82734,"author1", "Description1");
Book book2 = new Book("Book2", 23984,"author2", "Description2");
library.addBook(book1);
library.addBook(book2);

NormalUser user1 = new NormalUser("User1", 1234567890,"09112143646", new Date());
library.addUser(user1);


library.rentBook(book1, user1, 1, new Date());
library.returnBook(book1);
library.removeUser(user1);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.example;

import java.util.Date;

public class NormalUser extends User{
private Date registrationDate;

public Date getRegistrationDate() {
return registrationDate;
}

public void setRegistrationDate(Date registrationDate) {
this.registrationDate = registrationDate;
}

public NormalUser(String name, int ID, String phoneNum, Date registrationDate)
{
super(name,ID,phoneNum);
this.registrationDate= registrationDate;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.example;

import java.util.Date;

public class Rent {
public void setBook(Book book) {
this.book = book;
}

public void setNormalUser(NormalUser normalUser) {
this.normalUser = normalUser;
}

public void setRentalID(int rentalID) {
this.rentalID = rentalID;
}

public void setRentalDate(Date rentalDate) {
this.rentalDate = rentalDate;
}

private Book book;
private NormalUser normalUser;
private int rentalID;

public Book getBook() {
return book;
}

public NormalUser getNormalUser() {
return normalUser;
}

public int getRentalID() {
return rentalID;
}

public Date getRentalDate() {
return rentalDate;
}

private Date rentalDate;
public Rent (Book book, NormalUser normalUser, int rentalID, Date rentalDate)
{
this.book = book;
this.normalUser= normalUser;
this.rentalID = rentalID;
this.rentalDate= rentalDate;
}




}
Loading