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

Assignment Help:

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.


Related Discussions:- Logic behind object oriented programming

What is the issue which auto_ptr objects address?, A: If you employ auto_pt...

A: If you employ auto_ptr objects you would not need to be concerned along with heap objects not being deleted even if the exception is thrown.

Stone game, A game is played with three piles of stones and two players. At...

A game is played with three piles of stones and two players. At her turn, a player removes one or more stones from the piles. However, if she takes stones from more than one pile,

When i develop a destructor, When I develop a destructor, do I require to e...

When I develop a destructor, do I require to explicitly call the destructors for my member objects?

Explain the process of using the constructor, Using the Constructor The...

Using the Constructor There are basically three ways of creating and initializing the object. The first way to call the constructor is explicitly as :

Assignment, I have an assignment , can I send it

I have an assignment , can I send it

Area under a curve, Write a program to find the area under the curve y = f(...

Write 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. The area under a curve between two points can b

C language, in a program for what purpose print f and scan f is used

in a program for what purpose print f and scan f is used

Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

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

Explain briefly about class and objects, Question 1. Explain Briefly ab...

Question 1. Explain Briefly about class and objects. 2. Create a class string which stores a string value. Overload ++ operator which converts the characters of the string t

C programming, a c program to find the volume of sphere

a c program to find the volume of sphere

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd