- •Void print();
- •Include.H
- •Void Point::set_Point_x( double _x)
- •Void Point::set_Point_y( double _y)
- •Void print ();
- •Void Cube::Draw()
- •Void Cube::square(double r)
- •Int main()
- •Include "targetver.H"
- •If(!p1.InBounds() || !p2.InBounds())
- •If(!temp.UperLeftCorner.InBounds() || !temp.LowerRightConer.InBounds())
- •If(!temp.UperLeftCorner.InBounds() || !temp.LowerRightConer.InBounds())
- •If(!temp.LowerRightConer.InBounds())
- •If(!p2.InBounds())
- •If(!temp.LowerRightConer.InBounds())
Include.H
#include <iostream>
#include <stdio.h>
#include <tchar.h>
#include <fstream>
#include <iomanip>
#include <conio.h>
#include <ctime>
#include <istream>
#include <cmath>
#include "point.h"
#include "quadro.h"
#define M_PI 3.14
using namespace std;
mail.cpp
#include "quadro.h"
#include "point.h"
#include "include.h"
int main()
{
double i;
bool temp;
quadro X;
quadro Y(1,1,3,3,2);
quadro Z(Y);
Y.move_quadro();
cout << "Zoom quadro (0-minimize,1-bigest;na skolko):";
cin >> temp >> i;
X.size_quadro(temp,i);
_getch();
return 0;
}
Point.cpp
#include "include.h"
#include "point.h"
Point::Point()
{
srand(time(NULL));
Ox=rand() % 40-20 + 1;
Oy=rand() % 40-20 + 1;
}
Point::Point(const double _x, const double _y)
{
Ox=_x;
Oy=_y;
}
Point::Point(const Point& P)
{
Ox=P.Ox;
Oy=P.Oy;
}
Point::~Point()
{
cout << "destructor Point is working " << endl;
}
void Point::rePoint()
{
Ox=rand() % 40-20 + 1;
Oy=rand() % 40-20 + 1;
}
double Point::konst() const
{
double n;
n=Ox;
return n;
}
void Point::size_minus_point(double i)
{
Ox-=i/2;
Oy-=i/2;
}
void Point::size_plus_point(double i)
{
Ox+=i/2;
Oy+=i/2;
}
void Point::move_Point(double n)
{
Ox=Ox-n;
}
void Point::show_Point() const
{
cout << "(" << Ox <<"," << Oy <<")"<< endl;
return ;
}
double Point::get_Point_x() const
{
return Ox;
}
double Point::get_Point_y() const
{
return Oy;
}
void Point::set_Point_x(double const x)
{
Ox=x;
}
void Point::set_Point_y(double const y)
{
Oy=y;
}
Point.h
#ifndef POINT_H
#define POINT_H 1
class Point
{
private:
double Ox;
double Oy;
public:
Point();
Point(const double _x, const double _y);
Point(const Point& P);
~Point();
friend class quadro;
double konst() const;
void rePoint();
void move_Point(double);
void size_minus_point(double);
void size_plus_point(double i);
void show_Point() const;
double get_Point_x() const;
double get_Point_y() const;
void set_Point_x(double const x) ;
void set_Point_y(double const y) ;
};
#endif
Quadro.h
#include "point.h"
#ifndef quadro_H
#define quadro_H 1
class quadro
{
private:
char *name; //наименование объекта: object 1, object 2
char *objID;
Point t1,t2;
double a;
public:
static int count;
quadro();
quadro(const double r_b_x, const double r_b_y,const double l_b_x, const double l_b_y,const double _a);
quadro(const quadro&_P);
~quadro();
double set_S();
double set_P();
void move_quadro();
bool prov();
void size_quadro(bool,double);
void starline() const;
void name_object(const char *ident);
};
#endif
вариант 3
7.1.1
Класс «Эллипс». Создать 3 объекта этого класса с центром в точке (0, 0) и полуосями a, b, расположенными по координатным линиям Ox Oy. Выполнить растяжение исходного объекта-эллипса по одной из его осей. Вычислить площадь исходного и нового эллипсов. Sэллипса = π*a*b.
Ellips.cpp
#include "stdafx.h"
Ellips::Ellips()
{
created ++;
cout << created <<" Constructor Ellips without arguments is working"<< endl;
}
Ellips::Ellips(Point _a, Point _b)
{
created++;
double temp=_a.get_Point_x();
a.set_Point_x(temp);
temp=_a.get_Point_y();
a.set_Point_y(temp);
temp=_b.get_Point_x();
b.set_Point_x(temp);
temp=_b.get_Point_y();
b.set_Point_y(temp);
cout << created << " Constructor Ellips with arguments is working "<< endl;
}
Ellips::Ellips(const Ellips& E)
{
created++;
a=E.a;
b=E.b;
cout << created << "Constructor Ellips copy is working"<< endl;
}
Ellips::~Ellips()
{
cout << created << " Destructor Ellips is working"<< endl;
created--;
}
double Ellips::square()
{
S=3.14*((a.get_Point_x())*(b.get_Point_y()));
return S;
}
void Ellips::print()
{
cout << " Ellips " << created <<
" is drawing\n ";
cout << "x=" << a.get_Point_x() << " y=" << b.get_Point_y()<< endl;
cout << "S=" << S << endl;
return;
}
void Ellips::extend_a(Point _a)
{ double temp=_a.get_Point_x();
a.set_Point_x(temp);
return;
}
void Ellips::extend_b(Point _b)
{
double temp=_b.get_Point_y();
b.set_Point_y(temp);
return;
}
Func.cpp
#include "stdafx.h"
void initialize( double& xa,double& ya,double& xb,double& yb)
{
do
{
cout << "Vvedite poluosi Ellipsa "<<endl;
cout << " xa=";
cin >> xa;
cout << "ya=";
cin >> ya;
cout << " xb=";
cin >> xb;
cout << " yb=";
cin >> yb;
if((ya==0)&&(xb==0)) break;
else cout << "Neverno vvedeno! Zanovo ";
}
while (true);
}
void func(Ellips* ell, Point& ext)
{
ell->square();
ell->print();
ell->extend_a(ext);
ell->square();
ell->print();
return;
}
Main.cpp
#include "stdafx.h"
int Ellips::created=0;
int _tmain(int argc, _TCHAR* argv[])
{
{double xa,ya,xb,yb;
initialize(xa,ya,xb,yb);
Point a(xa,ya);
Point b(xb,yb);
Point c(4,4);
Point d(c);
Ellips E1;
func(& E1,c);
Ellips E2(a,b);
func(& E2,d);
}
_getch();
return 0;
}
Point.cpp
#include "stdafx.h"
Point::Point()
{
srand(static_cast<unsigned>(time(NULL)));
x=10.0*rand()/RAND_MAX;
y=10.0*rand()/RAND_MAX;
cout << "constructor without parametres Point is working " << endl;
}
Point::Point(const double _x, const double _y)
{
x=_x;
y=_y;
cout << "constructor Point with parametres is working "<< endl;
return;
}
Point::Point(const Point& P)
{
x=P.x;
y=P.y;
cout << "constructor Point of copying is working " << endl;
}
Point::~Point()
{
cout << "Destructor Point is working " << endl;
}
