不會寫Visual Web的問題題目?!

大大好:

我有一題不會做的題目 Visual Web --- asp.net 用c#

題目圖片:http://www.dumpt.com/img/viewer.php?file=gq9uceu9y...

題目:

三個圓的圓心都在同一直線上且三圓互切,在TEXTBOX輸入任何紅黃圓的半徑

EX: 橘圓半徑: [ textbox1]

黃圓半徑: [ textbox2]

藍圓面積:(等於textbox1和2算出的值)

寫在button裡

還有他說要寫防呆機制,避免輸入非數字和0

以上都是我沒學過的 所以我不知道該如何下手

簡單的佈置我都ok, 就是不會寫他的程式碼(不是寫在html)

想問問有沒有人可以用簡單的方式或較容易看懂得程式碼給我看看該如何寫??

萬事拜託

感謝

1 Answer

Rating
  • 1 decade ago
    Favorite Answer

    新增一個button

    跟兩個textbox

    調用

    using System.Drawing;

    using System.Drawing.Drawing2D;

    計算類別

    class bclass

    {

    Rectangle orange, yellow, blue;

    int b1, o1, o2, y1, y2, y3;

    string superficial;

    public void bb(int i, int j)

    {

    b1 = (i * 2) + (j * 2);

    blue = new Rectangle(0, 0, b1, b1);

    o1 = (b1 / 2) - i;

    o2 = i * 2;

    orange = new Rectangle(0, o1, o2, o2);

    y1 = b1 - (j * 2);

    y2 = (b1 / 2) - j;

    y3 = j * 2;

    yellow = new Rectangle(y1, y2, y3, y3);

    float sp = (i + j) * (i + j) * (float)3.14;

    superficial = sp.ToString();

    }

    public Rectangle ORANGE

    {

    get

    {

    return orange;

    }

    }

    public Rectangle YELLOW

    {

    get

    {

    return yellow;

    }

    }

    public Rectangle BLUE

    {

    get

    {

    return blue;

    }

    }

    public int B

    {

    get

    {

    return b1;

    }

    }

    public string SUPERFICIAL

    {

    get

    {

    return superficial;

    }

    }

    }

    宣告屬性

    bclass bget = new bclass();

    SolidBrush sbOrange = new SolidBrush(Color.Orange);

    SolidBrush sbYellow = new SolidBrush(Color.Yellow);

    SolidBrush sbBlue = new SolidBrush(Color.Blue);

    Pen p = new Pen(Color.White, 1);

    button程式碼

    try

    {

    if (int.Parse(TextBox1.Text) > 0 && int.Parse(TextBox2.Text) > 0)

    {

    bget.bb(int.Parse(TextBox1.Text), int.Parse(TextBox2.Text));

    Bitmap bmp = new Bitmap(bget.B, bget.B);

    Graphics g = Graphics.FromImage(bmp);

    g.FillEllipse(sbBlue, bget.BLUE);

    g.FillEllipse(sbOrange, bget.ORANGE);

    g.FillEllipse(sbYellow, bget.YELLOW);

    g.DrawString(bget.SUPERFICIAL, new Font("Arial", 15), sbYellow, 10, 10);

    bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);

    Response.ContentType = "image/gif";

    }

    }

    catch { }

Still have questions? Get your answers by asking now.