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
44 changes: 44 additions & 0 deletions report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 3rd Assignment Report

![](https://github.com/kianaghamsari/Second-Assignment/blob/develop/uni.png)

## Kiana Ghamsari - 400222079


# Introduction

The purpose of the application is to manage a library using Java Object-Oriented Programming.

The application includes 5 classes:
* Book
* Librarian
* Library
* Main
* User

You can sign up or login if you already have an account as a ordinary user who can borrow a book, or as a librarian who manages the library.


# Structure

* The `Library` class is the most important , and also, class `Main` runs the program by calling the method called `runMenu()`.
* The methods `newUserSignUp()` and `newLibrarianSignUp()` are created in `Main` to let new users sign up as either an ordinary user or a librarian.
* Users can borrow and return books from the library by `rentBook()` and `returnBook()` methods, respectively, defined in `User` class.
* The add, update, search, remove operations on all books and users objects are accessed only by librarians. These methods are defined in `Library` class.
* A Librarian can also borrow or return books due to it’s inheritance of `User` class.
* Librarian can, also, add or remove another librarian.

# Bonus
In my implementation:

* Usernames are unique
* A book cannot be borrowed twice
* The user cannot return the book that has not been borrowed
* All fields are private, and proper getters and setters are defined
* All functionalities are available from GUI

# Conclusion:
* By this project, I've used basic concepts of object-oriented programming in an example.
* I, also, experienced working with access modifiers, public and private methods.
* I broke my code into individual classes that helped me increasing the readability of my code
* I didn't provide a back and exit command
49 changes: 49 additions & 0 deletions src/main/java/Book.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
public class Book {
//Book should contain name,author,year of publish and ISBN
private String name;
private String author;
private int yearOfPublish;
private String ISBN;

public Book(String name, String author, int yearOfPublish, String ISBN) {
this.name = name;
this.author = author;
this.yearOfPublish = yearOfPublish;
this.ISBN = ISBN;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getAuthor() {
return author;
}

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

public int getYearOfPublish() {
return yearOfPublish;
}

public void setYearOfPublish(int yearOfPublish) {
this.yearOfPublish = yearOfPublish;
}

public String getISBN() {
return ISBN;
}

public void setISBN(String ISBN) {
this.ISBN = ISBN;
}

@Override
public String toString() {
return "Here is the information of " + this.getName() + "book:\nThe Book's Name: " + getName() + "\nThe Author's Name: " + getAuthor() + "\nThe Book's Year of Publish: " + getYearOfPublish() + "\nThe Book's ISBN: " + getISBN();
}

}
21 changes: 14 additions & 7 deletions src/main/java/Librarian.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
public class Librarian {
/*
* The librarian should have a username and a password
* The librarian should be able to search users, librarians and books
* The librarian should be able to add\remove\update user add\remove\update_
_ librarian and add\remove\update book
*/
public class Librarian extends User {
// /*
// * The librarian should have a username and a password
// * The librarian should be able to search users, librarians and books
// * The librarian should be able to add\remove\//update user add\remove\//update_
// _ librarian and add\remove\//upd//ate book
// */

public Librarian() {
super();
}

public Librarian(String username, String password) {
super(username, password);
}

}
Loading