Recap Challenge #1
Lesson 12 of 12 in Coddy's Basics of Classes and Objects in C# course.
Challenge
EasyYou are given a code with a Point class.
Your task is to implement the program in the main method that gets from the input two points and calculates the distance between them.
The order of the input is:
x1
y1
x2
y2
Try it yourself
using System;
class Point {
int x;
int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public double distFrom(Point otherPoint) {
return Math.Sqrt(Math.Pow(this.x - otherPoint.x, 2) + Math.Pow(this.y - otherPoint.y, 2));
}
}
class Program {
public static void Main(string[] args) {
// Write code here
}
}All lessons in Basics of Classes and Objects in C#
1Introduction
Introduction