1.设计三个图形类:Circle(圆)、Rectangle(矩形)、Triangle(三角形),要求:

1个回答

  • 用VB程序设计做的随机画十个圆的编程代码 (抱歉:就知道这些)

    Dim r(10) As Integer,i As Integer '半径

    Dim x(10) As Integer,n As Integer '半径坐标

    Dim y(10) As Integer,m As Integer '半径坐标

    Dim mr As Integer

    Private Sub Command1_Click()

    Cls

    i = 1

    Text1 = " "

    Text2 = " "

    Timer1.Enabled = True

    Command2.Enabled = True

    End Sub

    Private Sub Command2_Click()

    Dim a As Integer,b As Integer

    a = r(1)

    b = r(1)

    For i = 2 To 10

    If a r(i) Then

    b = r(i)

    End If

    Next i

    Text1 = a

    Text2 = b

    End Sub

    Private Sub Command3_Click()

    End

    End Sub

    Private Sub Form_Load()

    i = 1

    n = 1

    m = 1

    End Sub

    Private Sub Timer1_Timer()

    Randomize

    x(n) = Int(Rnd * (Frame1.Left - 99) + 100)

    y(m) = Int(Rnd * (Form1.ScaleHeight - 99) + 100)

    mr = x(n)

    If mr > y(m) Then mr = y(m)

    If mr > Frame1.Left - x(n) Then mr = Frame1.Left - x(n)

    If mr > Form1.ScaleHeight - y(m) Then mr = Form1.ScaleHeight - y(m)

    r(i) = Int((Rnd * mr - 51) + 100)

    Circle (x(n),y(m)),r(i),QBColor(Int(Rnd * 16)) 'RGB(Int(Rnd * 256),Int(Rnd * 256),Int(Rnd * 256))

    Form1.DrawWidth = Int(Rnd * 5 + 1)

    i = i + 1

    If i = 11 Then Timer1.Enabled = False

    End Su