Rate this paper
  • Currently rating
  • 1
  • 2
  • 3
  • 4
  • 5
3.00 / 2
Paper Topic:

Object Oriented Pseudocode

Pseudo Code Example

Driving a Car Algorithm

Objects used

Driver

Car

The driving system runs by having both objects the car and driver interact by sending messages to each other

Objects Definition

Class Car

Private Engine_Status As Boolean

Private EngineShift As Integer

Private Speed As Real

Private Brake_Status As Boolean

Private Fuel_Level As Integer

Public WarningCode Integer

Public Subprogram StartCarEngine

Engine_Status EngineOn

Output Car Started Running

End Subprogram

Car_System_Error_Code Public Function CarSystemCheck

Return Car_System_Error_Code

End Function

Public Subprogram

StopCarEngine

DecreaseCarSpeed (0

Engine_Status EngineOff

Output Car Engine off

End Subprogram

Public Subprogram IncreaseCarSpeed (NewSpeed

While (CarSpeed NewSpeed (CarSpeed MaxSpeed

Output Car Accelerating

Increase CarSpeed

If CarSpeed NewSpeed

Output Car De-accelerating

ApplyBrakes (ON

Decrease CarSpeed

If CarSpeed ShiftSpeed

ShiftDown

ApplyBrakes (OFF

Output Car speed is newspeed

End Subprogram

Private Subprogram ShiftUp

Decrement Shift

End Subprogram

Private Subprogram ShiftDown

Increment Shift

End Subprogram

Private Subprogram ApplyBrakes (newBrakesStatus

Brakes_Status newBrakesStatus

End Subprogram

Public Subprogram EmergencyStop

While Speed 0

ApplyBrakes (ON

ApplyBrakes (OFF

End Subprogram

Private Subprogram DetectLowFuel

If FuelLevel MaxAllowedDrivingTime

StopCar (car

Output Driver Reached Max Driving Time . Car will Stop Now

Else

Output Driver Ok

End Function

Private Subprogram CheckDrivingTime

While DrivingStatus ON

CheckDrivingTime

End Subporgarm

Public Subprogram IncreaseCarSpeed (NewSpeed

Call car .increaseCarSpeed (newspeed

End Subprogram

Public Subprogram DecreaseCarSpeed (NewSpeed

While (CarSpeed NewSpeed

ApplyBrakes (ON

Decrease CarSpeed

If CarSpeed ShiftSpeed

ShiftDown

ApplyBrakes (OFF

End Subprogram

Public Subprogram EmergencyStop

DrivingStatus OFF

End Subprogram

End Driver Class

Pseudo Code

Main

Declare Driver1 as Driver

Declare Car1 as Car

User Selects that driver startcar

Call Driver1 .StartCar (Car1

Driver1 Outputs Driver ok

Car1 Outputs Car Started Running

User increase speed of car

Call Driver1 .increaseSpeed (NewCarSpeed

Car1 outputs Car Accelerating

Car1 outputs New speed is NewCarSpeed

Call Driver1 .decreaseSpeed (NewCarSpeed

Car1 outputs Car deaccelerating

Car1 outputs New speed is NewCarSpeed

Car1 outputs Low Fuel

User Stops Car

Call Driver1 .stopCar

Car1 outputs Car Deaccelarting

Car1 outputs Car Speed is 0

Driver1 outputs Driver Stopped

End Main

Architecture difference between object oriented and structured design

Object design split the system into smaller part called objects . Objects deal with each other through messaging . Each object handles itself through the use of variables and methods internal to the object . The object also declares other variables and methods that can be accessed and called by other outside objects

In case a problem occur within the system , it is easy to identify the responsible object and isolate the problem . Update of system methods and modifications are much easier to implement by replacing the object containing the required change instead of modifying the whole program in case of structured design

Structured design does not split the problem and its solution into smaller parts . The program sequentially goes through the logic of the solution from start to end . Modification and update requires echoing the change in the whole program instead of replacing smaller objects in case of object-oriented design

The object-oriented design makes more sense as it encapsulate the program into real time objects that interact with each other imitating real life objects...

Not the Essay You're looking for? Get a custom essay (only for $12.99)