Prev | Current Page 202 | Next

Carl Reynolds and Paul Tymann

"Schaum's Outline of Principles of Computer Science"


CHAP. 5] PROGRAMMING IN JAVA 77
Using the procedural approach, we would break the job down into subtasks, or subroutines, write the
routines, and combine the routines with a main program into a sequence of activities to be performed. We might
have a carEntersThruway procedure, and a carExitsThruway procedure, and we might keep information
in a file about the cars using the Thruway.
Using the OO approach, we would think about the ???things??? in our problem domain, and create analogous
software classes. For instance, we would probably have a Vehicle class, and we might have a
ThruwayInterchange class, and a VehicleOwner class. We would give Vehicles characteristics that
are important to our application, such as licenseNumber, state, make, model, and color. Since we
need to track where vehicles enter and leave the Thruway, we might add Vehicle properties
enteredAtInterchange and exitedAtInterchange. Likewise, the properties of a VehicleOwner
might include firstName, lastName, streetAddress, city, state, and zipCode.
The logic of an OO program gets coded as ???methods??? of the objects. Instead of having an isolated
or application-wide carEntersThruway procedure, as we might using the procedural approach, we can
have similar code in a method of the Vehicle class.


Pages:
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
Tango Olsztyn życzenia urodzinowe ekonto opinie fenster berlin typy bukmacherskie