CS 160

September 26, 2007

Today we will go over the rest of chapter 4, most of this is covered in the first program. Then we will review creating objects, calling methods with input variables, and the methods might have return values. Creating instances of classes in other places than the main. Minimizing the main method so it doesn't have much code.
Linked here is the program I wrote to show lots of examples of primitive types and other little syntax type rules. Examples.java

Second Example

The Driver class that holds the main and creates instances of the Train Class. Notice the code in the Main is very small, most the work is done in the classes, this is what you should get used to doing also. Driver.java
The TrainDepot class is a holder of all the individual trains. TrainDepot.java
The class that is instantiated in the main, it has instance variables, constructor and set/get methods. Make sure you understand the return variables and input variables to all the methods. Train.java