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 are the different types of endless loops, What are the different types...

What are the different types of endless loops? An endless loop can be of two types: i.) A loop that is intentionally designed to go round and round until the condition withi

Program to convert compass heading in degrees , Convert compass heading in ...

Convert compass heading in degrees (0-360 degrees)to compass bearing. A compass bearing consist of three items namely: a.The direction you face (North or South) b.An angle betwe

Boardcoloring, color representation 0,1,2,3,4,5,6,7,.......

color representation 0,1,2,3,4,5,6,7,.......

If else, A small shop sells 280 different items. Every item is identified b...

A small shop sells 280 different items. Every item is identified by a 3 - digit code. All items which start with a zero (0) are cards, all items which start with a one (1) are swee

Explain the goto statement, The goto statement This statement can be us...

The goto statement This statement can be used to branch to another statement of the program. This is rarely used as it violates the principle of structured programming. Though

Setup and source code with nice user interface, Virtual Webcam effects - Se...

Virtual Webcam effects - Setup and Source code with Nice User Interface Project Description: I want a similar webcam effects application which can apply effects to webcam fee

Write a program to illustrate the call by reference, Write a Program to ill...

Write a Program to illustrate the Call by Reference? Here is an illustration: #include . int compute_sum(int *n); int main( void) { int n=3, sum; printf("%d\n",n); /

Bitcoin alternative – deployment and modification, I started preparing an a...

I started preparing an alternative cryptocurrency and I am way over my head. I would like help in making modifications to the open source files and then help with deployment. I wil

Please help to solve a c program, Padovan String Problem Description A P...

Padovan String Problem Description A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes s

Default value functions, Default Value Functions,  When declaring a functio...

Default Value Functions,  When declaring a function we can specify a default value for each parameter. This value will be used if that parameter is left blank when calling to the f

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