Giter Site home page Giter Site logo

cosc1430_exercise3's Introduction

COSC1430_Exercise3

Given the Shape2D class (see the provided Shape2D.h), implement a derived class:

Circle

With the following additional members:

·One protected member variable, radius (float)

·The corresponding accessor and mutator to access and modify the above protected member radius (already given)

·The constructor that takes three parameters as input with the order of the x and y coordinates of the center and the radius of the circle. The constructor should call the constructor of Shape2D to properly initialize the center coordinates.

·A public function to compute and the area of a circle and set the area to the variable area inherited from Shape2D

  -void compArea(); 
  -using the following formula area = 3.14 * radius * radius

·override the function printArea() from the Shape2D to output the following The area of the circle is <the computed area>. 
 
  -use << fixed << setprecision(2)

From the above Circle class, derive a new class:

Cylinder

With the following additional members:

·One private member variable, height (float)

·The corresponding accessor and mutator to access and modify the above private member height (already given)

·The constructor that takes four parameters as input with the order of the x and y coordinates of the center, the radius of the base circle, and the height of the cylinder. The constructor should call the constructor of Circle to properly initialize the center coordinates and the radius of the base circle.

·Override the function void compArea() from the Circle class to compute the area of the cylinder 

  -using the following formula area = 2 * 3.14 * height * radius + 2 * 3.14 * radius * radius

·Override the function printArea() to output the following

  -The area of the cylinder is <the computed area>.    

Main

A sample main() function is provided to you. However, there are some errors in the provided main() function. Please fix them so that it can be compiled and generate the expected output.

cosc1430_exercise3's People

Contributors

ohaluminum avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.