Test - Meena Annamalai
Period 1
public class Book {
private String title;
int uniqueID = (int)(Math.random() * 987);
String bookInfo;
public static int bookCount = 0;
String listOfBooks;
//public static long currentTimeMillis();
public Book (String title) {
this.title = title;
//this.uniqueID = uniqueID;
this.bookCount = bookCount;
}
public String toString() {
return "The title of this book is " + this.title;
}
public String getTitle() {
return "this is the book title: " + this.title;
}
public int getUniqueID() {
return this.uniqueID;
}
public long getTime() {
return System.currentTimeMillis();
}
public int bookCount() {
//listOfBooks.append(this.Book);
return bookCount;
}
public static void main (String[] args) {
Book myBook = new Book("grapes of wrath");
System.out.println("this is the title: " + myBook.title);
myBook.getTitle();
System.out.println(myBook.getUniqueID());
Book myOtherBook = new Book("harry potter");
System.out.println("this is the title: " + myOtherBook.title);
myOtherBook.getTitle();
System.out.println(myOtherBook.getUniqueID());
myOtherBook.toString();
Book[] bookCounter = {myBook, myOtherBook};
for(int i=0; i < bookCounter.length; i++) {
bookCount++;
}
System.out.println("This is the total number of books " + bookCount);
System.out.println(System.currentTimeMillis());
//tester
}
}
Book.main(null);
public class Novel extends Book {
public String author;
Novel(String title) {
super(title);
this.author = author;
}
public String Display() {
System.out.println("hello library member");
System.out.println(super.getTitle());
System.out.println("Time book entered library " + super.getTime());
return super.getTitle();
}
public String getAuthor() {
return "this is the novel author: " + this.author;
}
public void setAuthor(String newAuthor) {
this.author = newAuthor;
}
}
public class Textbook extends Book {
public String company;
Textbook(String title) {
super(title);
this.company = company;
}
public String Display() {
System.out.println("hello library member");
System.out.println(super.getTitle());
System.out.println("Time book entered library " + super.getTime());
return super.getTitle();
}
public String getCompany() {
return "this is the textbook company: " + this.company;
}
public void setCompany(String newCompany) {
this.company = newCompany;
}
}
public class Tester{
public static void main(String[] args)
{
Novel myNovel = new Novel("saumya's life story novel");
myNovel.setAuthor("saumya");
myNovel.Display();
System.out.println(myNovel.getAuthor());
Textbook myAPCSATextbook = new Textbook("AP CSA Textbook");
myAPCSATextbook.setCompany("collegeboard");
myAPCSATextbook.Display();
System.out.println(myAPCSATextbook.getCompany());
}
}
Tester.main(null);