Object-Oriented Data and Processes
Essay by Stella • April 23, 2012 • Essay • 683 Words (3 Pages) • 2,364 Views
Object-Oriented Data and Processes
Identify a task performed regularly.
Driving a car!
Write a short, structured design (pseudocode only) that accomplishes this task.
Declare Car Door as Real
Declare Car as Real
Declare Brake Pedal as Real
Declare Drive as Real
Open Car Door
Sit in Car
Close CarDoor
Press BrakePedal
Start Car
Put car in Drive
Release BrakePedal
Accelerate Car
End Program
Think about this task in an object-oriented way, and identify the objects involved in the task.
Involved in this program are the car and the person driving the car. The properties include a car, a door, the handle of the door, and brake pedal. All objects included in this are the car's four tires, the metal surrounding the car, the rubber on the tires, the engine.
Identify how you can encapsulate the data and processes you identified into an object-oriented design.
Class Car Operation
Declare Car as Real
Declare Car Entry as Real
Declare Car Driver as Real
Subprogram Enter Car
Set Enter Car = Open Car Door
Get into Car
Close Car Door
End Subprogram
Subprogram Drive Car
Set Drive Car = Start Car
Put Car in Drive
Release Brake Pedal
Accelerate Car
End Subprogram
Function Enter Car () as Real
Set Enter Car = Car Entry
...
...