rls.hpp>
// ---------------------------------------- -------------------------- TMainForm: public TForm
{
__published ://IDE-managed Components * image;
TLabel * Label3; * Label4; * Label7;
private ://User declarations ://User declarations
__fastcall TMainForm (TComponent * Owner); __fastcall Draw (); __fastcall drawPos (int p, double s);
}; TReostat
{:
double r; pos; nc; step;:
__fastcall TReostat () {r = 0; pos = 0; nc = 9; step = 20;}; __fastcall GetPosition () {return pos;}; __fastcall GetR () {return r;} ; __fastcall GetNC () {return nc;}; __fastcall GetStep () {return step;}; __fastcall SetPosition (int val) {pos = val;}; __fastcall SetNC (int val) {nc = val;}; __fastcall SetStep ( double val) {step = val;}; __fastcall SetR (double val) {r = val;};
}; PACKAGE TMainForm * MainForm;
# endif.cpp
// ---------------------------------------- ----------------------------
# include
# pragma hdrstop
# include "Main.h"
# include
// ---------------------------------------- ----------------------------
# pragma package (smart_init)
# pragma resource "*. dfm" * MainForm;
// Coil - виток дроту реостата
// NC - кількість витків
// ---------------------------------------- ----------------------------
__fastcall TMainForm :: TMainForm (TComponent * Owner)
: TForm (Owner)
{Label3-> Caption = "Опір реостата (Ом):";
Draw (); * Reostat = new TReostat ();
}
// ---------------------------------------- ---------------------------- __fastcall TMainForm :: Draw ()
{TReostat * Reostat = new TReostat (); -> SetNC (10);
Reostat-> SetPosition (4);
// початкова позиція - 30
// кінцева позиція - 530
// діапазон - 500> SetStep (500/(Reostat-> GetNC () -1)); * o = image-> Canvas;> Brush-> Color = clWhite; > FillRect (image-> ClientRect);> Pen-> Color = clBlack; X = 30, Y = 50, Y1 = 150; (int i = 0; i GetNC (); i + + )
{> MoveTo (X, Y);> LineTo (X, Y1); (i! = (Reostat-> GetNC () -1))
{> MoveTo (X, Y);> LineTo ((X + Reostat-> GetStep ()), Y1);
} break; + = Reostat-> GetStep ();
} = 30; = 100;> MoveTo (X-20, Y);