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

Cross platform clinet app for a vpn, Cross Platform Clinet app for a vpn ...

Cross Platform Clinet app for a vpn Project Description: We want a cross platform client app for VPN. The app must have the subsequent options below: 1. Must be an open

Define inline functions, Inline Functions Imagine a c program, which re...

Inline Functions Imagine a c program, which reads disk records having employee information. If this is a payroll application each employee record data is probably processed by

Bubble sort c program, Bubble sort C program: Write a program to defin...

Bubble sort C program: Write a program to define a bubble sort. void main()  {   clrscr();   int a[100],ch,n;   cout   cin>>n;   for (int i=0;i

Implementation of the definition class - c++ program, Implementation of the...

Implementation of the Definition class: void Definition::put_word(char *s) {    word = new char[strlen(s)+1];    strcpy(word,s);    nmeanings = 0; }   voi

Open and close ?les for writing, If you have computed a number (stored as a...

If you have computed a number (stored as a ?oating-point value) and want to display this on a plot (i.e. as a character string) you have to convert it into a STRING. That is we wan

Explain public derivation, Public derivation Public derivations are muc...

Public derivation Public derivations are much more common than private derivations. In this situation: The private members inherited from the base class are inaccessible

How can I fix this to, Write a program consisting of two functions (plus ma...

Write a program consisting of two functions (plus main). The first function should read in a number and then pass this back to main. This value should then be passed into a secon

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