Thursday, October 1, 2015

[7.5] Online book reader system

1. Example

1.User membership creation and extension
2. Searching the database of books
3. Reading the books



2. Implementation






//
//keep all the book's information
//Method - add books
//Method - delete books
//Method - update books
//
public class Book
{
    private long ID;
    private String details;
    private static Set books;


    // Constructor
    public Book(long ID, Stirng details){...}


    // Class Method
    public static void addBook(long ID, String detials)
    {
         books.add(new Book(ID, details));
    }
    public static Book find(long ID)
    {
         for ( Book b: books)
             if (b.getID() == ID) return b
         return null;
    }
    public static  void delete (Book b)
    {
         books.remvoe(b);
    }


    // Object methods
    public void update (){}
}






//
//Keep all the information regarding the user ,and an identifier to //identify each user uniquely.
//We can add functionality like 
//Method - registering the user, 
//Method - charging a membership amount,
//Method - monthly / daily quota
//
public class User
{
     private long ID;
     private String details;
     private int accountType;
     private static Set users;

    
     // Constructor
     public User(long ID, Stirgn details, int accountType){...}



     // Class Method
     public static User find(long ID)
     {
          for (User u:users)
               if (u.getID() == ID) return u;
          return null;
     }
     public static void addUser()
     {
          users.add(  new User(ID, details, accountType));
     }



     // Object methods
     public Book searchLibrary(long ID) {return Book.find(id);}
     public void renewMembership(){...}    
}





//
//Manager class for managing the online book reader system which would //have a listen function to listen for any incoming requests to log in.
//It also provides 
//Method  - book search functionality and 
//Method  - display functionality.
//Because the end user interacts through this class, 
//SEARCH must be implemented
//
public class OnlineReaderSystem
{


       private Book b;
       private User u;



       // Constructor
       public OnlineReaderSystem(Book b, User u){...}
       


       // Object methods
       public void listenRequest(){}
       public Book searchBook(long ID){return book.find(ID);}
       public User searchUser(long ID){return user.find(ID);}
       public void display(){}


}



3. Similar Ones

No comments:

Post a Comment