Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Anyone there have source code of library system?

  Asked By: Bonni    Date: Feb 22    Category: Java    Views: 3106
  

This program cannot store the previous record. Can someone help me to
solve this problem?

Anyone there have source code of library system?

import java.lang.*;
import java.io.*;

class ClearScr{
public static void clrscr(){
for(int cnt=0; cnt<=24; cnt++){
System.out.println();
}
}
}

class BooksInfo{

public String Btitle;
public String Bisbn;
public String Bauthor;
public String name;
public String date;
public String Rdate;
public String status;
public String status2;

public void includeBooks()throws java.io.IOException{

InputStreamReader ir = new InputStreamReader
(System.in);
BufferedReader in = new BufferedReader(ir);

System.out.println("\n\n\n\n\n\n");
System.out.println("
***********************");
System.out.println
(" Book Shop");
System.out.println("
***********************");
System.out.println("\n");
System.out.println("
Book in the Catalog");
System.out.println
("====================================================================
============");
System.out.println("");
System.out.println("");
System.out.print(" Enter Author's
Name :");
Bauthor = in.readLine();

System.out.print(" Enter the Title of the
Book :");
Btitle = in.readLine();

System.out.print(" Enter the ISBN of the
Book :");
Bisbn = in.readLine();

System.out.print(" Enter Book Status
(in/out) :");
status = in.readLine();

System.out.println();
}

public void borrowBooks()throws java.io.IOException{

InputStreamReader ir = new InputStreamReader
(System.in);
BufferedReader in = new BufferedReader(ir);

System.out.println("\n\n\n\n\n\n");
System.out.println
(" ***********************");
System.out.println
(" Book Shop");
System.out.println
(" ***********************");
System.out.println("\n");
System.out.println("\t\t\t*** Check Out
Books ***");
System.out.println("\t\t\t----------------
-----\n");

System.out.print("\t\t\tMember's
Name : ");
name = in.readLine();

System.out.print("\t\t\tRent Date : ");
date = in.readLine();

System.out.print("\t\t\tDue Date : ");
Rdate = in.readLine();
}

public void returnBooks()throws java.io.IOException{

InputStreamReader ir = new InputStreamReader
(System.in);
BufferedReader in = new BufferedReader(ir);

System.out.println("\t PLEASE KeyIn (in) for
retun book || (out) for no return book");
System.out.println("\n");

System.out.print("\t Enter Book Status
(in/out) :");
status2 = in.readLine();

}

public void DisplayBooks()throws java.io.IOException{

System.out.println("\t\t\tTitle : "+ Btitle);

System.out.println("\t\t\tISBN : "+ Bisbn);
System.out.println("\t\t\tAuthor: "+ Bauthor);
System.out.println("\t\t\tRent Date : "+ date);
System.out.println("\t\t\tDue Date : "+ Rdate);
System.out.println("\t\t\tBook Status : "+
status);
System.out.println("\t\t\tMember's Name : "+
name);
System.out.println();
}

}
class Options
{
int total;
String QtyOfBooks ="";
String name2;
String name ="";
String date ="";
String Rdate ="";
String status ="";
String status2 ="";

boolean inputCorrect = true;
BooksInfo[] bk = new BooksInfo[3];

public void option1()throws java.io.IOException{

ClearScr.clrscr();
System.out.println("\t\t\t*** Include Books ***");
System.out.println("\t\t\t---------------------
\n");
System.out.print("\t\t\tEnter Quantity of
Books :");
InputStreamReader ir = new InputStreamReader
(System.in);
BufferedReader in = new BufferedReader(ir);
QtyOfBooks = in.readLine();
total = Integer.parseInt(QtyOfBooks);

System.out.println();

if(total <= bk.length){

for(int cnt=0; cnt<total; cnt++){

bk[cnt] = new BooksInfo();
bk[cnt].includeBooks();
}
}
}

public void option2()throws java.io.IOException{

ClearScr.clrscr();
System.out.println("\t\t\t*** Check Out Books
***");
System.out.println("\t\t\t---------------------
\n");
System.out.print("\t\t\tEnter Quantity of
Books :");
InputStreamReader ir = new InputStreamReader
(System.in);
BufferedReader in = new BufferedReader(ir);
QtyOfBooks = in.readLine();
total = Integer.parseInt(QtyOfBooks);

System.out.println();

if(total <= bk.length){

for(int cnt=0; cnt<total; cnt++){

bk[cnt] = new BooksInfo();
bk[cnt].borrowBooks();
bk[cnt].includeBooks();

}
}
}

public void option3()throws java.io.IOException{

ClearScr.clrscr();
System.out.println("\n\t\t\t*** Return Books
***\n");
System.out.println("\t\t\t------------------------
\n");

System.out.print("\t\t\tEnter Member's Name: ");
InputStreamReader ir = new InputStreamReader
(System.in);
BufferedReader in = new BufferedReader(ir);
name2 = in.readLine();
System.out.println();


for(int cnt=0; cnt<total; cnt++){

if(bk[cnt].name.equals(name2)){
System.out.println
("\t\t\tMember's name : "+bk[cnt].name);
System.out.println("\n");
System.out.println
("\t\t\tISBN : "+bk[cnt].Bisbn);
System.out.println
("\t\t\tTitle : "+bk[cnt].Btitle);
System.out.println("\n");
System.out.println("\t\t\tRent
Date : "+bk[cnt].date);
System.out.println("\t\t\tDue
Date : "+bk[cnt].Rdate);
System.out.println("\n");

System.out.println();
}
}
if(total <= bk.length){

for(int cnt=0; cnt<total; cnt++){

bk[cnt] = new BooksInfo();
bk[cnt].returnBooks();

}
}

System.out.print("Press enter to continues");
in.readLine();
}



public void option4()throws java.io.IOException{

ClearScr.clrscr();
System.out.println("\n\t\t\t*** Display Books
Status ***\n");
System.out.println("\t\t\t-------------------------
--------\n");

for(int cnt=0; cnt<total; cnt++){

bk[cnt].DisplayBooks();

}

System.out.print("\t\t\tPress enter to continues");
InputStreamReader ir = new InputStreamReader
(System.in);
BufferedReader in = new BufferedReader(ir);
in.readLine();
}

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Rickey Scott     Answered On: Feb 22

You should use database or file to store  the book  info when a user
add a book. Otherwise when the program  exit, nothing will exist. You
can find example in java.sun.com.

 
Answer #2    Answered By: Monique Perry     Answered On: Feb 22

When u add the entries on run times normally that data is not for presistant
like it is placed in ram there it can't be stored permannet and it'll be vanish
as ur program  exit and for that it is more appropriate to use databases at the
back end. it is not difficult there r just like 7 or 8 commands and u'll able to
store data. and you have to use java.sql package for that take a look at its
help it will me very usefull to you.

 
Answer #3    Answered By: Roosevelt Jenkins     Answered On: Feb 22

Is the code  for schooling or for work? If work, then
you need a decend database to contain your data and
use java.sql manipulated it. If school, then create a
.txt file to contain your data. Li was very closed
when responding to you.

 
Didn't find what you were looking for? Find more on Anyone there have source code of library system? Or get search suggestion and latest updates.




Tagged: