Sunday, September 30, 2012
Book/BookRunner
This past week, we started a lab called Book/BookRunner, where we created different constructors and utilized different methods. We created a default constructor, an initialization constructor, modifier method, accessor method, toString() method, etc. Until about 75% of the way through the lab, it finally dawned upon me that the setbookName() method meant to set the name of the book to a new name. Oh, so the names of the methods actually do mean something! While I admit it was a rather slow epiphany, it made things easier as I started to work on BookRunner and as I utilized all the methods to do what I wanted. Also, I liked the fact that I could combine System.out.println() with an object and another method. For instance, I could say System.out.println(textbook.getbookName()); and it's interesting how it can do everything at once in the same line of code. Another thing that I found interesting was the fact that I could dictate which constructor I would use based on setting the parameters in BookRunner. For instance, if I wanted to call the initialization constructor, I just had to set two arguments in the parameters: a book name and a book ISBN number. Likewise, if I just left it as an empty set, I would call the default constructor. After doing these things, it helped me realize the purpose of creating those constructors in the first place. In the beginning, I had no idea what a constructor was or what it did, so I struggled a bit in understanding what was going on. The same applies to the methods, such as toString(), because I simply didn't know what it did. I like the whole idea of trial and error in a lab like this, but often it depends on the type of lab we're doing. Certain labs need more examples while others simply need to be tried and done.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment