Введение в технологию программирования. Ч.1. Среда объектно-ориентированного программирования Delphi. Коржов Е.Н - 4 стр.

UptoLike

Составители: 

4
ȼȼȿȾȿɇɂȿ
ɇɚɫɬɨɹɳɟɟ ɭɱɟɛɧɨɟ ɩɨɫɨɛɢɟ ɩɨɞɝɨɬɨɜɥɟɧɨ ɞɥɹ ɫɬɭɞɟɧɬɨɜ, ɧɚɱɢɧɚɸ-
ɳɢɯ ɢɡɭɱɚɬɶ ɤɭɪɫ «əɡɵɤɢ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɜɵɫɨɤɨɝɨ ɭɪɨɜɧɹ», ɢɥɢ «Ɍɟɯ-
ɧɨɥɨɝɢɹ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ», ɤɨɝɞɚ ɜɵɛɪɚɧɚ ɫɪɟɞɚ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ
Borland Delphi. Ɉɫɧɨɜɧɚɹ ɰɟɥɶ ɩɨɫɨɛɢɹ ɡɚɤɥɸɱɚɟɬɫɹ ɜ ɪɚɡɜɢɬɢɢ ɩɟɪɜɵɯ
ɩɪɚɤɬɢɱɟɫɤɢɯ ɧɚɜɵɤɨɜ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɫɪɟɞɵ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Delphi ɜ
ɪɚɡɪɚɛɨɬɤɟ ɩɪɨɝɪɚɦɦɧɨɝɨ ɨɛɟɫɩɟɱɟɧɢɹ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɢɫɬɟɦ ɨɛɳɟɝɨ ɧɚ-
ɡɧɚɱɟɧɢɹ.
ȼ ɩɟɪɜɨɣ ɱɚɫɬɢ ɩɨɫɨɛɢɹ ɞɚɟɬɫɹ ɨɛɳɟɟ ɩɪɟɞɫɬɚɜɥɟɧɢɟ ɨɛ ɨɛɴɟɤɬɧɨ-
ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɣ ɫɪɟɞɟ ɪɚɡɪɚɛɨɬɤɢ ɩɪɨɝɪɚɦɦ Borland Delphi, ɨɬɥɢɱɚɸɳɟɣ-
ɫɹ, ɧɚ ɧɚɲ ɜɡɝɥɹɞ, ɨɬ ɞɪɭɝɢɯ ɩɨɞɨɛɧɵɯ ɫɢɫɬɟɦ ɧɚɢɛɨɥɶɲɟɣ ɫɬɪɨɝɨɫɬɶɸ
ɹɡɵɤɚ, ɫ ɨɞɧɨɣ ɫɬɨɪɨɧɵ, ɢ ɩɨɩɭɥɹɪɧɨɫɬɶɸ ɫɪɟɞɢ ɨɛɭɱɚɸɳɢɯɫɹ ɩɪɢ ɢɡɭɱɟ-
ɧɢɢ ɨɫɧɨɜ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ, ɫ ɞɪɭɝɨɣ. ȼ ɩɨɫɨɛɢɢ ɩɪɢɜɨɞɹɬɫɹ ɧɟɤɨɬɨɪɵɟ
ɧɚɱɚɥɶɧɵɟ ɫɜɟɞɟɧɢɹ ɨ ɫɨɜɪɟɦɟɧɧɵɯ ɜɡɝɥɹɞɚɯ ɜ ɨɛɥɚɫɬɢ ɬɟɯɧɨɥɨɝɢɢ ɨɛɴ-
ɟɤɬɧɨ-ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ.
ȼɨ ɜɬɨɪɨɣ ɱɚɫɬɢ ɩɪɟɞɫɬɚɜɥɟɧɵ ɡɚɞɚɧɢɹ ɢ ɩɪɢɦɟɪɵ ɢɯ ɜɵɩɨɥɧɟɧɢɹ ɜ
ɪɚɦɤɚɯ ɥɚɛɨɪɚɬɨɪɧɨɝɨ ɩɪɚɤɬɢɤɭɦɚ, ɪɚɫɫɱɢɬɚɧɧɨɝɨ ɧɚ 20 ɚɤɚɞɟɦɢɱɟɫɤɢɯ ɱɚ-
ɫɨɜ. ɉɪɟɞɩɨɥɚɝɚɟɬɫɹ, ɱɬɨ ɩɪɚɤɬɢɤɭɦ ɫɨɫɬɨɢɬ ɢɡ ɩɹɬɢ ɱɟɬɵɪɟɯɱɚɫɨɜɵɯ ɫɞɜɨ-
ɟɧɧɵɯ ɡɚɧɹɬɢɣ. ɉɟɪɜɚɹ ɱɚɫɬɶ ɡɚɧɹɬɢɹ ɜɵɩɨɥɧɹɟɬɫɹ ɫɬɭɞɟɧɬɨɦ ɩɨɞ ɪɭɤɨɜɨ-
ɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ, ɚ ɜɬɨɪɚɹɫɚɦɨɫɬɨɹɬɟɥɶɧɨ.
ȼ ɉɪɢɥɨɠɟɧɢɢ ɩɪɢɜɟɞɟɧɵ ɧɚɢɛɨɥɟɟ ɱɚɫɬɨ ɢɫɩɨɥɶɡɭɟɦɵɟ ɩɪɢ ɪɚɡɪɚ-
ɛɨɬɤɟ ɩɪɨɝɪɚɦɦ ɫɜɟɞɟɧɢɹ ɤɚɤ ɨ ɫɚɦɨɣ ɫɪɟɞɟ Delphi, ɬɚɤ ɢ ɨ ɧɟɤɨɬɨɪɵɯ ɟɺ
ɧɚɢɛɨɥɟɟ ɱɚɫɬɨ ɭɩɨɬɪɟɛɥɹɸɳɢɯɫɹ ɤɨɦɩɨɧɟɧɬɚɯ.
ɉɪɟɞɩɨɥɚɝɚɟɬɫɹ, ɱɬɨ ɫɬɭɞɟɧɬ ɪɚɧɟɟ ɩɪɨɫɥɭɲɚɥ ɧɚɱɚɥɶɧɵɣ ɤɭɪɫ «ɂɧ-
ɮɨɪɦɚɬɢɤɚ» ɢ ɩɨɥɭɱɢɥ ɧɟɨɛɯɨɞɢɦɵɟ ɫɜɟɞɟɧɢɹ ɨ ɠɢɡɧɟɧɧɨɦ ɰɢɤɥɟ ɩɪɨ-
ɝɪɚɦɦɵ, ɩɨɧɹɬɢɟ ɨɛ ɚɥɝɨɪɢɬɦɟ ɢ ɟɝɨ ɫɜɨɣɫɬɜɚɯ, ɚ ɬɚɤɠɟ ɩɪɢɨɛɪɟɥ ɩɪɚɤɬɢ-
ɱɟɫɤɢɟ ɧɚɜɵɤɢ ɪɚɡɪɚɛɨɬɤɢ ɚɥɝɨɪɢɬɦɨɜ
, ɜɤɥɸɱɚɸɳɢɟ ɫɥɟɞɭɸɳɢɟ ɲɚɝɢ,
ɩɪɟɞɲɟɫɬɜɭɸɳɢɟ ɷɬɚɩɭ ɫɨɛɫɬɜɟɧɧɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ (ɤɨɞɢɪɨɜɚɧɢɹ):
1) ɚɧɚɥɢɡ ɡɚɞɚɧɢɹ ɢ ɨɩɪɟɞɟɥɟɧɢɟ ɨɫɧɨɜɧɨɣ ɢɞɟɢ ɟɝɨ ɪɟɚɥɢɡɚɰɢɢ;
2) ɨɩɪɟɞɟɥɟɧɢɟ ɜɯɨɞɧɵɯ ɞɚɧɧɵɯ;
3) ɨɩɪɟɞɟɥɟɧɢɟ ɜɵɯɨɞɧɵɯ ɞɚɧɧɵɯ;
4) ɡɚɩɢɫɶ ɬɟɤɫɬɚ ɧɚ ɚɥɝɨɪɢɬɦɢɱɟɫɤɨɦ ɹɡɵɤɟ ɢɥɢ ɫɨɫɬɚɜɥɟɧɢɟ ɛɥɨɤ-
ɫɯɟɦɵ ɚɥɝɨɪɢɬɦɚ.
ɗɬɢ ɞɟɣɫɬɜɢɹ, ɩɪɟɞɲɟɫɬɜɭɸɳɢɟ ɧɟɩɨɫɪɟɞɫɬɜɟɧɧɨɣ ɪɚɛɨɬɟ ɫɨ ɫɪɟɞɨɣ
ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ, ɜ ɞɚɧɧɨɦ ɩɨɫɨɛɢɢ ɧɟ ɪɚɫɫɦɚɬɪɢɜɚɸɬɫɹ. ɉɨɥɚɝɚɟɬɫɹ,
ɨɞɧɚɤɨ, ɱɬɨ ɩɨɞɨɛɧɚɹ ɩɪɟɞɜɚɪɢɬɟɥɶɧɚɹ ɪɚɛɨɬɚ ɩɪɨɜɨɞɢɬɫɹ ɤɚɠɞɵɦ ɫɬɭɞɟɧ-
ɬɨɦ ɫɚɦɨɫɬɨɹɬɟɥɶɧɨ ɢ ɨɮɨɪɦɥɹɟɬɫɹ ɞɨɥɠɧɵɦ ɨɛɪɚɡɨɦ ɜ ɪɚɛɨɱɟɣ ɬɟɬɪɚɞɢ.
Ɇɵ ɫɨɱɥɢ ɜɨɡɦɨɠɧɵɦ ɬɚɤɠɟ ɧɟ ɚɤɰɟɧɬɢɪɨɜɚɬɶ ɜɧɢɦɚɧɢɟ ɧɚ ɬɚɤɨɦ ɜɨ-
ɩɪɨɫɟ, ɤɚɤ ɬɟɫɬɢɪɨɜɚɧɢɟ ɪɚɡɪɚɛɨɬɚɧɧɨɣ ɩɪɨɝɪɚɦɦɵ, ɯɨɬɹ ɷɬɨ, ɛɟɡɭɫɥɨɜɧɨ,
ɜɚɠɧɟɣɲɢɣ ɷɬɚɩ ɠɢɡɧɟɧɧɨɝɨ ɰɢɤɥɚ ɩɪɨɝɪɚɦɦɵ ɢ ɨɞɢɧ ɢɡ ɩɪɢɟɦɨɜ ɞɨɤɚɡɚ-
ɬɟɥɶɫɬɜɚ ɩɪɚɜɢɥɶɧɨɫɬɢ ɟɟ ɪɚɛɨɬɵ ɢ ɫɨɨɬɜɟɬɫɬɜɢɹ ɮɭɧɤɰɢɨɧɚɥɶɧɵɦ ɢ ɩɪɨ-
ɰɟɞɭɪɧɵɦ ɫɩɟɰɢɮɢɤɚɰɢɹɦ. Ⱦɭɦɚɟɬɫɹ, ɩɪɟɞɫɬɚɜɥɟɧɧɵɣ ɦɚɬɟɪɢɚɥ ɜ ɧɚɢ-
ɛɨɥɶɲɟɣ ɫɬɟɩɟɧɢ ɨɬɜɟɱɚɟɬ ɨɫɧɨɜɧɨɣ ɡɚɞɚɱɟ ɷɬɨɝɨ ɫɟɦɟɫɬɪɨɜɨɝɨ ɤɭɪɫɚ.
                              ȼȼȿȾȿɇɂȿ
     ɇɚɫɬɨɹɳɟɟ ɭɱɟɛɧɨɟ ɩɨɫɨɛɢɟ ɩɨɞɝɨɬɨɜɥɟɧɨ ɞɥɹ ɫɬɭɞɟɧɬɨɜ, ɧɚɱɢɧɚɸ-
ɳɢɯ ɢɡɭɱɚɬɶ ɤɭɪɫ «əɡɵɤɢ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɜɵɫɨɤɨɝɨ ɭɪɨɜɧɹ», ɢɥɢ «Ɍɟɯ-
ɧɨɥɨɝɢɹ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ», ɤɨɝɞɚ ɜɵɛɪɚɧɚ ɫɪɟɞɚ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ
Borland Delphi. Ɉɫɧɨɜɧɚɹ ɰɟɥɶ ɩɨɫɨɛɢɹ ɡɚɤɥɸɱɚɟɬɫɹ ɜ ɪɚɡɜɢɬɢɢ ɩɟɪɜɵɯ
ɩɪɚɤɬɢɱɟɫɤɢɯ ɧɚɜɵɤɨɜ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɫɪɟɞɵ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Delphi ɜ
ɪɚɡɪɚɛɨɬɤɟ ɩɪɨɝɪɚɦɦɧɨɝɨ ɨɛɟɫɩɟɱɟɧɢɹ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɢɫɬɟɦ ɨɛɳɟɝɨ ɧɚ-
ɡɧɚɱɟɧɢɹ.
     ȼ ɩɟɪɜɨɣ ɱɚɫɬɢ ɩɨɫɨɛɢɹ ɞɚɟɬɫɹ ɨɛɳɟɟ ɩɪɟɞɫɬɚɜɥɟɧɢɟ ɨɛ ɨɛɴɟɤɬɧɨ-
ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɣ ɫɪɟɞɟ ɪɚɡɪɚɛɨɬɤɢ ɩɪɨɝɪɚɦɦ Borland Delphi, ɨɬɥɢɱɚɸɳɟɣ-
ɫɹ, ɧɚ ɧɚɲ ɜɡɝɥɹɞ, ɨɬ ɞɪɭɝɢɯ ɩɨɞɨɛɧɵɯ ɫɢɫɬɟɦ ɧɚɢɛɨɥɶɲɟɣ ɫɬɪɨɝɨɫɬɶɸ
ɹɡɵɤɚ, ɫ ɨɞɧɨɣ ɫɬɨɪɨɧɵ, ɢ ɩɨɩɭɥɹɪɧɨɫɬɶɸ ɫɪɟɞɢ ɨɛɭɱɚɸɳɢɯɫɹ ɩɪɢ ɢɡɭɱɟ-
ɧɢɢ ɨɫɧɨɜ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ, ɫ ɞɪɭɝɨɣ. ȼ ɩɨɫɨɛɢɢ ɩɪɢɜɨɞɹɬɫɹ ɧɟɤɨɬɨɪɵɟ
ɧɚɱɚɥɶɧɵɟ ɫɜɟɞɟɧɢɹ ɨ ɫɨɜɪɟɦɟɧɧɵɯ ɜɡɝɥɹɞɚɯ ɜ ɨɛɥɚɫɬɢ ɬɟɯɧɨɥɨɝɢɢ ɨɛɴ-
ɟɤɬɧɨ-ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ.
     ȼɨ ɜɬɨɪɨɣ ɱɚɫɬɢ ɩɪɟɞɫɬɚɜɥɟɧɵ ɡɚɞɚɧɢɹ ɢ ɩɪɢɦɟɪɵ ɢɯ ɜɵɩɨɥɧɟɧɢɹ ɜ
ɪɚɦɤɚɯ ɥɚɛɨɪɚɬɨɪɧɨɝɨ ɩɪɚɤɬɢɤɭɦɚ, ɪɚɫɫɱɢɬɚɧɧɨɝɨ ɧɚ 20 ɚɤɚɞɟɦɢɱɟɫɤɢɯ ɱɚ-
ɫɨɜ. ɉɪɟɞɩɨɥɚɝɚɟɬɫɹ, ɱɬɨ ɩɪɚɤɬɢɤɭɦ ɫɨɫɬɨɢɬ ɢɡ ɩɹɬɢ ɱɟɬɵɪɟɯɱɚɫɨɜɵɯ ɫɞɜɨ-
ɟɧɧɵɯ ɡɚɧɹɬɢɣ. ɉɟɪɜɚɹ ɱɚɫɬɶ ɡɚɧɹɬɢɹ ɜɵɩɨɥɧɹɟɬɫɹ ɫɬɭɞɟɧɬɨɦ ɩɨɞ ɪɭɤɨɜɨ-
ɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ, ɚ ɜɬɨɪɚɹ – ɫɚɦɨɫɬɨɹɬɟɥɶɧɨ.
     ȼ ɉɪɢɥɨɠɟɧɢɢ ɩɪɢɜɟɞɟɧɵ ɧɚɢɛɨɥɟɟ ɱɚɫɬɨ ɢɫɩɨɥɶɡɭɟɦɵɟ ɩɪɢ ɪɚɡɪɚ-
ɛɨɬɤɟ ɩɪɨɝɪɚɦɦ ɫɜɟɞɟɧɢɹ ɤɚɤ ɨ ɫɚɦɨɣ ɫɪɟɞɟ Delphi, ɬɚɤ ɢ ɨ ɧɟɤɨɬɨɪɵɯ ɟɺ
ɧɚɢɛɨɥɟɟ ɱɚɫɬɨ ɭɩɨɬɪɟɛɥɹɸɳɢɯɫɹ ɤɨɦɩɨɧɟɧɬɚɯ.
     ɉɪɟɞɩɨɥɚɝɚɟɬɫɹ, ɱɬɨ ɫɬɭɞɟɧɬ ɪɚɧɟɟ ɩɪɨɫɥɭɲɚɥ ɧɚɱɚɥɶɧɵɣ ɤɭɪɫ «ɂɧ-
ɮɨɪɦɚɬɢɤɚ» ɢ ɩɨɥɭɱɢɥ ɧɟɨɛɯɨɞɢɦɵɟ ɫɜɟɞɟɧɢɹ ɨ ɠɢɡɧɟɧɧɨɦ ɰɢɤɥɟ ɩɪɨ-
ɝɪɚɦɦɵ, ɩɨɧɹɬɢɟ ɨɛ ɚɥɝɨɪɢɬɦɟ ɢ ɟɝɨ ɫɜɨɣɫɬɜɚɯ, ɚ ɬɚɤɠɟ ɩɪɢɨɛɪɟɥ ɩɪɚɤɬɢ-
ɱɟɫɤɢɟ ɧɚɜɵɤɢ ɪɚɡɪɚɛɨɬɤɢ ɚɥɝɨɪɢɬɦɨɜ, ɜɤɥɸɱɚɸɳɢɟ ɫɥɟɞɭɸɳɢɟ ɲɚɝɢ,
ɩɪɟɞɲɟɫɬɜɭɸɳɢɟ ɷɬɚɩɭ ɫɨɛɫɬɜɟɧɧɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ (ɤɨɞɢɪɨɜɚɧɢɹ):
       1) ɚɧɚɥɢɡ ɡɚɞɚɧɢɹ ɢ ɨɩɪɟɞɟɥɟɧɢɟ ɨɫɧɨɜɧɨɣ ɢɞɟɢ ɟɝɨ ɪɟɚɥɢɡɚɰɢɢ;
       2) ɨɩɪɟɞɟɥɟɧɢɟ ɜɯɨɞɧɵɯ ɞɚɧɧɵɯ;
       3) ɨɩɪɟɞɟɥɟɧɢɟ ɜɵɯɨɞɧɵɯ ɞɚɧɧɵɯ;
       4) ɡɚɩɢɫɶ ɬɟɤɫɬɚ ɧɚ ɚɥɝɨɪɢɬɦɢɱɟɫɤɨɦ ɹɡɵɤɟ ɢɥɢ ɫɨɫɬɚɜɥɟɧɢɟ ɛɥɨɤ-
          ɫɯɟɦɵ ɚɥɝɨɪɢɬɦɚ.
     ɗɬɢ ɞɟɣɫɬɜɢɹ, ɩɪɟɞɲɟɫɬɜɭɸɳɢɟ ɧɟɩɨɫɪɟɞɫɬɜɟɧɧɨɣ ɪɚɛɨɬɟ ɫɨ ɫɪɟɞɨɣ
ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ, ɜ ɞɚɧɧɨɦ ɩɨɫɨɛɢɢ ɧɟ ɪɚɫɫɦɚɬɪɢɜɚɸɬɫɹ. ɉɨɥɚɝɚɟɬɫɹ,
ɨɞɧɚɤɨ, ɱɬɨ ɩɨɞɨɛɧɚɹ ɩɪɟɞɜɚɪɢɬɟɥɶɧɚɹ ɪɚɛɨɬɚ ɩɪɨɜɨɞɢɬɫɹ ɤɚɠɞɵɦ ɫɬɭɞɟɧ-
ɬɨɦ ɫɚɦɨɫɬɨɹɬɟɥɶɧɨ ɢ ɨɮɨɪɦɥɹɟɬɫɹ ɞɨɥɠɧɵɦ ɨɛɪɚɡɨɦ ɜ ɪɚɛɨɱɟɣ ɬɟɬɪɚɞɢ.
     Ɇɵ ɫɨɱɥɢ ɜɨɡɦɨɠɧɵɦ ɬɚɤɠɟ ɧɟ ɚɤɰɟɧɬɢɪɨɜɚɬɶ ɜɧɢɦɚɧɢɟ ɧɚ ɬɚɤɨɦ ɜɨ-
ɩɪɨɫɟ, ɤɚɤ ɬɟɫɬɢɪɨɜɚɧɢɟ ɪɚɡɪɚɛɨɬɚɧɧɨɣ ɩɪɨɝɪɚɦɦɵ, ɯɨɬɹ ɷɬɨ, ɛɟɡɭɫɥɨɜɧɨ,
ɜɚɠɧɟɣɲɢɣ ɷɬɚɩ ɠɢɡɧɟɧɧɨɝɨ ɰɢɤɥɚ ɩɪɨɝɪɚɦɦɵ ɢ ɨɞɢɧ ɢɡ ɩɪɢɟɦɨɜ ɞɨɤɚɡɚ-
ɬɟɥɶɫɬɜɚ ɩɪɚɜɢɥɶɧɨɫɬɢ ɟɟ ɪɚɛɨɬɵ ɢ ɫɨɨɬɜɟɬɫɬɜɢɹ ɮɭɧɤɰɢɨɧɚɥɶɧɵɦ ɢ ɩɪɨ-
ɰɟɞɭɪɧɵɦ ɫɩɟɰɢɮɢɤɚɰɢɹɦ. Ⱦɭɦɚɟɬɫɹ, ɩɪɟɞɫɬɚɜɥɟɧɧɵɣ ɦɚɬɟɪɢɚɥ ɜ ɧɚɢ-
ɛɨɥɶɲɟɣ ɫɬɟɩɟɧɢ ɨɬɜɟɱɚɟɬ ɨɫɧɨɜɧɨɣ ɡɚɞɚɱɟ ɷɬɨɝɨ ɫɟɦɟɫɬɪɨɜɨɝɨ ɤɭɪɫɚ.
                                  4