import javax.swing.plaf.PanelUI;
import java.util.Scanner;
class library {
public int addBookSize=4;
public int returnBookSize=3;
public int issueBooksSize=3;
Scanner sca = new Scanner(System.in);
String [][] availableBook;
{
availableBook = new String[][]{{"m2", "oop", "english","php","","","","","",""}, {"mic", "dsa", "m1","","","","","","",""}};
}
public int availableBookLength = availableBook.length;//2
public int returnBookLength = availableBook[0].length;//10
public int addBookLength = availableBook[1].length;//10
public void showBook(){
System.out.print("ALL BOOKS : ");
for (int i=0;i<availableBookLength;i++){
for (int j = 0; j < 10; j++) {
System.out.print(" "+availableBook[i][j]);
}
}
System.out.println(" ");
}
public void showRetBook(){
System.out.print("RETURNED BOOKS : ");
for (int i = 0; i < returnBookLength; i++) {
System.out.print(" "+availableBook[1][i]);
}
System.out.println("");
}
public void addBook(){
if (addBookSize==addBookLength){
System.out.println("SORRY NOT ENOUGH SPACE--");
}
else {
for (int i = addBookSize; i < addBookLength; i++) {
addBookSize++;
System.out.println("ADD BOOK TO BLOCK : " + addBookSize);
String seven = sca.next();
availableBook[0][i] = seven;
// libSize++;
System.out.println(" DO YOU WANTS TO ADD MORE BOOKS YES=1 NO=2");
int s = sca.nextInt();
if (addBookSize==10){
System.out.println("SORRY NOT ENOUGH SPACE : "+addBookSize);
}
if (s == 1) {
continue;
}
else {
break;
}
}
}
}
public void returnBook(){
if (returnBookSize==returnBookLength){
System.out.println("SORRY NOT ENOUGH SPACE");
}
else {
for (int i = returnBookSize; i < returnBookLength; i++) {
returnBookSize++;
System.out.println("ADD RETURN_BOOK TO BLOCK : " + returnBookSize);
String seven = sca.next();
availableBook[1][i] = seven;
System.out.println(" DO YOU WANTS RETURN MORE BOOKS YES=1 NO=2");
int s = sca.nextInt();
if (returnBookSize==10){
System.out.println("SORRY NOT ENOUGH SPACE : "+returnBookSize);
}
if (s == 1) {
continue;
} else {
break;
}
}
}
}
String[] issueBooks = new String[]{"Mic", "OOP", "DSA", "", "", "", "", "", "", ""};
int issueLength = issueBooks.length;
public void showIssueBooks(){
System.out.print("ISSUE BOOKS : ");
for (int i = 0; i < issueLength; i++) {
System.out.print(" " + issueBooks[i]);
}
System.out.println("");
}
// ADD ISSUE_BOOKS START
public void addIssueBooks(){
if (issueBooksSize==issueLength){
System.out.println("SORRY NOT ENOUGH SPACE");
}
else {
for (int i = issueBooksSize; i < issueLength; i++) {
issueBooksSize++;
System.out.println("ADD ISSUE_BOOK TO BLOCK : " + issueBooksSize);
String seven = sca.next();
issueBooks[i] = seven;
System.out.print("BOOK ADDED TO ");
showIssueBooks();
System.out.println(" DO YOU WANTS TO ADD MORE ISSUE_BOOKS YES=1 NO=2");
int s = sca.nextInt();
if (issueBooksSize==10){
System.out.println("SORRY NOT ENOUGH SPACE : "+issueBooksSize);
}
if (s == 1) {
continue;
} else {
break;
}
}
}
}
}
public class libr_practice {
public static void main(String[] args) {
// You have to implement a library using java class library - done
// Methods : addBook,
// issueBook,
// returnBook,
// showAvailableBooks(),
// propertied : Array to store the available Books,
// Array to show available Books,
Scanner sc = new Scanner(System.in);
library ob = new library();
while (true) {
System.out.println("1=SHOW_BOOKS,2=ADD_BOOK,3=ISSUE_BOOK,4=ADD_ISSUE_BOOK,5=SHOW_RETURN_BOOK,6=RETURN_BOOK");
int action = sc.nextInt();
if (action == 1) {
// ob.showBooks();
ob.showBook();
} else if (action == 2) {
// ob.addBooks();
ob.addBook();
} else if (action == 3) {
ob.showIssueBooks();
} else if (action == 4) {
ob.addIssueBooks();
} else if (action==5) {
ob.showRetBook();
} else if (action==6) {
ob.returnBook();
}
}
}
}