1001. Estate

Source: Internet
Author: User


#include <iostream>

#include <iomanip>

#include <cmath>

using namespace Std;

Your code'll is here
Class Land

{

Public

Land (): Price_ (0) {}

Explicit Land (int. price);

Calculate how much Feng Gor can earn from the land

Virtual Double Calmoney () = 0;

Protected

Price of unit area

int price_;

};

Class Square:public Land

{

Public

Square (double len, int price);

Double Calmoney ();

Private

Length of side of a square

Double Len_;

};


Class Circle:public Land

{

Public

Circle (double radius, int price);

Double Calmoney ();

Private

Length of radius of a circle

Double Radius_;

};

Circle::circle (double radius, int price) {
Radius_ = radius;
Price_ = Price;
}
Double Circle::calmoney () {
Return ACOs ( -1) *price_ * radius_ * RADIUS_;
}

Square::square (double len, int price) {
Len_ = Len;
Price_ = Price;
}

Double Square::calmoney () {
return Len_ * Len_ * PRICE_;
}

void Accountant::D evelopestate (land* land) {
Money_ + = Land->calmoney ();
}

Double Accountant::checkmoney () {
return money_;
}







Class Accountant

{

Public

Accountant (): Money_ (0) {}

Develop a land, earn the value of the land

void Developestate (land* land);

Return the value of Money_

Double Checkmoney ();

Private

Double Money_;

};





int main (int argc, const char *argv[])

{

Accountant py;

Circle *a = New Circle (100, 10000);

Square *b = new Square (100, 50000);

Py. Developestate (a);

cout << Setprecision (Ten) << py. Checkmoney () << Endl;

Py. Developestate (b);

cout << Setprecision (Ten) << py. Checkmoney () << Endl;

return 0;

}

1001. Estate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.