Testing
Mort Test on demand
public class Book{
private static ArrayList<Book> library = new ArrayList<Book>(); //unused
protected String title;
protected int id;
private static int bookcount; // bookcount
public String toString(){
return title;
}
public Book(String title, int id){
this.title = title;
this.id = id;
Book.bookcount++; // count books
}
public static void main(String[] args){
Book book1 = new Book("Artsy", 1);
long book1time = System.nanoTime(); // start nanotime, not practical because it is outside the creation of the book
Book book2 = new Book("Crafty", 2);
long book2time = System.nanoTime(); // start nanotime
System.out.println("Book Name : " + book1.title);
System.out.println("ID : " + book1.id);
System.out.println("Nanoseconds : " + book1time); // print nanotime
System.out.println("Book Name : " + book2.title);
System.out.println("ID : " + book2.id);
System.out.println("Nanoseconds : " + book2time);
System.out.println("Book count: " + Book.bookcount);
}
}
Book.main(null)
public class Novel extends Book{ // extends
private String author;
public Novel(String title, int id, String author){
super(title, id); // pulls title and id from book
this.author = author;
}
public static void main(String[] args){ // tester for novel
Novel novel1 = new Novel("Artsies", 3, "Greg Heffley");
long novel1time = System.nanoTime(); // start nanotime, not practical because it is outside the creation of the novel
Novel novel2 = new Novel("Crafties", 4, "Robert Downey Jr.");
long novel2time = System.nanoTime(); // start nanotime
System.out.println("Novel Name : " + novel1.title);
System.out.println("ID : " + novel1.id);
System.out.println("Nanoseconds : " + novel1time);
System.out.println("Novel Name : " + novel2.title);
System.out.println("ID : " + novel2.id);
System.out.println("Nanoseconds : " + novel2time);
}
}
public class Textbook extends Book{ // extends
private String pubCo;
public Textbook(String title, int id, String pubCo){
super(title, id); // pulls title and id from book
this.pubCo = pubCo;
}
public static void main(String[] args){ // tester for textbook
Textbook textbook1 = new Textbook("Artser", 5, "Target");
long textbook1time = System.nanoTime(); // start nanotime, not practical because it is outside the creation of the textbook
Textbook textbook2 = new Textbook("Crafter", 6, "Walmart");
long textbook2time = System.nanoTime(); // start nanotime
System.out.println("Textbook Name : " + textbook1.title);
System.out.println("ID : " + textbook1.id);
System.out.println("Nanoseconds : " + textbook1time);
System.out.println("Textbook Name : " + textbook2.title);
System.out.println("ID : " + textbook2.id);
System.out.println("Nanoseconds : " + textbook2time);
}
}
Novel.main(null);
Textbook.main(null);