. Тімотті С. Монк, Стівен Поттс "Borland C + + в прикладах". Мінськ 1996р.
11. Додатки
Додаток А
Лістінгі програми основного Завдання.
# include
# include max (int value1, int value2)
{((value1> value2)? value1: value2);
} min (int value1, int value2)
{((value1
} Point {Line;: POSITION {,
}; RELATIVE_RECT {_RECT, _OF_RECT
}; (int theX, int theY)// constructor
{= theX; Y = theY;
} DetectType (Line & Diagonal); Show (int Dump = 0); GetX () {return X;} GetY () {return Y;} Position () {return Pos ;} _RECT In_Rect () {return Location;}: X, Y;// coordinatesPos;// relative to line_RECT Location;// relative to rect.
}; Line {: FIGURE {,
}; * A, * B; (Point & P1, Point & P2)
{= new Point (P1. GetX (), P1. GetY ()); = new Point (P2. GetX (), P2. GetY ());
} Show (FIGURE figure);
}; App {: GRAPH_RESULT {_OK, _FAILURE
}; Run ();// constructor_RESULT SwitchToGraphic (); SwitchToText ();
}; main ()
{Kursova;. run (); 0;
}
// --------------- class Point ------------------- Point :: DetectType (Line & Diagonal)
{TopX, BottomX,, RightY; = min (Diagonal. A-> GetX (), Diagonal. B-> GetX ()); = max (Diagonal. A- > GetX (), Diagonal. B-> GetX ()); = min (Diagonal. A-> GetY (), Diagonal. B-> GetY ()); = max (Diagonal. A-> GetY (), Diagonal. B-> GetY ());
// relative to rectangle. (Diagonal. A-> GetX () == Diagonal. B-> GetX () | |. A-> GetY () == Diagonal. B-> GetY ())
{= OUT_OF_RECT;;
} ((TopX
(LeftY
/* (GetY () <
(GetX () - Diagonal. A-> GetX ()) *
(Diagonal. B-> GetY () - Diagonal. A-> GetY ())/
(Diagonal. B-> GetX () - Diagonal. A-> GetX ()) + Diagonal. A-> GetY ())
*/
// relative to line.temporary = GetX () - Diagonal. A->...