Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Web.Http;
- namespace DistCalcRESTService.Controllers
- {
- public class Point
- {
- public int X { get; set; }
- public int Y { get; set; }
- public static double distance(Point startPoint, Point endPoit)
- {
- int deltaX = startPoint.X - endPoit.X;
- int deltaY = startPoint.Y - endPoit.Y;
- return Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
- }
- }
- public class ValuesController : ApiController
- {
- // GET api/values
- public string Get()
- {
- return "a+b";
- }
- // GET api/values/5
- [Route("dist")]
- public double distance(int x1, int y1, int x2,int y2)
- {
- Point startPoint = new Point()
- {
- X = x1,
- Y = y1
- };
- Point endPoint = new Point()
- {
- X = x2,
- Y = y2
- };
- return Point.distance(startPoint,endPoint);
- }
- // POST api/values
- public void Post([FromBody]string value)
- {
- }
- // PUT api/values/5
- public void Put(int id, [FromBody]string value)
- {
- }
- // DELETE api/values/5
- public void Delete(int id)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement