|
-
July 25th, 2003, 10:02 AM
#1
Senior Member
Java Programming Help
I have a practical that requires:
A book has the following attributes
1. title
2. author name
3. loan status
4. borrowerID
5. loan date
6. due dtae
a) declare these instance variables using String class, boolean type and GregorianCalendar class.
b) define a method(toString) that returns the Book object as a string format given:
title;author;loanStatus;borrowerID;day/month/year;day/month/year
c) define a static method(create) that takes in a string format given in (b), and create a Book object. Example of a given String
Data Structure;Michael Main;true;1234;01/08/2003;15/08/2003
d) define a main() method to test the Book class.
I have coded the following:
//Start of code
import java.util.*;
public class Book {
String title;
String author;
boolean loanStatus;
String borrowerID;
GregorianCalendar loanDate;
GregorianCalendar dueDate;
public String toString() {
return null;
}
public static void takeString(String title, String author, boolean loanStatus, String borrowerID, GregorianCalendar loanDate, GregorianCalendar dueDate) {
Book book1 = new Book();
}
public static void main(String[] args) {
Book book1 = new Book();
//book1.takeString("Data Structure", "Michael Main", true, 1234, 01/8/2003, 15/8/2003);
}
}
//End of Code
How can i use the toString method to return the Book object into the String format? using StringTokenizer? Anyone can help?
Btw, is this the right forum to post this question? Thank You...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|