⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nahai.txt

📁 inherits + point + line + ...
💻 TXT
字号:
//---------------------------------------------------------------------------
#include <math.h>
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
/***************************/
/***************************/
class point
{
protected:
        int x,y;
        HDC drawing_context;
public:
        point(int,int);
        void draw();
};
/***************************/
point::point(int a,int b)
{
        x=a; y=b;
        drawing_context = GetDC(Form1->Handle);
}
/***************************/
void point::draw()
{
        SetPixel(drawing_context, x, y, RGB(128,0, 128));
}
/***************************/
/***************************/
class line:public point
{
protected:
        int len;
public:
        line(int,int,int);
        void draw();
};
/***************************/
line::line(int x,int y,int l):point(x,y)
{
        len=l;
}
/***************************/
void line::draw()
{
        int t=x;
        for (int i=0;i<len;i++)
        {
                point::draw();x++;
        }
        x=t;
}
/***************************/
/***************************/
class motavazi:public line
{
protected:
        int angle,height;
public:
motavazi(int,int,int);
setheight(int);
setangle(int);
void draw();
};
/***************************/
motavazi::motavazi(int x,int y,int len):line(x,y,len)
{
        angle=0;
        height=0;
}
/***************************/
motavazi::setheight(int height1)
{
        if (height1>0)
                height=height1;
}
/***************************/
motavazi::setangle(int angle1)
{
        angle=angle1;
}
/***************************/
void motavazi::draw()
{
        int ty=y,tx=x;
        double a=(angle*3.14)/180 ;
        for (int i=1;i<=height;i++)
        {
                line::draw();
                x=tx+(i/tan(a));
                y++;
        }
        y=ty;x=tx;
}
/***************************/
/***************************/
class rect:public motavazi
{
public:
        rect(int,int,int);
};
/***************************/
rect::rect(int x,int y,int len):motavazi(x,y,len)
{
        angle=90;
}
/***************************/
/***************************/
class squer:public rect
{
public:
        squer(int,int,int);
};
/***************************/
squer::squer(int x,int y,int len):rect(x,y,len)
{
        height=len;
}
/***************************/
/***************************/
class emptymotavazi:public motavazi
{
public:
        emptymotavazi(int,int,int);
        void draw();
};
/***************************/
emptymotavazi::emptymotavazi(int x,int y,int len):motavazi(x,y,len)
{
        angle=0;
        height=0;
}
/***************************/
void emptymotavazi::draw()
{
        int ty=y,tx=x;
        double a=(angle*3.14)/180 ;
        line::draw();
        x=tx+(1/tan(a));
        y++;
        for (int i=2;i<height;i++)
        {
                point::draw();
                x=x+len;
                point::draw();
                x=x-len;
                x=tx+(i/tan(a));
                y++;
        }
        line::draw();
        y=ty;x=tx;
}
/***************************/
/***************************/
class emptyrect:public emptymotavazi
{
public:
        emptyrect(int,int,int);
};
/***************************/
emptyrect::emptyrect(int x,int y,int len):emptymotavazi(x,y,len)
{
        angle=90;
}
/***************************/
/***************************/
class emptysquer:public emptyrect
{
public:
        emptysquer(int,int,int);
};
/***************************/
emptysquer::emptysquer(int x,int y,int len):emptyrect(x,y,len)
{
        height=len;
}
/***************************/
/***************************/
void __fastcall TForm1::p(TObject *Sender)
{
        point p1(50,9);
        line l1(7,9,100);
        emptysquer s1(12,14,20);
        emptyrect r1(80,90,100);
        emptymotavazi m1(50,50,100);

        m1.setangle(30);
        m1.setheight(30);
        m1.draw() ;
        p1.draw();
        l1.draw() ;
        s1.draw() ;
        r1.setheight(50) ;
        r1.draw() ;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -