CMPSC 56 Chapter Notes - Chapter 5-6: Instance Variable, Texas State Highway Loop 1, Dynamic Array
Document Summary
Remember: focus on the things in the program rather than the procedures. Figure out what the class is supposed to do. Prep code = a form of code to help you focus on the logic. Includes instance variable declarations, method declarations, and method logic. Test code = a class/methods that will test the real code and check if it"s doing the right thing. Real code = the actual implementation of the class. Write test code first to make it easier/faster to write the actual code. Should write a little test code, then write only the implementation code needed to pass the test, and so on. To convert a string to an int: integer. parseint(3) Enhanced for loop: for (int i : arr) {} int is just the data type that the array holds break statement immediately gets you out of a loop. To get a random integer from 0 < randomnum < n: int randomnum = (int)(math. random()