Thursday, January 29, 2015
Our Lord and Savior, JDR
This code ensures that everybody knows that John D. Randolph is our true hero, as He guides us to the light. He acts as the perfect role model, thus having the life which is the ultimate goal of every follower of the Randolph faith.
Wednesday, January 21, 2015
Java Chapter Three
I learned what this piece of code does, thanks to chapter three. The first half establishes a reference variable named dog1 that is of the Dog type. The second half creates a new dog object and adds it to the "heap". To link the object to the reference, thus assigning the new Dog to the reference variable dog1, the equal sign is used.
dog1.bark();
After the previous line of code, this line ensues, as it give dog1 an action to perform. the first half of the code is the reference variable, while the second half is the action. Basically, the dot operator is used to explain that you use the thing before the dot to do the thing stated after the dot. Thus, this line of code means to use dog1 to invoke the bark method.
With Primitive Variables, the value of the variable is the value, such as 5, -27.9, or 'a'.
With Reference Variables, the value of the variable is the bits representing a way to get to a specific object.
This is a dog.
Friday, January 16, 2015
Java Chapter Two
On thing I learned was that instance variables are things an object knows about itself; they represent an object's state, and can have unique values for each object of that type.
Another thing I learned was that methods are things an object can do.
This code creates 3 objects which each have the title, genre, and rating of 3 separate movies. In this code, the dot operator is used to set instance variables to a specific value. As is seen below, this is what the output of the code would be.
Monday, January 12, 2015
Java Chapter One
This is the code to the Beer Song program, which has the job of reciting the entire "Beer Song" from 99 bottles to zero bottles. We were given the code, however there was one error which caused the song to say "1 bottles of beer on the wall" instead of the grammatically correct "1 bottle...". Thus, my task was to fix the code in order to make it grammatically sound. In order to achieve such a goal, I placed the "if (beerNum == 1)" chunk of code under the prints because now the code will notice that the number of beers left is 1, making it say bottle instead of bottles.
This is the PhraseOMatic program, which is meant to choose one random word from each of the three lists in order to say a phrase such as, "All we need is a John D Randolph". This is my favorite possible phrase because John D Randolph is my hero. In order to create the phrases, the program determines the number of words in each list and then chooses a random integer which represents the place value of the word in the list. Thus, it would choose the third, first, and fifth words in the first, second, and third list respectively.
Subscribe to:
Comments (Atom)
