
- •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())
Int main()
{
Windows W1("Empty Window");
cout << W1;
W1.Perimetr();
_getch();
Windows W2("Window 2", Point(5,5), Point(20,10));
cout << W2;
W2.Perimetr();
_getch();
Windows W3 = 2 * W2;
W3.SetTitle("Window 3");
cout << W3;
W3.Perimetr();
_getch();
cin >> W1;
Windows W4 = W1 + Point(0, 0);
W4.SetTitle("Window 4");
cout << W4;
W4.Perimetr();
_getch();
return 0;
}
Stdafx.h
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <stdio.h>
#include <tchar.h>
#include <conio.h>
#include <iostream>
using namespace std;
stdafx.cpp
Include "targetver.H"
Windows::Windows(const char* title,
const Point& P1, const Point& P2,
Windows::Colors color, Windows::Visibility vis, Windows::FrameState frame)
{
If(!p1.InBounds() || !p2.InBounds())
{
cout<<"\nError: Coordinates of corners are out of consol\'s bounds.\n\n";
this->UperLeftCorner = Point();
this->LowerRightConer = Point();
this->Length = 0;
this->Width = 0;
}
else
{
this->UperLeftCorner = P1;
this->LowerRightConer = P2;
this->Width = P2.GetY() - P1.GetY();
this->Length = P2.GetX() - P1.GetX();
}
strcpy(this->Title, title);
this->SetColor(color);
this->SetVisibility(vis);
this->SetFrameState(frame);
}
Windows::Windows(const Windows& W)
{
this->UperLeftCorner = W.UperLeftCorner;
this->LowerRightConer = W.LowerRightConer;
this->Length = W.Length;
this->Width = W.Width;
this->color = W.color;
this->vis = W.vis;
this->frame = W.frame;
}
Windows Windows::operator= (const Windows& W)
{
this->UperLeftCorner = W.UperLeftCorner;
this->LowerRightConer = W.LowerRightConer;
this->Length = W.Length;
this->Width = W.Width;
this->color = W.color;
this->vis = W.vis;
this->frame = W.frame;
return *this;
}
Windows Windows::operator+ (const Point& dP)
{
Windows temp = *this;
temp.UperLeftCorner += dP;
temp.LowerRightConer += dP;
If(!temp.UperLeftCorner.InBounds() || !temp.LowerRightConer.InBounds())
{
temp = Windows();
cout<<"\nError: Resulted Window is out of consol\'s bound."<<endl;
cout<<"The Operation + is canceled.\n\n";
}
return temp;
}
Windows operator+ (const Point& dP, const Windows& W)
{
Windows temp = W;
temp.UperLeftCorner += dP;
temp.LowerRightConer += dP;
If(!temp.UperLeftCorner.InBounds() || !temp.LowerRightConer.InBounds())
{
temp = Windows();
cout<<"\nError: Resulted Window is out of consol\'s bound."<<endl;
cout<<"The Operation + is canceled.\n\n";
}
return temp;
}
Windows Windows::operator+= (const Point& dP)
{
this->UperLeftCorner += dP;
this->LowerRightConer += dP;
if(!this->UperLeftCorner.InBounds() || !this->LowerRightConer.InBounds())
{
this->UperLeftCorner -= dP;
this->LowerRightConer -= dP;
cout<<"\nError: Shifted Window is out of consol\'s bound."<<endl;
cout<<"The Operation += is canceled.\n\n";
}
return *this;
}
Windows Windows::operator* (const double& K)
{
Windows temp = *this;
if(K < 0)
{
temp = Windows();
cout<<"\nError: The negative values of stretch coefficient is not possible."<<endl;
cout<<"The Operation * is canceled.\n\n";
return temp;
}
temp.Length *= K;
temp.Width *= K;
temp.LowerRightConer = temp.UperLeftCorner + Point(temp.Length, temp.Width);