2 Replies - 759 Views - Last Post: 13 January 2010 - 07:26 AM Rate Topic: -----

#1 someday.87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-January 10

library system,need help

Posted 13 January 2010 - 06:09 AM

hello,

here i have library system ,

my analysis for system,

the system should have,

1- book class = thats have title,author,isbn,availabe book, book on loan

2- reader class

3- loan class = thats have title of book, date

ok ,
i want,plz
1- main class ,
2- update book class
3- main search class

and thank you,,

mean with these code = > arrive to simple program with no data base, just code

because i want do refactoring..

waiting you ..
public class Book
{
	//FIELDS
	private String title;
	private String author;
	private String isbn;
	private int borrowed;
	private boolean onLoan;
	private boolean hardback;
	private int dueBack;
	// CONSTRUCTOR
	public Book(String bookTitle, String bookAuthor,boolean bookHardback, String booknum)
	{
		title = bookTitle;
		author = bookAuthor;
		isbn = booknum;
		hardback = bookHardback;
		borrowed = 0;
		dueBack = 0;
		onLoan = false;
	}
	

	

  /**
	 * return borrowed
	 */
	public int getBorrowed() //The amount of times it's been borrowed
	{
		return borrowed;
	}  
	/**
	 *Return on loan
	 */
	public boolean getOnLoan() //True if it is on loan, False if it isn't.
	{
		return onLoan;
	}
	/**
	 * return dueback
	 */
	public int getDueBack()  //the week of the year it has to be returned (1-52)
	{
		return dueBack;
	}



 private Scanner reader;
	public Library()
	{
		books = new ArrayList<Book>();
		reader = new Scanner(System.in);
	}


 //********
	//ADD ITEM
	//********  
	public void addBook(Book theBook)
	{
		books.add(theBook);
	}


	//******************
	// Search for a book
	//******************
	private int searchMethod(String bookisbn)
	{
	String booknumber = bookisbn;
			for(int x=0; x<books.size(); x++)
			{
				Book oneBook = books.get(x);
					if(oneBook.getisbn().equalsIgnoreCase(booknumber))
					{
					return x;
				}
			}
			return -1;	
		}
	//*************************
	// Delete item using book number
	//*************************
	  public void deleteBook(int searchMethod)
	  {		
		  int result = searchMethod;
		  if(result == -1){
			  System.out.println("Not Found");
			}
			else{
				books.remove(result);		  
		}
	}
	   
	//***********************
	//Display number of books
	//***********************
	public int numberBooks()
	{
		return books.size();
	}
   
	//******************
	// Make book On Loan
	//******************
	public void bookOnLoan(int searchMethod)
	{
		int result = searchMethod;
		if(result == -1){
			System.out.println("Not found");
		}
		else{
			System.out.println("Do you want to put this book on loan?");
		   
			Book.onLoan(result);
			Book.dueBack(
		   
		}
	}


	
	



This post has been edited by someday.87: 13 January 2010 - 07:24 AM


Is This A Good Question/Topic? 0
  • +

Replies To: library system,need help

#2 Simple_Condolences  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 138
  • Joined: 10-January 10

Re: library system,need help

Posted 13 January 2010 - 06:43 AM

Though we are all willing to help, please edit your first post and fix some of your spelling mistakes and reword your question clearly. Additionally, thank you for posting your code in the code brackets!

Glancing through your code, what I'm seeing is the following:

A constructor for a Book object, a constructor for a Library arrayList, and what you're saying is a loan class is actually a Boolean variable.

The Boolean variable onLoan is either going to be true or false. You cannot use it to hold data aside from those two options. From the looks of it, the purpose is to tell whether the book is checked out(true) or on the shelf/in the library(false).

Aside from this, however, I can't find out what you're asking us to do. Please update your new post with the edit feature. Thanks!

- Zach

EDIT: Wrong variable name.

This post has been edited by Simple_Condolences: 13 January 2010 - 06:45 AM

Was This Post Helpful? 0
  • +
  • -

#3 someday.87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-January 10

Re: library system,need help

Posted 13 January 2010 - 07:26 AM

done,,,

review the topic..

i hope you acceptabe this issue because my mother language not english...

bye ,,,

waiting your help ...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1