Logic behind object oriented programming, C/C++ Programming

In this we will take a closer look at the logic behind Object Oriented Programming.  Read through the pseudocode listed below and answer the following questions.

Class Square

  Declare Protected Side as Float

  Declare Protected Area as Float

  Public Square()

     Set Side = 1.0

     Set Area = 1.0

  End Constructor

  Public Subprogram SetSide(NewSide)

     Set Side = NewSide

  End Subprogram

  Public Subprogram ComputeArea()

     Set Area = Side^2

  End Subprogram

  Public Function GetArea() as Float

     Set GetArea = Area

  End Function

  Public Function GetSide() as Float

     Set GetSide = Side

  End Function

End Class

Class Rectangle Extends Square

  Declare Private Height as Float

  Public Rectangle()

     Call Square()

     Set Height = 1.0

  End Constructor

  Public Subprogram SetHeight(NewHeight)

     Set Height = NewHeight

  End Subprogram

  Public Function GetHeight() as Float

     Set GetHeight = Height

  End Function

  Public Subprogram ComputeArea()

     Set Area = Side * Height

  End Subprogram

Question1:Give the names of the methods of the class Square.

Question 2:Write the statement that would be used in the main program to create a new object Square1 based off of the Square Class.

Question 3:Suppose Rectangle1 is an object of the class Rectangle and the statement Call Rectangle1.ComputeArea()

appears in the main program.  Which formula for area is used in the execution of the subprogram ComputeArea()?

Question 4:Write the statement that would be used in the main program to set a side of Square1 to 20.

Question 5:Write the statements that would be used in the main program to compute the area of Square1, assign it to a variable called Area and then print it to the screen.

Posted Date: 3/21/2013 5:42:29 AM | Location : United States







Related Discussions:- Logic behind object oriented programming, Assignment Help, Ask Question on Logic behind object oriented programming, Get Answer, Expert's Help, Logic behind object oriented programming Discussions

Write discussion on Logic behind object oriented programming
Your posts are moderated
Related Questions
Implementation of the Stack class in C++: How to implement stack class in c++. int Stack::push(int elem) {    if (top    {       list[top++] = elem;       r

array of class objects and single inheritance

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

C++ Multiplayer Game Programming Project Project Description: We are seeking an experienced C++ Game Programmer to enhance clientside related aspects of MCS: Mars City Securi

A more advanced data type is the structure; here we can define a template as a collection of different variables e.g.     struct birthdate   {     int month;     int day;

A: #include // Test to see if pointer hopping is worthwhile. // strlen implemented with usual indexing mechanism. int strlen1( const char str[ ] ) { int i; for( i =

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

w.a.p to find outWrite a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.


Luminous Jewels - The Polishing Game Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various lum