/** * Write a description of class Book here. * * @author (Michael Clark) * @version (30th October 2012, version 0.1) */ public class Book { // instance variables - replace the example below with your own private int id; private String author; private String title; private boolean isFiction; /** * Constructor for objects of class Book */ public Book(String title, String author, int id, boolean isFiction) { // initialise instance variables this.id = 0; this.author = author; this.title = title; this.isFiction = false; } /** * Get the name of the book Author. * */ public String getAutor() { // put your code here return this.author; } /** * Get the book ID. */ public int getId() { return this.id; } /** * Get the book title. * */ public String getTitle() { return this.title; } public void setAuthor(String authorName) { author = authorName; } public void setId(int bookId) { id = bookId; } public void setTitle(String bookTitle) { title = bookTitle; } }
This is the book Class, every time i click on compile, it goes into an infinite compilation.
import java.util.ArrayList; /** * This Class would hold Membership details for the Library. * * @author (Michael Clark) * @version (30th October 2012, version 0.1) */ public class Member { // instance variables - These are member object attributes/fields private String firstName; private String lastName; private String phoneNumber; private int refNumber; /** * Constructor for objects of class Member */ public Member(String firstName, String lastName, String phoneNumber, int refNumber) { this.firstName = firstName; this.lastName = lastName; this.phoneNumber = phoneNumber; this.refNumber = refNumber; } /** * This is return method for the object firstname. * */ public String getfirstName() { return this.firstName; } /** * Return method for the last name. */ public String getlastName() { return this.lastName; } /** * Return method for the phone number. */ public String getPhoneNumber() { return this.phoneNumber; } /** * Return method for membership reference. */ public int getrefNumber() { return this.refNumber; } }
import java.util.ArrayList; /** * This is a model of a Library class. * * @author (Michael Clark) * @version (30th October 2012, version 0.1) */ public class Library { // instance variables private ArrayList<Membership> member; private ArrayList<Book> books; /** * Constructor for objects of class Library */ public Library(Membership member) { // initialise instance variables members = new ArrayList<Membership>(); books = new ArrayList<Book>(); }
This is the Library class to implement all the functionality, but really struggled here to integrate it into the rest of the classes. it also goes into an infinite compilation when I compile it.. Its a Uni project and the scenario is this =
(1) To create a member Class that keeps a basic information about each of its members e.g first name, last name, phone number and each member is also given a unique ID(positive integer)
(2) To create a book Class. Every book is given a unique positive integer ID which is used to track the loans. The library also records a books Author, Title, and whether its fiction or non-fiction.
(3) The loan class. A loan is a member borrowing a particular book. So if a member comes in and borrows 3 books its considered 3 loans. the loan period for all books is 3 wks. The library records the membership ID, the book ID number, the date loaned and the date due back. So here we have to add a loan for a given member and book ID numbers. Remove a loan for a given member and book ID numbers. List all loans giving book and member details. This should hold at least 2 attributes, members ID and books ID or member and book object references.
(4) The library Class should provide all the functionality required to maintain collections of members, books and loans. The library class should have 2 attributes of type ArrayLists one for the members and one for the books. with a constructor to create the arraylists
Any input would be appreciated guys.. thanx