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

Coding, Problem Statement: You have to write a C program to develop a Car P...

Problem Statement: You have to write a C program to develop a Car Parking Management System for a busy commercial area. The system will record the car plate number, date and time w

#include, Write a program to find the area under the curve y = f(x) between...

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

Define reference?, A: This is a name that acts as an alias, or alternative ...

A: This is a name that acts as an alias, or alternative name, for a beforehand defined variable or an object. prepending variable along with "&" symbol makes it as reference. fo

Bankers algorithm, creating a system having five process from p0 to p4 and ...

creating a system having five process from p0 to p4 and five resource types. create the need matrix use the safe algorithm to test if the system is in safe mode.

#, YOU HAVE GIVEN THE MARKED UP PRICE OF 80% AND DISCOUNT PRICE OF 10% THEN...

YOU HAVE GIVEN THE MARKED UP PRICE OF 80% AND DISCOUNT PRICE OF 10% THEN FIND THE SELLING PRICE

Write short note on classes in c++, Introduction to Classes Object-orie...

Introduction to Classes Object-oriented programming (OOP) is a conceptual approach to design programs. It can be executed in many languages, whether they directly support OOP c

What is friend functions, Friend Functions One of the major features of...

Friend Functions One of the major features of OOP is information hiding. A class encapsulates data and methods to operate on that data in a single unit. The data from the class

Webcam driver static library or dll required for windows, Webcam Driver sta...

Webcam Driver static library or DLL required for Windows I want a .dll or .lib file using which i will take a snapshot from the webcam and it can't turn on the webcam LED while

Write a program to add co-ordinates of the plane, Write a program to add co...

Write a program to add co-ordinates of the plane The class having x and y co-ordinates. Create three objects. Use a constructor to pass one pair of co-ordinates and a funct

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