If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Threaded View

need help wif homework

*****LET ME MAKE THIS CLEAR! I DON'T NEED SOMEONE TO DO THE WHOLE PROGRAM FOR ME! I AM JUST GIVING YOU ALL THIS INFORMATION SO YOU WON'T BE CONFUSED ON WHAT THE PROGRAM IS ALL ABOUT... I JUST NEED SOMEONE TO CHECK THE BOOK CLASS CODE AND HELP ME WITH THE IFSTATEMENT IN THE PATRON CLASS! IT IS AT THE BOTTOM OF THIS LONG POST!

I am new to java and I need much help with my school assignment... Here is the problem... I must write a library program... here is the question

Patrons of a library can borrow up to three books. A patron, therefore, has a name and up to three books. A book has an author and a title. Design and implement two classes, Patron and Book, to represent these objects and the following behavior:

-The client can instantiate a book with a title and author
-The client can examine but not modify a book's title or author
-The client can ask a patron wthere it has borrowed a given book (identified by title).
-The client can tell a patron to return a given book (identified by title).
-The client can tell a patron to borrow a given book.

The Patron class should use a seperate instance variable for each book (a total of three).
Each of these variables is initially null. When a book is borrowed, the patron looks for a variable that is not null. If no such variable is found, the method returns false. If a null variable is found, it is reset to the new book and the method returns true. Similar considerations apply to other methods. Use the method aString.equals(aString) to compare two strings for equality. Be sure to include appropriate toString methods for your classes and test them with a tester program.

My teacher already wrote out a tester program for us... unfortunately... i don't have a copy of it to show..

this here is what i have come up for the Book class
public class Book

//Instance Variables
String author;
String title;

//Constructor method
public void Book(){
author =" ";
title = " ";

public void setName (String a, String t) // a being author and t being title
//set author and title
author = a;
title = t;

That's what i got... i dun know if that is even correct... but i think it's on the right track ne?
This is my little guide line that me and the teacher made

Book
Instance Vars - author, title (string)
Constructor - Book(), Book(author, title)
Methods- getAuthor, getTitle, toString
_________________________________
i followed that little map... and that's what i have got

pretty pathetic huh... i know the patron makes no sense at all... but yeah... i have a hunch...
i just recently stared at this problem for 5 intense minutes... and i have come up with this(for the if statement in Patron)