Created
October 2, 2012 15:08
-
-
Save benfb/3819925 to your computer and use it in GitHub Desktop.
BBaileyBookRunner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BBaileyBookRunner | |
{ | |
public static void main(String args[]) | |
{ | |
BBaileyBook textBook = new Book(); //creates a new object textbook of class Book | |
textBook.setName("Scooby Doo"); //sets the name of textBook to "Scooby Doo" | |
textBook.getName(); //println would print default values if the default constructor was called. In this case, the output matches the input | |
System.out.println(textBook); //What does this line do? It calls the .toString() method | |
BBaileyBook theStranger = new Book("The Stranger", 123456789); //creates a new book with title "The Stranger" and ISBN 123... | |
System.out.println(textBook.getName); //prints textBook's name | |
theStranger.setName("Even Stranger"); //the method setName is used to change the name, and is a modifier method | |
theStranger.getName(); //does not print anything because there is no print statement in the method. getName is an accessor method | |
theStranger.setISBN(143412597); //changes theStranger's ISBN to 143412597 | |
System.out.println(theStranger); //calls the toString method of theStranger object | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment