Today we worked on the tracker program and the collision test program. We modified both of them without any prior knowledge of Java. In the morning session, I learned how to import a .jar file into Eclipse (keeping in mind to click on the correct folder), move objects diagonally by combining code from other parts of the program, and that the tilde key is on the wrong side of the keyboard and should be hit with the right hand. During the afternoon session, I learned that the reason to make things private is to protect users from themselves, how to use the replace() and length() methods to manipulate strings, and how to use an "*" to import all of the classes in a package so that I don't have to import them one-by-one. Also, I read through page 50 of our textbook.July 12. 2005
Here are five questions and their answers for today:
Q: Does the println() method take ints as well as strings?
A: Yes, as long as the int is concatenated with a string.
Q: Do all variables have to have "public" or "private" before them?
A: No, but if it is not specified, then it will become the default access specifier.
Q: Is the Rectangle class bulit into Java or do I have to construct it?
A: It is part of the AWT package.
Q: If "=" assigns, then how do you compare?
A: To compare, use "==".
Q: If a Rectangle is contrcuted, what are the first two arguments used for?
A: They define the coordinates of the top left corner of the rectangle.
Today, I completed the circle, quadratic equation, soda can, and paycheck programs. I worked on the line program but I did not finish the "equals()" method yet (Update: I finished this in the evening session after revising my code and simplifying my variables). In the morning, I learned how a constructor affects the behavior of a class (it inializes variables), the structure of classes (constructors, methods, and instance variables), and when to use ints and when to use doubles (use doubles for rational numbers that are not whole numbers and irrational numbers). During the afternoon session, I learned that multiple constructors are used so that objects can be created used different types of input. I also learned to use NaN to code lines with undefined slopes and to use as few instance variables as possible in order to make my code more universal. Another thing I learned today was to use "this" to synchronize parameters and instance variables. In the textbook, I have skimmed up to page 230 although I skipped chapter five.July 13, 2005
Here are five questions and their answers for today:
Q: Does every class require a constructor?
A: No, but if a class does not have one, then it causes you to have to specify more information manually.
Q: What is the use of "static"?
A: "Static" is used to denote a feature that is defined for a class, not for individual instances.
Q: Why would you want to include multiple constructors in a class?
A: This allows class objects to be defined in more than one way.
Q: For coordinates, where is the origin?
A: The origin is at the top left corner of the canvas or object.
Q: What do the first two parameters of the Rectangle class do?
A: They define the location of the top left corner.
In the morning session, Chris and I worked on a bike project in which we had to construct classes of type Gear, Wheel, Chain, Axle, and Driver. I learned that the importance of connecting classes is to increase the versatility of your program. I also learned that it is bad practice to guess on "for" loops (one-off errors) and I learned that "do...while loops" can be used to automate user input. In the afternoon session, I helped my peers with their programs and started to work on assignment 4. I learned that the Scanner class can be used to take user input, if you don't initalize a variable and then divide by it, the result is infinity, and if you put a semicolon after a "for" statement, the code will not work. I also read up to chapter 8 in the textbook.July 14, 2005
Here are five questions and their answers for today:
Q: Is there a "goto" command in Java?
A: No.
Q: What are "%d" and "%8.5f" in System.out.println?
A:
Q: When do you use "final?"
A: You use it when declaring a constant.
Q: What does "extends" do?
A: It is used to define the superclass of a particular class.
Q: How do you change an integer to a string?
A: You can use String.valueOf(int a).
In the morning session, we read and learned about loops and binary. I finished through page 336 in the textbook. I learned that sign-magnitude uses the leftmost digit to denote the sign, "double" variables are not entirely accurate because of repeating binary numbers, and coupling should be kept to a minimum between classes in order to keep code efficient. In the afternoon session, I worked on detecting collisions between particles and segments and on adding complex number capabilities within my QuadraticEquation class. I learned about the importance of having multiple constructors within a class, that trackers control the movement of particles and segments, and that some computer worms work by overflowing arrays.July 15,2005
Here are five questions and their answers for today:
Q: If you have a "main" method in a class, then why include other methods in that file?
A: You can call those methods from the main method.
Q: What is the "interface" keyword?
A: It is used to get data from multiple classes without having to re-write code.
Q: Are there destructors in Java like in C++?
A:
Q: What is the "protected" access specifier used for?
A: Objects and methods with the "protected" access specifier can be accessed by subclasses of the object's or method's class.
Q: Is that a specific command to create an infinte loop without a dummy variable?
A: Yes, use "while(true)".
Today, we worked on various projects. I finished my ComplexNumber program and made it so that the user can input complex coefficients. I also began a project to model Conway's Game of Life (cellular automata) and explored the Pong project. In the morning, I learned that the "toString()" method is used to summarize the variables of a class, how to use a two dimensional array to store data, and that the "assert" command can be used to define preconditions. In the afternoon, I learned that some methods and instance variables have to be static in order to work. I also learned that if an object is going too fast, then collisions with other objects might not be detected and that sprites can be either images or created graphics.July 18, 2005
Here are five questions and their answers for today:
Q: What do @param or @return mean?
A: They are Javadoc commands used to describe the parameters of a method and what it returns.
Q: What is ! for?
A: It is the "not" operator.
Q: What does "final" mean on page 234?
A: It means that the variable cannot be changed.
Q: How do you implement simple graphics in Java?
A: You can use Graphics2D.
Q: Why do we need to know binary if we can use decimal or hexadecimal?
A: The reason is that computers operate using binary, not decimal or hexadecimal.
Today, in the morning session, Jam took questions and then we worked on our projects. In the morning, I learned that Javadoc'ing is important so that others can modify your code, the "interface" keyword is used to get data from multiple classes without having to re-write code, and an abstract method is one that has no implementation. In the afternoon, we continued working on our projects and I finised my Game of Life project.. In the afternoon, I learned that too many objects can slow your code, casting from a "double" to an "int" can cause a loss of data, and with an "interface" there are no instance variables and all methods are public. I also read up to page 419 in the textbook.July 19, 2005
Here are five questions and their answers from today:
Q: What is the advantage of defining classes within classes?
A: The sub-class can service the topical class.
Q: How do you make a graphical scene?
A: Create a container filled with various graphical objects.
Q: How do you access a value in an array?
A: You access a value in an array using the index.
Q: How do you make a class inherit another class?
A: You use the "extends" keyword.
Q: What is the difference between a "float" and a "double?"
A:
Today in the morning session, we read in our textbooks and learned about how the gaming package works. I learned that polymorphism means that the type of an object determines which mehod will be called. I also learned that the Timer object can be used to execute commands on specific intervals and that various mouse events can be triggered by moving, clicking, and releasing the mouse. In the afternoon, we worked on our projects. I learned that the gaming package uses trackers to move objects, the keyboard can return only one key at a time to the motherboard, and A.I. can be created for Pong by having the opponent track the y-coordinate(s) of the ball(s).July 20, 2005
Here are five questions and their answers from today:
Q: When do you get a bounds error in an array?
A: You get this error when you try to access an element that doesn't exist.
Q: How do access a value in an array?
A: You access a value in an array using the index.
Q: How do you convert a Java application into an applet?
A:
Q: What is more efficient - an array or an ArrayList?
A: Arrays are easier to use, but ArrayLists have more features.
Q: Why do the Wrapper clases need capitalization?
A: They must be capitalized in order to differentiate them from their respective primitives.
In the morning, Jam created a Space Invaders clone for us to show us how the gaming package works. I learned that subclasses are part of superclasses, no implicit parameters are required for subclasses calling superclass methods, and "super" is used to call a superclass method from a subclass when there is a method in the subclass with the same signature. In the afternoon, I began to work on my video game. You can check on my progress by clicking here. I learned that if two methods have the same signature, then they have the same name and parameter types. I also leanred that "instanceof" can be used to make a safe cast and that objects and methods with the "protected" access specifier can be accessed by subclasses of the object's or method's class.July 21, 2005
Here are five questions and their answers from today:
Q: How is having Class A extend Class B different than nesting A inside of B?
A:
Q: When do you get a compilation error in an array?
A: You get this error when you make a syntax error.
Q: Are Strings actually Strings or really just character arrays in Java?
A: They are character arrays.
Q: What is the point of a "for each" loop?
A: It can be more convenient than a regular "for" loop.
Q: How do you get the RGB for a color which you don't already know the RGB values?
A: You can use applications in which you define the color and it gives you the RGB value.
In the morning, Jam continued working on his Space Invaders clone. I learned not to check constants that only apply for a finite amount of time, that it's important to remember to add your sprites to the canvas, and that you should keep your code well-structured in a long program. In the afternoon, I continued to work on my video game but I ran into a number of nasty bugs. In the afternoon, I learned that the keyboard can only return one key at a time, the gaming package doesn't support the KEY_RELEASE event, and that every class in Java is a subject of Object.July 22, 2005
Here are five questions and their answers from today:
Q: How many dimensions can an array have?
A: An array can have as many as memory can hold.
Q: Are correctness proofs commonly used today?
A: No, they are inefficient.
Q: How can you quickly fix errors in your program?
A: Use the "quick fix" command.
Q: Is the for each loop just a more specific version of the for loop?
A: Yes, and it is more convenient.
Q: What is the image editing program for Unix?
A: It is Image Magick.
July 25, 2005Today, in the morning session, we learned about collections and collisions. I learned that the "throw" keyword is used to the let the user know that an error has occurred, a checked exception is one that pertains to problems that are likely to occur at times within a program, and unchecked exceptions are preventable by the programmer. In the afternoon, I continued working on my video game. I ran into several nasty bugs that had to do with my three-dimensional array. I learned that arrays are most efficient when full, the CRC card method is used to model classes, and the "try...catch" keywords are used to deal with code that might throw an exception. I also read up to page 634 in the textbook.
Q: What does UML stand for?
Here are five questions and their answers for today:
A: It stands for "Unified Model Language"Q: What does CRC stand for?
A: It stands for "Classes, Responsibilites, Collaborators."Q: How do you capture mouse events?
A: You implement a mouse listener.Q: Are variables ever followed by parentheses?
A: No, only methods are.Q: Do most complex programs employ collections?
A: Yes, as they are necessary for the programs to become complex.
Today, in the morning session, we continued to work on our games. I dealt with all of the array bugs from yesterday and implemented several new features. I learned that when copy-and-pasting, it's important to make sure that you change everal field that needs to be changed. I also learned that you should access tracker methods from outside of the tracker and that you can make an instance variable called "wave" to store the level that the player is on. In the afternoon, I continued debugging and implementing new features. I learned that you can use trigonometry to have enemies aim at the player, the "advanceFrame()" method runs approximately 25 times a second, and enemies should not fire too often or else it will be too difficult for the player to win.July 26, 2005
Here are five questions and their answers for today:
Q: How do you record sound in Windows?
A: You use the Sound Recorder application.
Q: How can you make sounds sound more futuristic?
A: You can use the synthesizer on it.
Q: What is a null pointer exception?
A: It is thrown when you try to access a field or an element that does not exist.
Q: What does the clone method do?
A: It creates an object identical to the implicit parameter.
Q: How do you test whether two objects have equal state?
A: You can use the "equals()" method.
During the morning session, we continued working on our video games. I spent an hour Javadoc'ing my code and I learned that it's important to Javadoc your code in order to receive help. I also learned that you should put methods that need to be run more than once outside of the "startGame()" method and that you can create a separate array to store the health of each enemy. In the afternoon, I continued debugging and implementing new features. I learned that you can award bonus points to the player based on the timer. I also learned that you should check that this total is not negative or else it is no longer a bonus. Finally, I learned that Jam's gaming package is not perfect with regards to multiplayer support.July 27, 2005
Q: Why do you capitalize "final" fields?
A: You do to denote that they are constants.
Q: When is the "startGame()" method called?
A: It is called at the beginning of the game.
Q: What does RGB stand for?
A: It stands for Red, Green, Blue.
Q: How can you rapidly change all of one phrase in your program?
A: You can use the "find-replace" command.
Q: What does API stand for?
A: It stands for Application Program Interface.
Today, during the morning session, we continued working on our video games. I learned that it's important not to have the enemies move down the screen too quickly. I also learned that it's important not to put a statement in a "for" loop that you don't want repeated and that the keyboard will not work in the "startGame()" method. In the afternoon, I continued implementing new features and debugging. I learned that Javadoc'ing is useful if you want others to understand your code and that you have to put "new" before "Point2D.Double" to make a new point. I also learned that you shouldn't multiply a variable by a constant too many times or you might end up with a very large number. I implemented the "addUpgrades()" method which adds the upgrade sprites to the canvas, the "checkWin()" method which checks whether the wave has been cleared. the "makeUpgrades()" method which constructs the upgrade sprite, the "makeUpgradeTrackers()" method which creates the trackers for the upgrades, and the "makeUpgradeGrid()" which defines which enemies conceal upgrades. I also added constants and instance variables such as "ENEMY_MOVE_DOWN_TIME", "ENEMY_VERTICAL_VELOCITY," and "private int[][] upgradeGrid." My game currently contains ten waves and is semi-fun right now. Tomorrow, I would like to fix the scoring bug and add collision handlers for the upgrades. I collaborated with Jam on my work today.July 28, 2005
This will be my final journal entry. We finished up our video games today. In the morning session, I learned that you can check the ID of each computer to determine whether or not to update certain objects, you can use epsilon to move objects by small amounts until a certain condition is met, and you need to create an array for any variable that applies to more than one player. In the afternoon, I learned that you should check if an object is null before referencing it to avoid "nullPointerExceptions." I also learned that arrays are inefficient if you plan on them holding a variable amount of items and that an "alive[]" array can be used to prevent players from acting after they have died. I implemented the "setTargetPlayer()" method which sets the player that a homing bullet follows, the "setSpread()" method which sets whether or not the player's bullets have the spread shot upgrade, and the "getSpread()" method which returns whether or not the player's bullets have the spread shot upgrade. I also implemented the "BULLET_SPEED_UPGRADE_MAGNITUDE" constant which determines how much speed the player's bullets gain after getting the bullet speed upgrade. My game currently includes five upgrades, all of which I implemented today. I collaborated with David, Jonathan, and Doug today.