
- •Введение
- •Постановка задачи
- •Анализ задачи проектирования
- •Анализ вариантов использования программы
- •Требования к приложениям
- •Определение попадания точки в четырехугольник
- •Настольное приложение на базе erlang
- •Создание приложения в среде ErlyBird
- •Реализация приложения
- •Реализация приложения
- •Создание Web –сервиса
- •Создание клиентского приложения WebForm
- •Создание прокси-класса
- •Системные требования
- •Руководство системного программиста
- •Заключение
- •Список литературы
- •Приложение Файл monte.Erl(настольное приложение)
- •Файл print.Erl
- •Файл monte_carlo.Html(web приложение на базе скриптов)
- •Файл service.Cs(web сервис)
- •Файл Service.Asmx
- •Файл Default.Aspx(клиентская часть приложения WebForm)
- •Файл Default.Aspx.Cs
Файл service.Cs(web сервис)
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
}
public double square_tr(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy)
{
return Math.Abs((0.5 * ((dx - ax) + (cx - bx))) * (by - ay));
}
public double square_pr(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy)
{
return Math.Abs((dx - ax) * (by - ay));
}
[WebMethod]
public double[] montecarlo(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy, int N)
{
double line1, line2, sq_ABCD, sq_trap, sq_monte, error, rand_x, rand_y,count_temp,N_temp; int count = 0;
sq_ABCD = square_pr(ax, ay, bx, by, cx, cy, dx, dy);
sq_trap = square_tr(ax, ay, bx, by, cx, cy, dx, dy);
Random RandPoint = new Random();
DateTime Begin = DateTime.Now;
for (int i = 0; i < N; i++)
{
rand_x = ax + (RandPoint.NextDouble() * (dx - ax));
rand_y = ay + (RandPoint.NextDouble() * (by - ay));
line1 = (ay - by) * (rand_x - bx) / (ax - bx) + by;
line2 = (cy - dy) * (rand_x - dx) / (cx - dx) + dy;
if (line1 >= rand_y && line2 >= rand_y) count++;
}
count_temp = count;
N_temp = N;
sq_monte = sq_ABCD * (count_temp / N_temp);
error = Math.Round(Math.Abs((sq_monte / sq_trap * 100) - 100), 4);
TimeSpan TimeTaken = DateTime.Now.Subtract(Begin);
double[] rezult = new double[6];
rezult[0] = N;
rezult[1] = count;
rezult[2] = sq_trap;
rezult[3] = sq_monte;
rezult[4] = error;
rezult[5] = Convert.ToDouble(TimeTaken.TotalMilliseconds);
return rezult;
}
}
Файл Service.Asmx
<%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="Service" %>
Файл Default.Aspx(клиентская часть приложения WebForm)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TP3._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
#form1 {
height: 856px;
}
.auto-style1 {
width: 20px;
}
.auto-style2 {
text-align: center;
width: 93px;
}
.auto-style3 {
width: 114px;
}
.auto-style4 {
width: 93px;
}
.auto-style5 {
text-align: center;
}
.auto-style6 {
width: 20px;
height: 31px;
}
.auto-style7 {
width: 114px;
height: 31px;
}
.auto-style8 {
width: 93px;
height: 31px;
}
</style>
</head>
<body style="height: 850px">
<form id="form1" runat="server">
<h1 align="center" style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">Метод Монте-Карло</h1>
<p align="center" style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; width: 339px;">
<asp:Image ID="Image1" runat="server" Height="124px" ImageAlign="Baseline" ImageUrl="http://localhost/image.gif" style="text-align: left" Width="281px" />
</p>
<h2 style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; height: 10px; width: 1143px;">Введите координаты вершин</h2>
<h3 style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; height: 14px;">Для правильной работы программы нужно, чтобы Ах < Bx < Cx < Dx и Ay < By</h3>
<table style="height: 54px; width: 244px">
<tr><td>
<asp:RadioButton ID="RadioButton1" runat="server" OnCheckedChanged="RadioButton1_CheckedChanged" Text="Ввод координат" Width="250px" Checked="True" GroupName="radio" AutoPostBack="True" />
</td></tr>
<tr><td>
<asp:RadioButton ID="RadioButton2" runat="server" OnCheckedChanged="RadioButton2_CheckedChanged" Text="Рандомные координаты" Width="250px" GroupName="radio" AutoPostBack="True" />
</td></tr>
<tr><td>
<asp:RadioButton ID="RadioButton3" runat="server" OnCheckedChanged="RadioButton3_CheckedChanged" Text="Пример" Width="250px" GroupName="radio" AutoPostBack="True" />
</td></tr>
</table>
<table style="width: 260px; height: 152px">
<tr><td class="auto-style1"></td><td class="auto-style3" style="text-align: center">X</td><td class="auto-style2">Y</td></tr>
<tr><td class="auto-style1">A:</td><td class="auto-style3">
<asp:TextBox ID="TextBox1" runat="server" Columns="20" ></asp:TextBox>
</td><td class="auto-style4">
<asp:TextBox ID="TextBox5" runat="server" Columns="20" ></asp:TextBox>
</td></tr>
<tr><td class="auto-style1">B:</td><td class="auto-style3">
<asp:TextBox ID="TextBox2" runat="server" Columns="20" ></asp:TextBox>
</td><td class="auto-style4">
<asp:TextBox ID="TextBox6" runat="server" Columns="20" ></asp:TextBox>
</td></tr>
<tr><td class="auto-style6">C:</td><td class="auto-style7">
<asp:TextBox ID="TextBox3" runat="server" Columns="20"></asp:TextBox>
</td><td class="auto-style8">
<asp:TextBox ID="TextBox7" runat="server" Columns="20" ></asp:TextBox>
</td></tr>
<tr><td class="auto-style1">D:</td><td class="auto-style3">
<asp:TextBox ID="TextBox4" runat="server" Columns="20" ></asp:TextBox>
</td><td class="auto-style4">
<asp:TextBox ID="TextBox8" runat="server" Columns="20" ></asp:TextBox>
</td></tr>
</table>
<br />
<asp:Button ID="Button1" runat="server" Text="Расчитать" Width="206px" OnClick="Button1_Click" />
<br />
<br />
<table style="width: 1072px" align="left" id="table1" >
<tr><td class="auto-style5">
<asp:Label ID="Label31" runat="server" Text="Общее количество точек" Visible="False"></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label32" runat="server" Text="Количествово попавших точек" Visible="False"></asp:Label>
</td>
<td class="auto-style5">
<asp:Label ID="Label33" runat="server" Text="Точная площадь трапеции" Visible="False"></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label34" runat="server" Text="Посчитаная площадь трапеции" Visible="False"></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label35" runat="server" Text="Погрешность, %" Visible="False"></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label36" runat="server" Text="Время выполнения, мс" Visible="False"></asp:Label>
</td></tr>
<tr><td class="auto-style5">
<asp:Label ID="Label1" runat="server"></asp:Label>
</td><td class="auto-style5" style="margin-left: 40px">
<asp:Label ID="Label2" runat="server"></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label3" runat="server"></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label4" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label5" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label6" runat="server" Text=""></asp:Label>
</td></tr>
<tr><td class="auto-style5">
<asp:Label ID="Label7" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label8" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label9" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label10" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label11" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label12" runat="server" Text=""></asp:Label>
</td></tr>
<tr><td class="auto-style5">
<asp:Label ID="Label13" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label14" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label15" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label16" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label17" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label18" runat="server" Text=""></asp:Label>
</td></tr>
<tr><td class="auto-style5">
<asp:Label ID="Label19" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label20" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label21" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label22" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label23" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label24" runat="server" Text=""></asp:Label>
</td></tr>
<tr><td class="auto-style5">
<asp:Label ID="Label25" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label26" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label27" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label28" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label29" runat="server" Text=""></asp:Label>
</td><td class="auto-style5">
<asp:Label ID="Label30" runat="server" Text=""></asp:Label>
</td></tr>
</table>
</form>
</body>
</html>