[snip for readablility]
My first 18 - 20 attempts to re-code LibraryTester to accept user input was:
import TerminalIO.KeyboardReader;
import java.text.NumberFormat;
import BreezySwing.Format;
public class LibraryTester {
public static void main (String[] args){
// Instantiate the Patrons & Books and the keyboard
Patron patron1 = new Patron();
Patron patron2 = new Patron();
Patron patron3 = new Patron();
//Book b1 = new Book();
//Book b2 = new Book();
//Book b3 = new Book();
KeyboardReader reader = new KeyboardReader();
String name;
String book;
// Input the first patron's data
name = reader.readLine("Enter the first patron's name: ");
//patron1.setName(name);
for (int i = 1; i <= 3; i++){
book = reader.readLine("Enter the book's title: ");
student1.setBook(i, book);
}
// Input the second patron's data
name = reader.readLine("Enter the second patron's name: ");
patron2.setName(name);
for (int i = 1; i <= 3; i++){
book = reader.readLine("Enter the book's title: ");
patron2.setBook(i, book);
}
// Input the third patron's data
name = reader.readLine("Enter the third patron's name: ");
patron3.setName(name);
for (int i = 1; i <= 3; i++){
book = reader.readLine("Enter the book's title: ");
patron3.setBook(i, book);
}
// Output the three patrons information
System.out.println(patron1);
System.out.println(patron2);
*****************************************
I know that I am missing a piece somewhere. Between my wife complaining the
kitchen table is
cluttered with all my java info, books, print outs, and other research stuff
for the last week, I am starting
to believe that I don't understand how to pass info in java.
Any comments, directions, would be greatly appreciated.
Thank you very much for all those that take a minute to review my kaos.
Randy
Andrew Harker - 03 Apr 2004 14:14 GMT
> I know that I am missing a piece somewhere. Between my wife complaining the
> kitchen table is
[quoted text clipped - 9 lines]
>
> Randy
I suggest you start with one class and make that do what you want
rather than trying to integrate all these classes all at once.
For each class write a little test harness and check it out - this
will also help you work out how to create a class, call each method,
etc. Code a bit then test it. Pay attention to things like variable
names, scope etc are correct (also follow Roedy's advice too). Look
at various data structures (eg arrays) and play with those a bit at a
time too.
You could use test classes like JUnit but to start with take advantage
of the fact you can have a 'main' in each class ... eg here is a simple
book demo ...
// file Book.java
public class Book {
private String title;
private String author;
Book(String title) {
this(title, "Unknown");
}
Book(String title, String author) {
this.title = title;
this.author = author;
}
public String toString() {
return "Book:title["+title+"],author["+author+"]";
}
public void setAuthor(String author) {
this.author = author;
}
// this will test out the Book class
public static void main(String[] args) {
Book b1 = new Book("Big words");
System.out.println(b1);
b1.setAuthor("RT");
System.out.println(b1);
// Book[] books = new Book[3];
// books[0] = new Book("One", "Fred");
// books[1] = new Book("Two");
// books[2] = new Book("Three", "Barney");
// following is equiv. to above
Book[] books = {
new Book("One", "Fred"),
new Book("Two"),
new Book("Three", "Barney")
};
for (int i = 0; i < books.length; i++) {
System.out.println(books[i]);
}
}
}
Randy Tingley - 03 Apr 2004 14:55 GMT
> > I know that I am missing a piece somewhere. Between my wife complaining the
> > kitchen table is
[quoted text clipped - 68 lines]
>
> }
Thank you! I will try this.
Randy
Randy Tingley - 03 Apr 2004 17:34 GMT
> > > I know that I am missing a piece somewhere. Between my wife complaining
> the
[quoted text clipped - 73 lines]
> Thank you! I will try this.
> Randy
I think I got it!
Thank you very much!
Andrew Thompson - 04 Apr 2004 08:25 GMT
> ..Between my wife complaining the
> kitchen table is
> cluttered with all my java info,
And our group is becoming cluttered with
your untrimmed replies, 85 lines for your
last reply to say 'thank you', is ridiculous.
Please use the 'delete' key before responding..
<http://www.physci.org/kbd.jsp?key=del>

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Randy Tingley - 04 Apr 2004 13:44 GMT
> And our group is becoming cluttered with
> your untrimmed replies, 85 lines for your
> last reply to say 'thank you', is ridiculous.
>
> Please use the 'delete' key before responding..
> <http://www.physci.org/kbd.jsp?key=del>
Do you grip all the time?
First to you bring to my attention that I am top posting.
I read your link and made sure that I did not do that again.
Next you told me that when replying I, "cut" or "snipped" to
much of the text out. Now people couldn't see all the question.
Now you are telling me that I am not cutting out enough?
once again you attached a link for me to review.
This newsgroup has taught me alot of valuable information
on java programming that I can not get from any book. This to
me is a "priceless" newsgroup.
I am trying to gain the knowledge that these wonderful people are
willing to share, along with learning this group's rules. I looked in
this group for FAQ's, but there are none?
Thank you, for all that ARE assisting me in my quest for knowledge.