From 852e2f6c179b9bfa4fce3d20fcba9898fb5e53aa Mon Sep 17 00:00:00 2001
From: VASANTH KUMAR BHUKYA <58137524+vasanthkumar18@users.noreply.github.com>
Date: Tue, 5 Oct 2021 16:03:55 +0530
Subject: [PATCH 1/6] Create Readme.md
---
BookBorrow/Readme.md | 63 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
create mode 100644 BookBorrow/Readme.md
diff --git a/BookBorrow/Readme.md b/BookBorrow/Readme.md
new file mode 100644
index 0000000..580f20f
--- /dev/null
+++ b/BookBorrow/Readme.md
@@ -0,0 +1,63 @@
+# Question
+There is a class Book, which has the attributes bookID, title and author. There are two categories of books, TextBooks and ReferenceBooks.
+The text books can be borrowed by a user while the reference books cannot be. There is an extra attribute status (default value is Available)
+and borrowedUser in the class TextBooks. There is an interface Borrowable which has methods checkIn and checkOut. The class Book implements
+the Borrowable interface (Think and decide whether class Book is an abstract class or not).
+
+
+The functionality of the checkIn and checkOut methods in TextBooks class is as follows:
+checkIn : should set status attribute as Borrowed and should set the value of borrowedUser.
+checkOut : should set status attribute as Available
+
+
+The functionality of the checkIn and checkOut methods in ReferenceBooks class is as follows:
+checkIn : display “Invalid”
+checkOut : display “Cannot be borrowed”
+
+
+Sample Input and Output:
+1. Add Reference Book
+2. Add Text Book
+3. Check-Out
+4. Check-In
+5. List Books
+6. Exit
+
+
+
+### Enter your choice: 1
+Enter ID, Title and Author (Line by line)
+101
+Data Structures and Algorithms
+Cormen
+
+### Enter your choice: 2
+Enter ID, Title and Author (Line by line)
+102
+Programming Ruby
+Thomas
+
+### Enter your choice: 5
+ReferenceBook: 101: Data Structures and Algorithms: Cormen
+TextBook: 102: Programming Ruby: Thomas: Available
+
+### Enter your choice: 3
+Enter Book ID: 101
+Cannot be borrowed
+
+### Enter your choice: 3
+Enter Book ID: 102
+Enter Username: Ram
+
+### Enter your choice: 5
+ReferenceBook: 101: Data Structures and Algorithms: Cormen
+TextBook: 102: Programming Ruby: Thomas: Borrowed by Ram
+
+### Enter your choice: 4
+Enter Book ID: 102
+
+### Enter your choice: 5
+ReferenceBook: 101: Data Structures and Algorithms: Cormen
+TextBook: 102: Programming Ruby: Thomas: Available
+
+### Enter your choice: 6
From 1483910fbad75163a91eb37dc4da7124af2d7426 Mon Sep 17 00:00:00 2001
From: VASANTH KUMAR BHUKYA <58137524+vasanthkumar18@users.noreply.github.com>
Date: Tue, 5 Oct 2021 16:04:36 +0530
Subject: [PATCH 2/6] Update Readme.md
---
BookBorrow/Readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/BookBorrow/Readme.md b/BookBorrow/Readme.md
index 580f20f..6260496 100644
--- a/BookBorrow/Readme.md
+++ b/BookBorrow/Readme.md
@@ -24,7 +24,7 @@ Sample Input and Output:
6. Exit
-
+
### Enter your choice: 1
Enter ID, Title and Author (Line by line)
101
From 57d7d5ac2d9cad7e37e0e95c4b45f31bacf61f90 Mon Sep 17 00:00:00 2001
From: VASANTH KUMAR BHUKYA <58137524+vasanthkumar18@users.noreply.github.com>
Date: Tue, 5 Oct 2021 16:04:49 +0530
Subject: [PATCH 3/6] Update Readme.md
---
BookBorrow/Readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/BookBorrow/Readme.md b/BookBorrow/Readme.md
index 6260496..d05f9ec 100644
--- a/BookBorrow/Readme.md
+++ b/BookBorrow/Readme.md
@@ -1,7 +1,7 @@
# Question
There is a class Book, which has the attributes bookID, title and author. There are two categories of books, TextBooks and ReferenceBooks.
The text books can be borrowed by a user while the reference books cannot be. There is an extra attribute status (default value is Available)
-and borrowedUser in the class TextBooks. There is an interface Borrowable which has methods checkIn and checkOut. The class Book implements
+and borrowedUser in the class TextBooks. There is an interface Borrowable which has methods checkIn and checkOut. The class Book implements
the Borrowable interface (Think and decide whether class Book is an abstract class or not).
From b388dddf3e3960af6cee2c612fbaa12df7eb7bb8 Mon Sep 17 00:00:00 2001
From: VASANTH KUMAR BHUKYA <58137524+vasanthkumar18@users.noreply.github.com>
Date: Tue, 5 Oct 2021 16:05:39 +0530
Subject: [PATCH 4/6] Add files via upload
---
BookBorrow/Q6.java | 139 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 139 insertions(+)
create mode 100644 BookBorrow/Q6.java
diff --git a/BookBorrow/Q6.java b/BookBorrow/Q6.java
new file mode 100644
index 0000000..e187df4
--- /dev/null
+++ b/BookBorrow/Q6.java
@@ -0,0 +1,139 @@
+import java.util.*;
+import java.lang.*;
+import java.io.*;
+
+
+interface Borrower
+{
+ void checkin();
+ void checkout();
+}
+class Book
+{
+ int bookID;
+ String title;
+ String author;
+ String booktype;
+ String status="Available";
+ String borroweduser="";
+ Book(int bookID, String title, String author, String booktype)
+ {
+ this.bookID=bookID;
+ this.title=title;
+ this.author=author;
+ this.booktype=booktype;
+ }
+}
+
+public class Main
+{
+ public static void main(String[] args)
+ {
+ Scanner sc=new Scanner(System.in);
+ LinkedList lists=new LinkedList<>();
+ for(;;)
+ {
+ System.out.println("1. Add Reference Book\n2. Add Text Book\n3. Check-Out\n4. Check-In\n5. List Books\n6. Exit\n");
+ System.out.println("Enter your choice:");
+ int n=sc.nextInt();
+ String esc=sc.nextLine();
+ int id;
+ String title;
+ String author;
+ String username;
+
+
+ if(n==1)
+ {
+ System.out.println("Input ID, Title and Author");
+ id=sc.nextInt();
+ String buff=sc.nextLine();
+ title=sc.nextLine();
+ author=sc.nextLine();
+ Book b=new Book(id,title,author,"RefBook"); // RB: Reference Book
+ lists.add(b);
+ }
+
+ else if(n==2)
+ {
+ System.out.println("Input ID, Title and Author");
+ id=sc.nextInt();
+ String buff=sc.nextLine();
+ title=sc.nextLine();
+ author=sc.nextLine();
+ Book b=new Book(id,title,author,"TextBook"); // TB: Text Book
+ lists.add(b);
+
+ }
+ else if(n==3)
+ {
+ System.out.println("Input Book ID:");
+ id=sc.nextInt();
+ String buff=sc.nextLine();
+ for(Book b:lists)
+ {
+ if(b.bookID==id)
+ {
+ if(b.booktype.equals("RefBook"))
+ {
+ System.out.println("Cannot be borrowed");
+ break;
+ }
+ else
+ {
+ b.status="Borrowed";
+ username=sc.nextLine();
+ b.borroweduser=username;
+ }
+ }
+ }
+ }
+ else if(n==4)
+ {
+ System.out.println("Input Book ID:");
+ id=sc.nextInt();
+ for(Book b:lists)
+ {
+ if(b.bookID==id)
+ {
+ if(b.booktype.equals("RefBook"))
+ {
+ System.out.println("Invalid");
+ break;
+ }
+ else
+ {
+ b.status="Available";
+ }
+ }
+ }
+ }
+ else if(n==5)
+ {
+ for(Book b:lists)
+ {
+
+ if(b.booktype.equals("RefBook"))
+ {
+ System.out.println("ReferenceBook:"+b.bookID+":"+b.title+":"+b.author);
+ }
+ else
+ {
+ if(b.status.equals("Available"))
+ System.out.println("TextBook:"+b.bookID+":"+b.title+":"+b.author+":Available");
+ else
+ System.out.println("TextBook:"+b.bookID+":"+b.title+":"+b.author+":Borrowed by "+b.borroweduser);
+ }
+ }
+
+ }
+ else
+ {
+ break;
+ }
+
+
+
+ }
+ }
+}
From 985aecee48261bdc8a9c769744d762f457286550 Mon Sep 17 00:00:00 2001
From: VASANTH KUMAR BHUKYA <58137524+vasanthkumar18@users.noreply.github.com>
Date: Tue, 5 Oct 2021 16:06:12 +0530
Subject: [PATCH 5/6] Delete Q6.java
---
BookBorrow/Q6.java | 139 ---------------------------------------------
1 file changed, 139 deletions(-)
delete mode 100644 BookBorrow/Q6.java
diff --git a/BookBorrow/Q6.java b/BookBorrow/Q6.java
deleted file mode 100644
index e187df4..0000000
--- a/BookBorrow/Q6.java
+++ /dev/null
@@ -1,139 +0,0 @@
-import java.util.*;
-import java.lang.*;
-import java.io.*;
-
-
-interface Borrower
-{
- void checkin();
- void checkout();
-}
-class Book
-{
- int bookID;
- String title;
- String author;
- String booktype;
- String status="Available";
- String borroweduser="";
- Book(int bookID, String title, String author, String booktype)
- {
- this.bookID=bookID;
- this.title=title;
- this.author=author;
- this.booktype=booktype;
- }
-}
-
-public class Main
-{
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- LinkedList lists=new LinkedList<>();
- for(;;)
- {
- System.out.println("1. Add Reference Book\n2. Add Text Book\n3. Check-Out\n4. Check-In\n5. List Books\n6. Exit\n");
- System.out.println("Enter your choice:");
- int n=sc.nextInt();
- String esc=sc.nextLine();
- int id;
- String title;
- String author;
- String username;
-
-
- if(n==1)
- {
- System.out.println("Input ID, Title and Author");
- id=sc.nextInt();
- String buff=sc.nextLine();
- title=sc.nextLine();
- author=sc.nextLine();
- Book b=new Book(id,title,author,"RefBook"); // RB: Reference Book
- lists.add(b);
- }
-
- else if(n==2)
- {
- System.out.println("Input ID, Title and Author");
- id=sc.nextInt();
- String buff=sc.nextLine();
- title=sc.nextLine();
- author=sc.nextLine();
- Book b=new Book(id,title,author,"TextBook"); // TB: Text Book
- lists.add(b);
-
- }
- else if(n==3)
- {
- System.out.println("Input Book ID:");
- id=sc.nextInt();
- String buff=sc.nextLine();
- for(Book b:lists)
- {
- if(b.bookID==id)
- {
- if(b.booktype.equals("RefBook"))
- {
- System.out.println("Cannot be borrowed");
- break;
- }
- else
- {
- b.status="Borrowed";
- username=sc.nextLine();
- b.borroweduser=username;
- }
- }
- }
- }
- else if(n==4)
- {
- System.out.println("Input Book ID:");
- id=sc.nextInt();
- for(Book b:lists)
- {
- if(b.bookID==id)
- {
- if(b.booktype.equals("RefBook"))
- {
- System.out.println("Invalid");
- break;
- }
- else
- {
- b.status="Available";
- }
- }
- }
- }
- else if(n==5)
- {
- for(Book b:lists)
- {
-
- if(b.booktype.equals("RefBook"))
- {
- System.out.println("ReferenceBook:"+b.bookID+":"+b.title+":"+b.author);
- }
- else
- {
- if(b.status.equals("Available"))
- System.out.println("TextBook:"+b.bookID+":"+b.title+":"+b.author+":Available");
- else
- System.out.println("TextBook:"+b.bookID+":"+b.title+":"+b.author+":Borrowed by "+b.borroweduser);
- }
- }
-
- }
- else
- {
- break;
- }
-
-
-
- }
- }
-}
From b178b089ab1986019a151d38f58fd3a4f7a52138 Mon Sep 17 00:00:00 2001
From: VASANTH KUMAR BHUKYA <58137524+vasanthkumar18@users.noreply.github.com>
Date: Tue, 5 Oct 2021 16:06:46 +0530
Subject: [PATCH 6/6] Add files via upload
---
BookBorrow/Main.java | 139 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 139 insertions(+)
create mode 100644 BookBorrow/Main.java
diff --git a/BookBorrow/Main.java b/BookBorrow/Main.java
new file mode 100644
index 0000000..e187df4
--- /dev/null
+++ b/BookBorrow/Main.java
@@ -0,0 +1,139 @@
+import java.util.*;
+import java.lang.*;
+import java.io.*;
+
+
+interface Borrower
+{
+ void checkin();
+ void checkout();
+}
+class Book
+{
+ int bookID;
+ String title;
+ String author;
+ String booktype;
+ String status="Available";
+ String borroweduser="";
+ Book(int bookID, String title, String author, String booktype)
+ {
+ this.bookID=bookID;
+ this.title=title;
+ this.author=author;
+ this.booktype=booktype;
+ }
+}
+
+public class Main
+{
+ public static void main(String[] args)
+ {
+ Scanner sc=new Scanner(System.in);
+ LinkedList lists=new LinkedList<>();
+ for(;;)
+ {
+ System.out.println("1. Add Reference Book\n2. Add Text Book\n3. Check-Out\n4. Check-In\n5. List Books\n6. Exit\n");
+ System.out.println("Enter your choice:");
+ int n=sc.nextInt();
+ String esc=sc.nextLine();
+ int id;
+ String title;
+ String author;
+ String username;
+
+
+ if(n==1)
+ {
+ System.out.println("Input ID, Title and Author");
+ id=sc.nextInt();
+ String buff=sc.nextLine();
+ title=sc.nextLine();
+ author=sc.nextLine();
+ Book b=new Book(id,title,author,"RefBook"); // RB: Reference Book
+ lists.add(b);
+ }
+
+ else if(n==2)
+ {
+ System.out.println("Input ID, Title and Author");
+ id=sc.nextInt();
+ String buff=sc.nextLine();
+ title=sc.nextLine();
+ author=sc.nextLine();
+ Book b=new Book(id,title,author,"TextBook"); // TB: Text Book
+ lists.add(b);
+
+ }
+ else if(n==3)
+ {
+ System.out.println("Input Book ID:");
+ id=sc.nextInt();
+ String buff=sc.nextLine();
+ for(Book b:lists)
+ {
+ if(b.bookID==id)
+ {
+ if(b.booktype.equals("RefBook"))
+ {
+ System.out.println("Cannot be borrowed");
+ break;
+ }
+ else
+ {
+ b.status="Borrowed";
+ username=sc.nextLine();
+ b.borroweduser=username;
+ }
+ }
+ }
+ }
+ else if(n==4)
+ {
+ System.out.println("Input Book ID:");
+ id=sc.nextInt();
+ for(Book b:lists)
+ {
+ if(b.bookID==id)
+ {
+ if(b.booktype.equals("RefBook"))
+ {
+ System.out.println("Invalid");
+ break;
+ }
+ else
+ {
+ b.status="Available";
+ }
+ }
+ }
+ }
+ else if(n==5)
+ {
+ for(Book b:lists)
+ {
+
+ if(b.booktype.equals("RefBook"))
+ {
+ System.out.println("ReferenceBook:"+b.bookID+":"+b.title+":"+b.author);
+ }
+ else
+ {
+ if(b.status.equals("Available"))
+ System.out.println("TextBook:"+b.bookID+":"+b.title+":"+b.author+":Available");
+ else
+ System.out.println("TextBook:"+b.bookID+":"+b.title+":"+b.author+":Borrowed by "+b.borroweduser);
+ }
+ }
+
+ }
+ else
+ {
+ break;
+ }
+
+
+
+ }
+ }
+}