In: Computer Science
Please type the answer for i can copy it. Thank you very much.
-Question 1
Respond to the following in a minimum of 175 words:
Read the following pseudocode class definitions:
Class Plant
Public Module message()
Display "I'm a plant."
End Module
End Class
Class Tree Extends Plant
Public Module message()
Display "I'm a tree."
End Module
End Class
-Question 2
Given these class definitions, determine what the following pseudocode will display:
Declare Plant p
Set p = New Tree()
Call p.message()
-Question 3
Discuss how algorithms address object-oriented classes and objects.
// Definition of the class Plant
class Plant
{
// public method message
public:
void message()
{
cout <<
"I'm a plant." << endl;
}
};
// Class tree inherit from plant class
class Tree : Plant
{
// public method message
void message()
{
cout << "I'm a tree.";
}
};
// main function
int main()
{
// created a plant class object
Plant p;
// assign plant p reference of tree object.
// Derived object assigned to base class
p = new Tree();
p.message(); // called message function but plant will
be called.
}
Answer3:
Object oriented programming is writing the code for the real
time
object. For eg you can write the code to demonstrate the
operation
of a fan so the code you are writing is actually the algorithm to
operate the fan.
With help of object oriented programming you can you can write
the
algorithm for the real time object eg: robots or blood
pressure
measuring device.