Details of this Paper

C++

Description

solution


Question

Question 1. Implement a simple graphics system consisting of classes to represent different geometric shapes such as rectangles, squares, and circles. Specifically, a rectangle has the following data members: height, width, and center point. A square has center point and edge width. Finally, a circle has center and radius. These three classes (e.g., rectangle) are all derived from a common ancestor class Figure.;In this work you only need to implement "the Rectangle" and "Triangle" classes as derived classes of the base class Figure.;Each of these three classes (i.e., Figure, Rectangle, and Triangle) has two member functions, namely, erase() and draw(), which if properly implemented erase or draw a figure, respectively. You don't need to implement the actual drawing or erasing. It will suffice to just print out a message to indicate which version of the erase() or draw() function being called at run time. For example, you can print a message like "Calling Figure::erase()".;The base class Figure has three member functions;(1) draw(), which doesn't do anything other than print a message to identify itself when it is being called;(2) erase(), which again doesn't do anything other than print a message to identify itself when being called, and;(3) center(), which simply calls the erase() and draw() functions and prints a message indicating that it is being called.;There are 3 parts in this question.;PART I Implement the above three classes using separate compilation without including any virtual functions. Compile and then test your classes using the following test drive;#include;#include "figure.h;#include "rectangle.h;#include "triangle.h;using std::cout;int main();Triangle tri;tri.draw();cout << "\nDerived class Triangle object calling" << " center().\n;tri.center();Rectangle rect;rect.draw();cout << "\nDerived class Rectangle object calling" < 1). Find E (M) by simulation.;B. Let N = min (n+1: Xn > Xn+1). Find E (N) by simulation.;2. Toss a pair of fair dice. If you get any double stop and lose. Otherwise keep tossing. If any sum gets repeated before getting any doubles stop and win.;A. Find the probability of winning;B. Find the expected number of tosses per game.

 

Paper#70925 | Written in 18-Jul-2015

Price : $27
SiteLock