Week 9: Currency Conversion

profilekhiylie301
checkpoint_wk_8_object-oriented_data_and_processes.docx

CheckPoint Week 8: Object-Oriented Data and Processes

1) Selected task is driving a car.

2) Pseudocode: Main Module Call Initiate Car Start Up Function Call Start Drive Function Call Turn Off Car Function End Main Module Initiate Car Start Up Function Display "Car Started successfully" End Initiate Car Start Up Function Initiate Start Drive Function Declare Dir as String Display "Input Command" Input Dir If Dir = "Slow Speed Down" Display "Slowing Speed Down" Else If Dir = "Stop vehicle" Display "Stopping the Car" Else If Dir = "Turn vehicle Left" Display "Turning Car Left" Else If Dir = "Turn vehicle Right" Display "Turning Car Right" Else If Dir = "Speed vehicle Up" Display "Accelerating the Car" Else If Dir = "Shifting Gears" Display "Shifting the Gears" End If End Start Drive Function Initiate Turn Off Car Function Declare Dir as String Display "Input ‘T’ to turn off the Car" Input Dir If Dir = "T" Display "Turning Car off" End Turn Off Car Function

3) Identify the objects involved in the task. Objects include: The accelerator The wheel

The foot for brake/accelerator

The hands for steering the wheel The four tires The gears The ignition The car's engine

The brakes

The speedometer

4) Encapsulating the data and processes you identified into an object-oriented design. The foot sends an outgoing message to the accelerator by press it. The Accelerator then, keeping in view the, parameter of the message it receives from the foot i.e. how hard have you accelerated, pings the engine to start the car or make it move. The hands send a message to the wheel regarding the direction. Based on that message, the steering wheel can send a message to the tires telling them to turn into the specified direction.

5) Architectural differences between the object-oriented and structured designs. Which of the designs makes more sense to you? Why? In object oriented programming, "objects" can store data, send messages to other objects, and receive messages from other objects. This is much more intuitive for real life systems than other programming paradigms. On the other hand, Structured programming is based on data structures, subroutines and splits the programs into modular forms. Object oriented design definitely looks better to me, since the programs following the objected oriented approach can be written in a understandable style. Additionally, repeated commands can be well organized in objected oriented structures, which saves time coding and checking your work and can as well be reused in the code or other programs.