Week Eight CheckPoint: Object-Oriented Data and Processes
- Identify a task you perform regularly, such as cooking, mowing the lawn, or driving a car.
What task are you going to describe? Let’s make a cup of tea.
- Write a short, structured design (pseudocode only) that accomplishes this task.
You need to follow proper design principals
Call Boil_Water Module
Declare Sugar as an Integer
Sugar = Call How_Many_Sugar Module
Call Prepare_Cup module
End Main Module
Declare Temperature as Integer
If Temperature < 212 degrees Fahrenheit
Turn Heat on
Display “Water is not ready”
Else If Temperature = 212 degrees Fahrenheit
Turn Heat off
Display “Water is ready.”
End Boil_Water Module
Integer How_Many_Sugar Module
Declare Integer Sugar
Display “Enter How Many Teaspoon(s) of Sugar”
End How_Many_Sugar Module
Declare Tea_Flavor as String
Display “What flavor of tea do you want?”
Display “Adding Boiling Water”
Display “Added” Tea_flavor “to cup.”
Display “Added” Sugar “teaspoons of sugar to cup”
Display “Stirring Tea”
Display “Tea is ready to drink”
End Prepare_Cup Module
- Thinkabout this task in an object-oriented way, and identify the objects involved in the task.
- Tea flavor
- Identify how you can encapsulate the data and processes you identified into an object-oriented design.
The teapot is the object and when the water is added and heat is turned on the process of making a cup of tea begins. The water communicates back and forth telling the program the temperature of the water and when it is ready to proceed. Next the user will send messages to the program so it knows the amount of sugar and the flavor of tea.
- Describe the architectural differences between the object-oriented and structured designs. Which of the designs makes more sense to you? Why?
Object oriented programming can store data and send messages to other objects. They can also receive messages from other objects. Object oriented program is much more intuitive for real life situations rather than architectural programing.
Object oriented design makes more sense to me, because it resembles real life and it makes the code reusable which could save time.