Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
277f58f
add fields to Book.java
Faraaz03 Aug 28, 2020
4de2bb4
add constructor method to Book.java
Faraaz03 Aug 28, 2020
38bdfdf
add getter and setter methods for Book.bookName
Faraaz03 Aug 28, 2020
6d77097
add getter and setter methods for Book.authorName
Faraaz03 Aug 28, 2020
4e0b869
add getter and setter methods for Book.bookISBNNumber
Faraaz03 Aug 28, 2020
bb85987
add the toString() method to Book.java
Faraaz03 Aug 28, 2020
a9a0a0e
add the equals() method and hashcode() method to Book.java
Faraaz03 Aug 28, 2020
5278773
add fields to Library.java
Faraaz03 Aug 28, 2020
3a30b3a
add constructor method to Library.java
Faraaz03 Aug 28, 2020
dc2dcb0
add getter and setter methods to Library.java
Faraaz03 Aug 28, 2020
0c03341
create a method to add a returned book to Library.java
Faraaz03 Aug 28, 2020
c9b0af6
add a toString() method to Library.java
Faraaz03 Aug 28, 2020
91d8d0a
add the equals() and hashcode() method to Library.java
Faraaz03 Aug 28, 2020
257f62a
add private fields to Student.java
Faraaz03 Aug 28, 2020
314297d
add constructor method to Student.java
Faraaz03 Aug 28, 2020
f4c5cda
add getter and setter methods for nameOfTheStudent.
Faraaz03 Aug 28, 2020
3715a7d
add getter and setter methods for universityRollNumber
Faraaz03 Aug 28, 2020
749f79f
add getter and setter methods for numberOfBooksIssued
Faraaz03 Aug 28, 2020
ea4b808
add getter and setter methods for Books
Faraaz03 Aug 28, 2020
f4f580b
create a method to add an issued book to Student.java
Faraaz03 Aug 28, 2020
3536986
create a method to show all my issued books.
Faraaz03 Aug 28, 2020
93231a1
add the toString() method to Student.java
Faraaz03 Aug 28, 2020
3fbda2a
add the equals() and the hashcode() method to Student.java
Faraaz03 Aug 28, 2020
7d0896f
add private fields to FrontDesk.java
Faraaz03 Aug 28, 2020
07d99c7
create a scanner object
Faraaz03 Aug 28, 2020
4b871e7
take input from user.
Faraaz03 Aug 28, 2020
a13d0de
create a Student object and add some values to it.
Faraaz03 Aug 28, 2020
ac99c9d
create a menu as given in the problem statement and call the respecti…
Faraaz03 Aug 28, 2020
1636911
Updated your README file.
Faraaz03 Oct 1, 2020
d9d3eac
Re - revised your README file.
Faraaz03 Oct 1, 2020
b435eba
Re - revised your README file.
Faraaz03 Oct 1, 2020
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
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
Every good university/college has a well-stocked library for the students. The students get access to a wide variety of
literature on topics/subjects that are crucial for their personal as well as professional development. But as the
number of students using the library increases, the task of keeping records get very difficult. In this assignment, we
are going to simulate that task by writing a piece of software.
are going to simulate that task by writing a piece of software.
In this software we'll create some definition classes and execution classes.
We'll create as many objects as we can to improve the functioning of our Library.
We'll then call these objects in the execution classes to make a better library.



Expand Down Expand Up @@ -65,4 +68,5 @@ Since this is the first assignment, feel free to add as many methods as you can,
of a field, and a method; the name of a field should be a noun, and the name of a method should be a verb!

It is completely alright if you cannot implement the actual code for the methods, you can simple write a print
statement to represent that the methods are working, just like in the `Video Rental Inventory System` project.
statement to represent that the methods are working, just like in the `Video Rental Inventory System` project.
* Author - Naman Agarwal
68 changes: 67 additions & 1 deletion src/definitions/Book.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,76 @@
/* Created by IntelliJ IDEA.
* User: Divyansh Bhardwaj (dbc2201)
* User: Md. Faraaz Siddiqui (faraaz0)
* Date: 21/08/20
* Time: 3:49 PM
* File Name : Book.java
* */
package definitions;

import java.util.Objects;

public class Book {
private String bookName;
private String authorName;
private String bookISBNNumber;

public Book(String bookName, String authorName, String bookISBNNumber) {
this.bookName = bookName;
this.authorName = authorName;
this.bookISBNNumber = bookISBNNumber;
}

public String getBookName() {

return bookName;
}

public void setBookName(String bookName) {

this.bookName = bookName;
}

public String getAuthorName() {

return authorName;
}

public void setAuthorName(String authorName) {

this.authorName = authorName;
}

public String getIsbnNumber() {

return bookISBNNumber;
}

public void setIsbnNumber(String bookISBNNumber) {

this.bookISBNNumber = bookISBNNumber;
}

@Override
public String toString() {
return String.format(
"Book Name: %s, Author Name: %s, ISBN Number: %s",
getBookName(), getAuthorName(), getIsbnNumber()
);
}

@Override
public boolean equals (Object o){
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Book book = (Book) o;
return Objects.equals(getBookName(), book.getBookName()) &&
Objects.equals(getAuthorName(), book.getAuthorName()) &&
Objects.equals(getIsbnNumber(), book.getIsbnNumber());
}

@Override
public int hashCode () {
return Objects.hash(getBookName(), getAuthorName(), getIsbnNumber());
}


}
43 changes: 42 additions & 1 deletion src/definitions/Library.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,51 @@
/* Created by IntelliJ IDEA.
* User: Divyansh Bhardwaj (dbc2201)
* User: Md. Faraaz Siddiqui (faraaz0)
* Date: 21/08/20
* Time: 3:50 PM
* File Name : Library.java
* */
package definitions;

import java.util.Arrays;

public class Library {
private Book[] books;

public Library() {

this.books = new Book[1000];
}

public Book[] getBooks() {

return books;
}

public void setBooks(Book[] books) {

this.books = books;
}


@Override
public String toString() {
return String.format(
"Books List: %s", getBooks());
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Library library = (Library) o;
return Arrays.equals(getBooks(), library.getBooks());
}

@Override
public int hashCode() {

return Arrays.hashCode(getBooks());
}


}
94 changes: 94 additions & 0 deletions src/definitions/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,99 @@
* */
package definitions;

import java.util.Arrays;
import java.util.Objects;


public class Student {
private String[] nameOfTheStudent;
private long universityRollNumber;
private int numberOfBooksIssued;
private Book[] books;

public Student(String nameOfTheStudent, long universityRollNumber, int numberOfBooksIssued) {
this.nameOfTheStudent = nameOfTheStudent.split(" ");
this.universityRollNumber = universityRollNumber;
this.numberOfBooksIssued = numberOfBooksIssued;
this.books = new Book[numberOfBooksIssued];
}

public String[] getNameOfTheStudent() {

return nameOfTheStudent;
}

public void setNameOfTheStudent(String[] nameOfTheStudent) {

this.nameOfTheStudent = nameOfTheStudent;
}

public long getUniversityRollNumber() {

return universityRollNumber;
}

public void setUniversityRollNumber(long universityRollNumber) {

this.universityRollNumber = universityRollNumber;
}

public int getNumberOfBooksIssued() {

return numberOfBooksIssued;
}

public void setNumberOfBooksIssued(int numberOfBooksIssued) {

this.numberOfBooksIssued = numberOfBooksIssued;
}

public Book[] getBooks() {
return books;
}

public void setBooks(Book[] books) {
this.books = books;
}

public void addNewBook(String bookName) {
System.out.println(bookName + " has been successfully issued.");
}

public void myIssuedBooks() {
for (Book books : books) {
System.out.println(books);
}
}

public void returnAnIssuedBook(String bookName) {
System.out.println(bookName + " has been successfully returned.");
}

@Override
public String toString() {
return String.format(
"Student Name: %s, University Roll Number: %l, Number Of Books Issued: %d, Name Of Books Issued By The Student: %d",
getNameOfTheStudent(), getUniversityRollNumber(), getNumberOfBooksIssued(), getBooks()
);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Student student = (Student) o;
return getUniversityRollNumber() == student.getUniversityRollNumber() &&
getNumberOfBooksIssued() == student.getNumberOfBooksIssued() &&
Arrays.equals(getNameOfTheStudent(), student.getNameOfTheStudent()) &&
Arrays.equals(getBooks(), student.getBooks());
}

@Override
public int hashCode() {
int result = Objects.hash(getUniversityRollNumber(), getNumberOfBooksIssued());
result = 31 * result + Arrays.hashCode(getNameOfTheStudent());
result = 31 * result + Arrays.hashCode(getBooks());
return result;
}
}
54 changes: 54 additions & 0 deletions src/execution/FrontDesk.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,62 @@
* */
package execution;

import definitions.Student;

import java.util.Scanner;

public class FrontDesk {
private static final int ADD_NEW_BOOK = 1;
private static final int RETURN_BOOK = 2;
private static final int MY_ISSUED_BOOKS = 3;
private static final int EXIT = 4;

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int userInput;
Student student = new Student("Md Faraaz Siddiqui", 191500454, 3);
do {
System.out.println("-=-=--=-=-Welcome To The Front Desk-=-=--=-=-");
System.out.println("How may I help you today?");
System.out.println("1. Issue a new book for me: ");
System.out.println("2. Return a previously issued book for me: ");
System.out.println("3. Show me all my issued books: ");
System.out.println("4. Exit.");
System.out.println("Enter your choice (1..4): ");
userInput = scanner.nextInt();
switch (userInput) {
case ADD_NEW_BOOK:
System.out.println("Enter the name of the book you want to read: ");
scanner.nextLine();
String bookName = scanner.nextLine();
student.addNewBook(bookName);
break;

case RETURN_BOOK:
System.out.println("Enter the name of the book you want to return: ");
scanner.nextLine();
bookName = scanner.nextLine();
student.returnAnIssuedBook(bookName);
break;

case MY_ISSUED_BOOKS:
student.myIssuedBooks();
break;
default:
System.out.println("WRONG CHOICE!");
}
}

while (userInput != EXIT);
{
scanner.close();
}


}
}