public static TSquare operator *(double n, TSquare Square) { TSquare sum = new TSquare(); sum.side = n * Square.side; return(sum); }
static void Main(string[] args) { TSquare Square = new TSquare(); TSquare Square2 = new TSquare(); Console.WriteLine("Side of Square equals: " + Square); Console.WriteLine("Side of Square2 equals: " + Square2); Console.WriteLine(); Square.GetArea(); Square.GetPerimeter(); TSquare.Compare(Square, Square2); Square2.GetArea(); Square2.GetPerimeter(); Console.WriteLine("Sum of squares " + (Square + Square2)); Console.WriteLine(); TCube cube = new TCube(); Console.WriteLine("Side of cube equals: " + cube); cube.Volume(); }
public static TSquare operator *(TSquare Square, double n) { TSquare sum = new TSquare(); sum.side = Square.side * n; return(sum); }
public static TSquare operator -(TSquare Square, TSquare Square2) { TSquare sum = new TSquare(); sum.side = Math.Abs(Square.side - Square2.side); return(sum); }
public static TSquare operator +(TSquare Square, TSquare Square2) { TSquare sum = new TSquare(); sum.side = Square.side + Square2.side; return(sum); }
public static void Compare(TSquare Square, TSquare Square2) { if (Square.side > Square2.side) { Console.WriteLine(Square.side + " > " + Square2.side + " on " + (Square.side - Square2.side)); } else if (Square.side < Square2.side) { Console.WriteLine(Square.side + " < " + Square2.side + " on " + (Square2.side - Square.side)); } else if (Square.side == Square2.side) { Console.WriteLine(Square.side + " = " + Square2.side); } }
public TSquare(TSquare Square) { this.side = Square.side; }