The Artima Developer Community
Sponsored Link

Java Answers Forum
Help with A project

1 reply on 1 page. Most recent reply: Dec 8, 2008 11:32 PM by Kondwani Mkandawire

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
marwan sherif

Posts: 1
Nickname: marwan1990
Registered: Dec, 2008

Help with A project Posted: Dec 5, 2008 1:17 AM
Reply to this message Reply
Advertisement
So..I have this project ..it's about a library system...where we should make three classes..one for books..one for members...one for borrowing....then the main method...so i am now working in the books class,here is what required:
Books Management
1- Insert new books: This command adds a new book to our library. The added data is stored
in a file. The file is a text file that is comma delimited in which each entry (book) is found on a
separate line. Each entry must contain the main book information mentioned before. An
example of one line in the file is as follows:
Core Java, Cay S. Horstmann, Prentice Hall PTR, 0-13-089468-0, December 01 2000, 5, 3, Programming
2- Search for a book: The system should process a request by the user to look up information
about a specific entry. The user can supply one or more of the following; book title (or part of
it), author name, ISBN or category. The system should provide a list of books that matches the
user request.
3- Add new copy: The system should prompt the user to enter book ISBN and the number of
its copies and update the Book entry in the file with the new number of copies.
4- Delete book: The user should be prompted for the book ISBN and that entry should be
deleted from the system (books file).
So if anybody can post the code or just give me some tips I would be thankful...


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Help with A project Posted: Dec 8, 2008 11:32 PM
Reply to this message Reply
Homework help again hey?

> Books Management
> 1- Insert new books: This command adds a new book to our
> library. The added data is stored
> in a file. The file is a text file that is comma delimited
> in which each entry (book) is found on a
> separate line. Each entry must contain the main book
> information mentioned before. An
> example of one line in the file is as follows:
> Core Java, Cay S. Horstmann, Prentice Hall PTR,
> 0-13-089468-0, December 01 2000, 5, 3, Programming

Create a class (A Book Object)

public class Book implements Serializable{
    private String title;
    private String author;
    private String publisher;
    private String isbn;
    private java.util.Date publicationDate;
    private String category;
 
    //  TODO:   create getters and setters - use your IDE
 
}
 
//  In another class - remember each class should be in a different file
 
public class Controller {
 
    public static void insert(Book book) {
        //  Create a file writer to read/write from an existing file
        //  String line = book.getTitle() + ", " + book.getAuthor() + "...";
        //  writer.append(line +"\n");  //  depending on how your writer is setup
    }
 
    public static Book search(String title) {
        //  Create file reader - you can use the one above if you have extracted it to a method
        //  List<Book> books = new ArrayList<Book>();
        //  while (reader.hasMoreLines()){  // this is not real code so don't just copy and paste this you will have to google some of this stuff
               //  tokenize line create new Book from this line - use StringTokenizer()
         }
         for (Book book : books) {
             if (book.getTitle().equals(title)
                return book;
         }
         return null;
    }
 
    //  Your delete will use a similar algorithm to the search - now you can just clean your code up, e.g. extract method for reader - or to load all books from a file into an array.


This is as very close to just writing the code for you, hope this helps.

> 2- Search for a book: The system should process a request
> by the user to look up information
> about a specific entry. The user can supply one or more of
> the following; book title (or part of
> it), author name, ISBN or category. The system should
> provide a list of books that matches the
> user request.
> 3- Add new copy: The system should prompt the user to
> enter book ISBN and the number of
> its copies and update the Book entry in the file with the
> new number of copies.
> 4- Delete book: The user should be prompted for the book
> ISBN and that entry should be
> deleted from the system (books file).
> So if anybody can post the code or just give me some tips
> I would be thankful...

Flat View: This topic has 1 reply on 1 page
Topic: Currrent Info on the JVM Previous Topic   Next Topic Topic: Mobile Innovators, Pay Attention, Nokia Comes Calling

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use