Вывод на экран результата - C#
Формулировка задачи:
Не могу вывести результат после перегрузки сложения и вычитания для векторов. Что неправильно?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace labwork3
{
public class Vector
{
private double fx;
private double fy;
public Vector(double ax, double ay)
{
fx = ax;
fy = ay;
}
public double x { get; set; }
public double y {get; set;}
public static Vector operator +(Vector v1, Vector v2)
{
return new Vector(v1.x + v2.x, v1.y + v2.y);
}
public static Vector operator -(Vector v1, Vector v2)
{
return new Vector(v1.x - v2.x, v1.y - v2.y);
}
public void Print(Vector v3)
{
Console.WriteLine("x - {0}, y -{1}",Convert.ToString(v3.x), Convert.ToString(v3.y));
}
}
class Program
{
static void Main(string[] args)
{
Vector a = new Vector(5, 4);
Vector b = new Vector(7, 5);
Vector c = a + b;
c.Print(c);
Console.Read();
}
}
}Решение задачи: «Вывод на экран результата»
textual
Листинг программы
public Vector(double ax, double ay)
{
x = ax;
y = ay;
}